]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.1-201309162121.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.1-201309162121.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 efd2396..682975d 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..9732b1c 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 @@ -366,6 +394,12 @@ ENTRY(vector_swi)
2611 #endif
2612 zero_fp
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 #ifdef CONFIG_ALIGNMENT_TRAP
2621 ldr ip, __cr_alignment
2622 ldr ip, [ip]
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..b3068b1 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,37 @@
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 +
2783 +void *module_alloc_exec(unsigned long size)
2784 +{
2785 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2786 +}
2787 +#endif
2788 #endif
2789
2790 int
2791 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2792 index 07314af..c46655c 100644
2793 --- a/arch/arm/kernel/patch.c
2794 +++ b/arch/arm/kernel/patch.c
2795 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2796 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2797 int size;
2798
2799 + pax_open_kernel();
2800 if (thumb2 && __opcode_is_thumb16(insn)) {
2801 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2802 size = sizeof(u16);
2803 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2804 *(u32 *)addr = insn;
2805 size = sizeof(u32);
2806 }
2807 + pax_close_kernel();
2808
2809 flush_icache_range((uintptr_t)(addr),
2810 (uintptr_t)(addr) + size);
2811 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2812 index 94f6b05..efd7312 100644
2813 --- a/arch/arm/kernel/process.c
2814 +++ b/arch/arm/kernel/process.c
2815 @@ -217,6 +217,7 @@ void machine_power_off(void)
2816
2817 if (pm_power_off)
2818 pm_power_off();
2819 + BUG();
2820 }
2821
2822 /*
2823 @@ -230,7 +231,7 @@ void machine_power_off(void)
2824 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2825 * to use. Implementing such co-ordination would be essentially impossible.
2826 */
2827 -void machine_restart(char *cmd)
2828 +__noreturn void machine_restart(char *cmd)
2829 {
2830 local_irq_disable();
2831 smp_send_stop();
2832 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2833
2834 show_regs_print_info(KERN_DEFAULT);
2835
2836 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2837 - print_symbol("LR is at %s\n", regs->ARM_lr);
2838 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2839 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2840 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2841 "sp : %08lx ip : %08lx fp : %08lx\n",
2842 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2843 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2844 return 0;
2845 }
2846
2847 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2848 -{
2849 - unsigned long range_end = mm->brk + 0x02000000;
2850 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2851 -}
2852 -
2853 #ifdef CONFIG_MMU
2854 #ifdef CONFIG_KUSER_HELPERS
2855 /*
2856 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2857
2858 static int __init gate_vma_init(void)
2859 {
2860 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2861 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2862 return 0;
2863 }
2864 arch_initcall(gate_vma_init);
2865 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2866
2867 const char *arch_vma_name(struct vm_area_struct *vma)
2868 {
2869 - return is_gate_vma(vma) ? "[vectors]" :
2870 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2871 - "[sigpage]" : NULL;
2872 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2873 }
2874
2875 -static struct page *signal_page;
2876 -extern struct page *get_signal_page(void);
2877 -
2878 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2879 {
2880 struct mm_struct *mm = current->mm;
2881 - unsigned long addr;
2882 - int ret;
2883 -
2884 - if (!signal_page)
2885 - signal_page = get_signal_page();
2886 - if (!signal_page)
2887 - return -ENOMEM;
2888
2889 down_write(&mm->mmap_sem);
2890 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2891 - if (IS_ERR_VALUE(addr)) {
2892 - ret = addr;
2893 - goto up_fail;
2894 - }
2895 -
2896 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2897 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2898 - &signal_page);
2899 -
2900 - if (ret == 0)
2901 - mm->context.sigpage = addr;
2902 -
2903 - up_fail:
2904 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2905 up_write(&mm->mmap_sem);
2906 - return ret;
2907 + return 0;
2908 }
2909 #endif
2910 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2911 index 4693188..4596c5e 100644
2912 --- a/arch/arm/kernel/psci.c
2913 +++ b/arch/arm/kernel/psci.c
2914 @@ -24,7 +24,7 @@
2915 #include <asm/opcodes-virt.h>
2916 #include <asm/psci.h>
2917
2918 -struct psci_operations psci_ops;
2919 +struct psci_operations psci_ops __read_only;
2920
2921 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2922
2923 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2924 index 0dd3b79..e018f64 100644
2925 --- a/arch/arm/kernel/ptrace.c
2926 +++ b/arch/arm/kernel/ptrace.c
2927 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2928 return current_thread_info()->syscall;
2929 }
2930
2931 +#ifdef CONFIG_GRKERNSEC_SETXID
2932 +extern void gr_delayed_cred_worker(void);
2933 +#endif
2934 +
2935 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2936 {
2937 current_thread_info()->syscall = scno;
2938
2939 +#ifdef CONFIG_GRKERNSEC_SETXID
2940 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2941 + gr_delayed_cred_worker();
2942 +#endif
2943 +
2944 /* Do the secure computing check first; failures should be fast. */
2945 if (secure_computing(scno) == -1)
2946 return -1;
2947 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2948 index afc2489..6372bc8 100644
2949 --- a/arch/arm/kernel/setup.c
2950 +++ b/arch/arm/kernel/setup.c
2951 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2952 unsigned int elf_hwcap __read_mostly;
2953 EXPORT_SYMBOL(elf_hwcap);
2954
2955 +pteval_t __supported_pte_mask __read_only;
2956 +pmdval_t __supported_pmd_mask __read_only;
2957
2958 #ifdef MULTI_CPU
2959 -struct processor processor __read_mostly;
2960 +struct processor processor;
2961 #endif
2962 #ifdef MULTI_TLB
2963 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2964 +struct cpu_tlb_fns cpu_tlb __read_only;
2965 #endif
2966 #ifdef MULTI_USER
2967 -struct cpu_user_fns cpu_user __read_mostly;
2968 +struct cpu_user_fns cpu_user __read_only;
2969 #endif
2970 #ifdef MULTI_CACHE
2971 -struct cpu_cache_fns cpu_cache __read_mostly;
2972 +struct cpu_cache_fns cpu_cache __read_only;
2973 #endif
2974 #ifdef CONFIG_OUTER_CACHE
2975 -struct outer_cache_fns outer_cache __read_mostly;
2976 +struct outer_cache_fns outer_cache __read_only;
2977 EXPORT_SYMBOL(outer_cache);
2978 #endif
2979
2980 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2981 asm("mrc p15, 0, %0, c0, c1, 4"
2982 : "=r" (mmfr0));
2983 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2984 - (mmfr0 & 0x000000f0) >= 0x00000030)
2985 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2986 cpu_arch = CPU_ARCH_ARMv7;
2987 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2988 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2989 + __supported_pte_mask |= L_PTE_PXN;
2990 + __supported_pmd_mask |= PMD_PXNTABLE;
2991 + }
2992 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2993 (mmfr0 & 0x000000f0) == 0x00000020)
2994 cpu_arch = CPU_ARCH_ARMv6;
2995 else
2996 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2997 __cpu_architecture = __get_cpu_architecture();
2998
2999 #ifdef MULTI_CPU
3000 - processor = *list->proc;
3001 + memcpy((void *)&processor, list->proc, sizeof processor);
3002 #endif
3003 #ifdef MULTI_TLB
3004 cpu_tlb = *list->tlb;
3005 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3006 index ab33042..11248a8 100644
3007 --- a/arch/arm/kernel/signal.c
3008 +++ b/arch/arm/kernel/signal.c
3009 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3010 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3011 };
3012
3013 -static unsigned long signal_return_offset;
3014 -
3015 #ifdef CONFIG_CRUNCH
3016 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3017 {
3018 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3019 * except when the MPU has protected the vectors
3020 * page from PL0
3021 */
3022 - retcode = mm->context.sigpage + signal_return_offset +
3023 - (idx << 2) + thumb;
3024 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3025 } else
3026 #endif
3027 {
3028 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3029 } while (thread_flags & _TIF_WORK_MASK);
3030 return 0;
3031 }
3032 -
3033 -struct page *get_signal_page(void)
3034 -{
3035 - unsigned long ptr;
3036 - unsigned offset;
3037 - struct page *page;
3038 - void *addr;
3039 -
3040 - page = alloc_pages(GFP_KERNEL, 0);
3041 -
3042 - if (!page)
3043 - return NULL;
3044 -
3045 - addr = page_address(page);
3046 -
3047 - /* Give the signal return code some randomness */
3048 - offset = 0x200 + (get_random_int() & 0x7fc);
3049 - signal_return_offset = offset;
3050 -
3051 - /*
3052 - * Copy signal return handlers into the vector page, and
3053 - * set sigreturn to be a pointer to these.
3054 - */
3055 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3056 -
3057 - ptr = (unsigned long)addr + offset;
3058 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3059 -
3060 - return page;
3061 -}
3062 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3063 index 2dc1934..ecf0e21 100644
3064 --- a/arch/arm/kernel/smp.c
3065 +++ b/arch/arm/kernel/smp.c
3066 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3067
3068 static DECLARE_COMPLETION(cpu_running);
3069
3070 -static struct smp_operations smp_ops;
3071 +static struct smp_operations smp_ops __read_only;
3072
3073 void __init smp_set_ops(struct smp_operations *ops)
3074 {
3075 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3076 index ab517fc..9adf2fa 100644
3077 --- a/arch/arm/kernel/traps.c
3078 +++ b/arch/arm/kernel/traps.c
3079 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3080 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3081 {
3082 #ifdef CONFIG_KALLSYMS
3083 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3084 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3085 #else
3086 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3087 #endif
3088 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3089 static int die_owner = -1;
3090 static unsigned int die_nest_count;
3091
3092 +extern void gr_handle_kernel_exploit(void);
3093 +
3094 static unsigned long oops_begin(void)
3095 {
3096 int cpu;
3097 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3098 panic("Fatal exception in interrupt");
3099 if (panic_on_oops)
3100 panic("Fatal exception");
3101 +
3102 + gr_handle_kernel_exploit();
3103 +
3104 if (signr)
3105 do_exit(signr);
3106 }
3107 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3108 * The user helper at 0xffff0fe0 must be used instead.
3109 * (see entry-armv.S for details)
3110 */
3111 + pax_open_kernel();
3112 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3113 + pax_close_kernel();
3114 }
3115 return 0;
3116
3117 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3118 kuser_init(vectors_base);
3119
3120 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3121 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3122 +
3123 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3124 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3125 +#endif
3126 +
3127 #else /* ifndef CONFIG_CPU_V7M */
3128 /*
3129 * on V7-M there is no need to copy the vector table to a dedicated
3130 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3131 index 7bcee5c..64c9c5f 100644
3132 --- a/arch/arm/kernel/vmlinux.lds.S
3133 +++ b/arch/arm/kernel/vmlinux.lds.S
3134 @@ -8,7 +8,11 @@
3135 #include <asm/thread_info.h>
3136 #include <asm/memory.h>
3137 #include <asm/page.h>
3138 -
3139 +
3140 +#ifdef CONFIG_PAX_KERNEXEC
3141 +#include <asm/pgtable.h>
3142 +#endif
3143 +
3144 #define PROC_INFO \
3145 . = ALIGN(4); \
3146 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3147 @@ -90,6 +94,11 @@ SECTIONS
3148 _text = .;
3149 HEAD_TEXT
3150 }
3151 +
3152 +#ifdef CONFIG_PAX_KERNEXEC
3153 + . = ALIGN(1<<SECTION_SHIFT);
3154 +#endif
3155 +
3156 .text : { /* Real text segment */
3157 _stext = .; /* Text and read-only data */
3158 __exception_text_start = .;
3159 @@ -112,6 +121,8 @@ SECTIONS
3160 ARM_CPU_KEEP(PROC_INFO)
3161 }
3162
3163 + _etext = .; /* End of text section */
3164 +
3165 RO_DATA(PAGE_SIZE)
3166
3167 . = ALIGN(4);
3168 @@ -142,7 +153,9 @@ SECTIONS
3169
3170 NOTES
3171
3172 - _etext = .; /* End of text and rodata section */
3173 +#ifdef CONFIG_PAX_KERNEXEC
3174 + . = ALIGN(1<<SECTION_SHIFT);
3175 +#endif
3176
3177 #ifndef CONFIG_XIP_KERNEL
3178 . = ALIGN(PAGE_SIZE);
3179 @@ -220,6 +233,11 @@ SECTIONS
3180 . = PAGE_OFFSET + TEXT_OFFSET;
3181 #else
3182 __init_end = .;
3183 +
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187 +
3188 . = ALIGN(THREAD_SIZE);
3189 __data_loc = .;
3190 #endif
3191 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3192 index 741f66a..8a5615c 100644
3193 --- a/arch/arm/kvm/arm.c
3194 +++ b/arch/arm/kvm/arm.c
3195 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3196 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3197
3198 /* The VMID used in the VTTBR */
3199 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3200 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3201 static u8 kvm_next_vmid;
3202 static DEFINE_SPINLOCK(kvm_vmid_lock);
3203
3204 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3205 */
3206 static bool need_new_vmid_gen(struct kvm *kvm)
3207 {
3208 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3209 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3210 }
3211
3212 /**
3213 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3214
3215 /* First user of a new VMID generation? */
3216 if (unlikely(kvm_next_vmid == 0)) {
3217 - atomic64_inc(&kvm_vmid_gen);
3218 + atomic64_inc_unchecked(&kvm_vmid_gen);
3219 kvm_next_vmid = 1;
3220
3221 /*
3222 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3223 kvm_call_hyp(__kvm_flush_vm_context);
3224 }
3225
3226 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3227 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3228 kvm->arch.vmid = kvm_next_vmid;
3229 kvm_next_vmid++;
3230
3231 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3232 index 14a0d98..7771a7d 100644
3233 --- a/arch/arm/lib/clear_user.S
3234 +++ b/arch/arm/lib/clear_user.S
3235 @@ -12,14 +12,14 @@
3236
3237 .text
3238
3239 -/* Prototype: int __clear_user(void *addr, size_t sz)
3240 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3241 * Purpose : clear some user memory
3242 * Params : addr - user memory address to clear
3243 * : sz - number of bytes to clear
3244 * Returns : number of bytes NOT cleared
3245 */
3246 ENTRY(__clear_user_std)
3247 -WEAK(__clear_user)
3248 +WEAK(___clear_user)
3249 stmfd sp!, {r1, lr}
3250 mov r2, #0
3251 cmp r1, #4
3252 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3253 USER( strnebt r2, [r0])
3254 mov r0, #0
3255 ldmfd sp!, {r1, pc}
3256 -ENDPROC(__clear_user)
3257 +ENDPROC(___clear_user)
3258 ENDPROC(__clear_user_std)
3259
3260 .pushsection .fixup,"ax"
3261 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3262 index 66a477a..bee61d3 100644
3263 --- a/arch/arm/lib/copy_from_user.S
3264 +++ b/arch/arm/lib/copy_from_user.S
3265 @@ -16,7 +16,7 @@
3266 /*
3267 * Prototype:
3268 *
3269 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3270 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3271 *
3272 * Purpose:
3273 *
3274 @@ -84,11 +84,11 @@
3275
3276 .text
3277
3278 -ENTRY(__copy_from_user)
3279 +ENTRY(___copy_from_user)
3280
3281 #include "copy_template.S"
3282
3283 -ENDPROC(__copy_from_user)
3284 +ENDPROC(___copy_from_user)
3285
3286 .pushsection .fixup,"ax"
3287 .align 0
3288 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3289 index 6ee2f67..d1cce76 100644
3290 --- a/arch/arm/lib/copy_page.S
3291 +++ b/arch/arm/lib/copy_page.S
3292 @@ -10,6 +10,7 @@
3293 * ASM optimised string functions
3294 */
3295 #include <linux/linkage.h>
3296 +#include <linux/const.h>
3297 #include <asm/assembler.h>
3298 #include <asm/asm-offsets.h>
3299 #include <asm/cache.h>
3300 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3301 index d066df6..df28194 100644
3302 --- a/arch/arm/lib/copy_to_user.S
3303 +++ b/arch/arm/lib/copy_to_user.S
3304 @@ -16,7 +16,7 @@
3305 /*
3306 * Prototype:
3307 *
3308 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3309 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3310 *
3311 * Purpose:
3312 *
3313 @@ -88,11 +88,11 @@
3314 .text
3315
3316 ENTRY(__copy_to_user_std)
3317 -WEAK(__copy_to_user)
3318 +WEAK(___copy_to_user)
3319
3320 #include "copy_template.S"
3321
3322 -ENDPROC(__copy_to_user)
3323 +ENDPROC(___copy_to_user)
3324 ENDPROC(__copy_to_user_std)
3325
3326 .pushsection .fixup,"ax"
3327 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3328 index 7d08b43..f7ca7ea 100644
3329 --- a/arch/arm/lib/csumpartialcopyuser.S
3330 +++ b/arch/arm/lib/csumpartialcopyuser.S
3331 @@ -57,8 +57,8 @@
3332 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3333 */
3334
3335 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3336 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3337 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3338 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3339
3340 #include "csumpartialcopygeneric.S"
3341
3342 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3343 index 5306de3..aed6d03 100644
3344 --- a/arch/arm/lib/delay.c
3345 +++ b/arch/arm/lib/delay.c
3346 @@ -28,7 +28,7 @@
3347 /*
3348 * Default to the loop-based delay implementation.
3349 */
3350 -struct arm_delay_ops arm_delay_ops = {
3351 +struct arm_delay_ops arm_delay_ops __read_only = {
3352 .delay = __loop_delay,
3353 .const_udelay = __loop_const_udelay,
3354 .udelay = __loop_udelay,
3355 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3356 index 025f742..a9e5b3b 100644
3357 --- a/arch/arm/lib/uaccess_with_memcpy.c
3358 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3359 @@ -104,7 +104,7 @@ out:
3360 }
3361
3362 unsigned long
3363 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3364 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3365 {
3366 /*
3367 * This test is stubbed out of the main function above to keep
3368 @@ -155,7 +155,7 @@ out:
3369 return n;
3370 }
3371
3372 -unsigned long __clear_user(void __user *addr, unsigned long n)
3373 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3374 {
3375 /* See rational for this in __copy_to_user() above. */
3376 if (n < 64)
3377 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3378 index e9238b5..6ed904a 100644
3379 --- a/arch/arm/mach-kirkwood/common.c
3380 +++ b/arch/arm/mach-kirkwood/common.c
3381 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3382 clk_gate_ops.disable(hw);
3383 }
3384
3385 -static struct clk_ops clk_gate_fn_ops;
3386 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3387 +{
3388 + return clk_gate_ops.is_enabled(hw);
3389 +}
3390 +
3391 +static struct clk_ops clk_gate_fn_ops = {
3392 + .enable = clk_gate_fn_enable,
3393 + .disable = clk_gate_fn_disable,
3394 + .is_enabled = clk_gate_fn_is_enabled,
3395 +};
3396
3397 static struct clk __init *clk_register_gate_fn(struct device *dev,
3398 const char *name,
3399 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3400 gate_fn->fn_en = fn_en;
3401 gate_fn->fn_dis = fn_dis;
3402
3403 - /* ops is the gate ops, but with our enable/disable functions */
3404 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3405 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3406 - clk_gate_fn_ops = clk_gate_ops;
3407 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3408 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3409 - }
3410 -
3411 clk = clk_register(dev, &gate_fn->gate.hw);
3412
3413 if (IS_ERR(clk))
3414 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3415 index 827d1500..2885dc6 100644
3416 --- a/arch/arm/mach-omap2/board-n8x0.c
3417 +++ b/arch/arm/mach-omap2/board-n8x0.c
3418 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3419 }
3420 #endif
3421
3422 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3423 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3424 .late_init = n8x0_menelaus_late_init,
3425 };
3426
3427 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3428 index f3fdd6a..3564800 100644
3429 --- a/arch/arm/mach-omap2/gpmc.c
3430 +++ b/arch/arm/mach-omap2/gpmc.c
3431 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3432 };
3433
3434 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3435 -static struct irq_chip gpmc_irq_chip;
3436 static unsigned gpmc_irq_start;
3437
3438 static struct resource gpmc_mem_root;
3439 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3440
3441 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3442
3443 +static struct irq_chip gpmc_irq_chip = {
3444 + .name = "gpmc",
3445 + .irq_startup = gpmc_irq_noop_ret,
3446 + .irq_enable = gpmc_irq_enable,
3447 + .irq_disable = gpmc_irq_disable,
3448 + .irq_shutdown = gpmc_irq_noop,
3449 + .irq_ack = gpmc_irq_noop,
3450 + .irq_mask = gpmc_irq_noop,
3451 + .irq_unmask = gpmc_irq_noop,
3452 +
3453 +};
3454 +
3455 static int gpmc_setup_irq(void)
3456 {
3457 int i;
3458 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3459 return gpmc_irq_start;
3460 }
3461
3462 - gpmc_irq_chip.name = "gpmc";
3463 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3464 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3465 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3466 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3467 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3468 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3469 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3470 -
3471 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3472 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3473
3474 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3475 index 813c615..ce467c6 100644
3476 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3477 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3478 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3479 return NOTIFY_OK;
3480 }
3481
3482 -static struct notifier_block __refdata irq_hotplug_notifier = {
3483 +static struct notifier_block irq_hotplug_notifier = {
3484 .notifier_call = irq_cpu_hotplug_notify,
3485 };
3486
3487 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3488 index f99f68e..e573e20 100644
3489 --- a/arch/arm/mach-omap2/omap_device.c
3490 +++ b/arch/arm/mach-omap2/omap_device.c
3491 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3492 struct platform_device __init *omap_device_build(const char *pdev_name,
3493 int pdev_id,
3494 struct omap_hwmod *oh,
3495 - void *pdata, int pdata_len)
3496 + const void *pdata, int pdata_len)
3497 {
3498 struct omap_hwmod *ohs[] = { oh };
3499
3500 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3501 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3502 int pdev_id,
3503 struct omap_hwmod **ohs,
3504 - int oh_cnt, void *pdata,
3505 + int oh_cnt, const void *pdata,
3506 int pdata_len)
3507 {
3508 int ret = -ENOMEM;
3509 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3510 index 17ca1ae..beba869 100644
3511 --- a/arch/arm/mach-omap2/omap_device.h
3512 +++ b/arch/arm/mach-omap2/omap_device.h
3513 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3514 /* Core code interface */
3515
3516 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3517 - struct omap_hwmod *oh, void *pdata,
3518 + struct omap_hwmod *oh, const void *pdata,
3519 int pdata_len);
3520
3521 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3522 struct omap_hwmod **oh, int oh_cnt,
3523 - void *pdata, int pdata_len);
3524 + const void *pdata, int pdata_len);
3525
3526 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3527 struct omap_hwmod **ohs, int oh_cnt);
3528 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3529 index 7f4db12..0243012 100644
3530 --- a/arch/arm/mach-omap2/omap_hwmod.c
3531 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3532 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3533 int (*init_clkdm)(struct omap_hwmod *oh);
3534 void (*update_context_lost)(struct omap_hwmod *oh);
3535 int (*get_context_lost)(struct omap_hwmod *oh);
3536 -};
3537 +} __no_const;
3538
3539 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3540 -static struct omap_hwmod_soc_ops soc_ops;
3541 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3542
3543 /* omap_hwmod_list contains all registered struct omap_hwmods */
3544 static LIST_HEAD(omap_hwmod_list);
3545 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3546 index d15c7bb..b2d1f0c 100644
3547 --- a/arch/arm/mach-omap2/wd_timer.c
3548 +++ b/arch/arm/mach-omap2/wd_timer.c
3549 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3550 struct omap_hwmod *oh;
3551 char *oh_name = "wd_timer2";
3552 char *dev_name = "omap_wdt";
3553 - struct omap_wd_timer_platform_data pdata;
3554 + static struct omap_wd_timer_platform_data pdata = {
3555 + .read_reset_sources = prm_read_reset_sources
3556 + };
3557
3558 if (!cpu_class_is_omap2() || of_have_populated_dt())
3559 return 0;
3560 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3561 return -EINVAL;
3562 }
3563
3564 - pdata.read_reset_sources = prm_read_reset_sources;
3565 -
3566 pdev = omap_device_build(dev_name, id, oh, &pdata,
3567 sizeof(struct omap_wd_timer_platform_data));
3568 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3569 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3570 index 706aa42..f85e9131 100644
3571 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3572 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3573 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3574 bool entered_lp2 = false;
3575
3576 if (tegra_pending_sgi())
3577 - ACCESS_ONCE(abort_flag) = true;
3578 + ACCESS_ONCE_RW(abort_flag) = true;
3579
3580 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3581
3582 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3583 index cad3ca86..1d79e0f 100644
3584 --- a/arch/arm/mach-ux500/setup.h
3585 +++ b/arch/arm/mach-ux500/setup.h
3586 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3587 .type = MT_DEVICE, \
3588 }
3589
3590 -#define __MEM_DEV_DESC(x, sz) { \
3591 - .virtual = IO_ADDRESS(x), \
3592 - .pfn = __phys_to_pfn(x), \
3593 - .length = sz, \
3594 - .type = MT_MEMORY, \
3595 -}
3596 -
3597 extern struct smp_operations ux500_smp_ops;
3598 extern void ux500_cpu_die(unsigned int cpu);
3599
3600 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3601 index cd2c88e..7430282 100644
3602 --- a/arch/arm/mm/Kconfig
3603 +++ b/arch/arm/mm/Kconfig
3604 @@ -446,7 +446,7 @@ config CPU_32v5
3605
3606 config CPU_32v6
3607 bool
3608 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3609 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3610 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3611
3612 config CPU_32v6K
3613 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3614
3615 config CPU_USE_DOMAINS
3616 bool
3617 + depends on !ARM_LPAE && !PAX_KERNEXEC
3618 help
3619 This option enables or disables the use of domain switching
3620 via the set_fs() function.
3621 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3622 config KUSER_HELPERS
3623 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3624 default y
3625 + depends on !(CPU_V6 || CPU_V6K || CPU_V7)
3626 help
3627 Warning: disabling this option may break user programs.
3628
3629 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3630 See Documentation/arm/kernel_user_helpers.txt for details.
3631
3632 However, the fixed address nature of these helpers can be used
3633 - by ROP (return orientated programming) authors when creating
3634 + by ROP (Return Oriented Programming) authors when creating
3635 exploits.
3636
3637 If all of the binaries and libraries which run on your platform
3638 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3639 index 6f4585b..7b6f52b 100644
3640 --- a/arch/arm/mm/alignment.c
3641 +++ b/arch/arm/mm/alignment.c
3642 @@ -211,10 +211,12 @@ union offset_union {
3643 #define __get16_unaligned_check(ins,val,addr) \
3644 do { \
3645 unsigned int err = 0, v, a = addr; \
3646 + pax_open_userland(); \
3647 __get8_unaligned_check(ins,v,a,err); \
3648 val = v << ((BE) ? 8 : 0); \
3649 __get8_unaligned_check(ins,v,a,err); \
3650 val |= v << ((BE) ? 0 : 8); \
3651 + pax_close_userland(); \
3652 if (err) \
3653 goto fault; \
3654 } while (0)
3655 @@ -228,6 +230,7 @@ union offset_union {
3656 #define __get32_unaligned_check(ins,val,addr) \
3657 do { \
3658 unsigned int err = 0, v, a = addr; \
3659 + pax_open_userland(); \
3660 __get8_unaligned_check(ins,v,a,err); \
3661 val = v << ((BE) ? 24 : 0); \
3662 __get8_unaligned_check(ins,v,a,err); \
3663 @@ -236,6 +239,7 @@ union offset_union {
3664 val |= v << ((BE) ? 8 : 16); \
3665 __get8_unaligned_check(ins,v,a,err); \
3666 val |= v << ((BE) ? 0 : 24); \
3667 + pax_close_userland(); \
3668 if (err) \
3669 goto fault; \
3670 } while (0)
3671 @@ -249,6 +253,7 @@ union offset_union {
3672 #define __put16_unaligned_check(ins,val,addr) \
3673 do { \
3674 unsigned int err = 0, v = val, a = addr; \
3675 + pax_open_userland(); \
3676 __asm__( FIRST_BYTE_16 \
3677 ARM( "1: "ins" %1, [%2], #1\n" ) \
3678 THUMB( "1: "ins" %1, [%2]\n" ) \
3679 @@ -268,6 +273,7 @@ union offset_union {
3680 " .popsection\n" \
3681 : "=r" (err), "=&r" (v), "=&r" (a) \
3682 : "0" (err), "1" (v), "2" (a)); \
3683 + pax_close_userland(); \
3684 if (err) \
3685 goto fault; \
3686 } while (0)
3687 @@ -281,6 +287,7 @@ union offset_union {
3688 #define __put32_unaligned_check(ins,val,addr) \
3689 do { \
3690 unsigned int err = 0, v = val, a = addr; \
3691 + pax_open_userland(); \
3692 __asm__( FIRST_BYTE_32 \
3693 ARM( "1: "ins" %1, [%2], #1\n" ) \
3694 THUMB( "1: "ins" %1, [%2]\n" ) \
3695 @@ -310,6 +317,7 @@ union offset_union {
3696 " .popsection\n" \
3697 : "=r" (err), "=&r" (v), "=&r" (a) \
3698 : "0" (err), "1" (v), "2" (a)); \
3699 + pax_close_userland(); \
3700 if (err) \
3701 goto fault; \
3702 } while (0)
3703 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3704 index 4a05444..d21968c 100644
3705 --- a/arch/arm/mm/context.c
3706 +++ b/arch/arm/mm/context.c
3707 @@ -43,7 +43,7 @@
3708 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3709
3710 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3711 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3712 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3713 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3714
3715 static DEFINE_PER_CPU(atomic64_t, active_asids);
3716 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3717 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3718 {
3719 u64 asid = atomic64_read(&mm->context.id);
3720 - u64 generation = atomic64_read(&asid_generation);
3721 + u64 generation = atomic64_read_unchecked(&asid_generation);
3722
3723 if (asid != 0 && is_reserved_asid(asid)) {
3724 /*
3725 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3726 */
3727 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3728 if (asid == NUM_USER_ASIDS) {
3729 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3730 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3731 &asid_generation);
3732 flush_context(cpu);
3733 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3734 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3735 cpu_set_reserved_ttbr0();
3736
3737 asid = atomic64_read(&mm->context.id);
3738 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3739 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3740 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3741 goto switch_mm_fastpath;
3742
3743 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3744 /* Check that our ASID belongs to the current generation. */
3745 asid = atomic64_read(&mm->context.id);
3746 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3747 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3748 asid = new_context(mm, cpu);
3749 atomic64_set(&mm->context.id, asid);
3750 }
3751 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3752 index c97f794..e5aeea5 100644
3753 --- a/arch/arm/mm/fault.c
3754 +++ b/arch/arm/mm/fault.c
3755 @@ -25,6 +25,7 @@
3756 #include <asm/system_misc.h>
3757 #include <asm/system_info.h>
3758 #include <asm/tlbflush.h>
3759 +#include <asm/sections.h>
3760
3761 #include "fault.h"
3762
3763 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3764 if (fixup_exception(regs))
3765 return;
3766
3767 +#ifdef CONFIG_PAX_KERNEXEC
3768 + if ((fsr & FSR_WRITE) &&
3769 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3770 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3771 + {
3772 + if (current->signal->curr_ip)
3773 + 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),
3774 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3775 + else
3776 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3777 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3778 + }
3779 +#endif
3780 +
3781 /*
3782 * No handler, we'll have to terminate things with extreme prejudice.
3783 */
3784 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3785 }
3786 #endif
3787
3788 +#ifdef CONFIG_PAX_PAGEEXEC
3789 + if (fsr & FSR_LNX_PF) {
3790 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3791 + do_group_exit(SIGKILL);
3792 + }
3793 +#endif
3794 +
3795 tsk->thread.address = addr;
3796 tsk->thread.error_code = fsr;
3797 tsk->thread.trap_no = 14;
3798 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3799 }
3800 #endif /* CONFIG_MMU */
3801
3802 +#ifdef CONFIG_PAX_PAGEEXEC
3803 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3804 +{
3805 + long i;
3806 +
3807 + printk(KERN_ERR "PAX: bytes at PC: ");
3808 + for (i = 0; i < 20; i++) {
3809 + unsigned char c;
3810 + if (get_user(c, (__force unsigned char __user *)pc+i))
3811 + printk(KERN_CONT "?? ");
3812 + else
3813 + printk(KERN_CONT "%02x ", c);
3814 + }
3815 + printk("\n");
3816 +
3817 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3818 + for (i = -1; i < 20; i++) {
3819 + unsigned long c;
3820 + if (get_user(c, (__force unsigned long __user *)sp+i))
3821 + printk(KERN_CONT "???????? ");
3822 + else
3823 + printk(KERN_CONT "%08lx ", c);
3824 + }
3825 + printk("\n");
3826 +}
3827 +#endif
3828 +
3829 /*
3830 * First Level Translation Fault Handler
3831 *
3832 @@ -545,9 +594,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3833 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3834 struct siginfo info;
3835
3836 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3837 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3838 + if (current->signal->curr_ip)
3839 + 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),
3840 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3841 + else
3842 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3843 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3844 + goto die;
3845 + }
3846 +#endif
3847 +
3848 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3849 return;
3850
3851 +die:
3852 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3853 inf->name, fsr, addr);
3854
3855 @@ -571,15 +633,68 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3856 ifsr_info[nr].name = name;
3857 }
3858
3859 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3860 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3861 +
3862 asmlinkage void __exception
3863 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3864 {
3865 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3866 struct siginfo info;
3867 + unsigned long pc = instruction_pointer(regs);
3868 +
3869 + if (user_mode(regs)) {
3870 + unsigned long sigpage = current->mm->context.sigpage;
3871 +
3872 + if (sigpage <= pc && pc < sigpage + 7*4) {
3873 + if (pc < sigpage + 3*4)
3874 + sys_sigreturn(regs);
3875 + else
3876 + sys_rt_sigreturn(regs);
3877 + return;
3878 + }
3879 + if (pc == 0xffff0fe0UL) {
3880 + /*
3881 + * PaX: __kuser_get_tls emulation
3882 + */
3883 + regs->ARM_r0 = current_thread_info()->tp_value;
3884 + regs->ARM_pc = regs->ARM_lr;
3885 + return;
3886 + }
3887 + }
3888 +
3889 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3890 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3891 + if (current->signal->curr_ip)
3892 + 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),
3893 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3894 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3895 + else
3896 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3897 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3898 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3899 + goto die;
3900 + }
3901 +#endif
3902 +
3903 +#ifdef CONFIG_PAX_REFCOUNT
3904 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3905 + unsigned int bkpt;
3906 +
3907 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3908 + current->thread.error_code = ifsr;
3909 + current->thread.trap_no = 0;
3910 + pax_report_refcount_overflow(regs);
3911 + fixup_exception(regs);
3912 + return;
3913 + }
3914 + }
3915 +#endif
3916
3917 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3918 return;
3919
3920 +die:
3921 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3922 inf->name, ifsr, addr);
3923
3924 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3925 index cf08bdf..772656c 100644
3926 --- a/arch/arm/mm/fault.h
3927 +++ b/arch/arm/mm/fault.h
3928 @@ -3,6 +3,7 @@
3929
3930 /*
3931 * Fault status register encodings. We steal bit 31 for our own purposes.
3932 + * Set when the FSR value is from an instruction fault.
3933 */
3934 #define FSR_LNX_PF (1 << 31)
3935 #define FSR_WRITE (1 << 11)
3936 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3937 }
3938 #endif
3939
3940 +/* valid for LPAE and !LPAE */
3941 +static inline int is_xn_fault(unsigned int fsr)
3942 +{
3943 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3944 +}
3945 +
3946 +static inline int is_domain_fault(unsigned int fsr)
3947 +{
3948 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3949 +}
3950 +
3951 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3952 unsigned long search_exception_table(unsigned long addr);
3953
3954 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3955 index 15225d8..25e2e3c 100644
3956 --- a/arch/arm/mm/init.c
3957 +++ b/arch/arm/mm/init.c
3958 @@ -30,6 +30,8 @@
3959 #include <asm/setup.h>
3960 #include <asm/tlb.h>
3961 #include <asm/fixmap.h>
3962 +#include <asm/system_info.h>
3963 +#include <asm/cp15.h>
3964
3965 #include <asm/mach/arch.h>
3966 #include <asm/mach/map.h>
3967 @@ -683,7 +685,46 @@ void free_initmem(void)
3968 {
3969 #ifdef CONFIG_HAVE_TCM
3970 extern char __tcm_start, __tcm_end;
3971 +#endif
3972
3973 +#ifdef CONFIG_PAX_KERNEXEC
3974 + unsigned long addr;
3975 + pgd_t *pgd;
3976 + pud_t *pud;
3977 + pmd_t *pmd;
3978 + int cpu_arch = cpu_architecture();
3979 + unsigned int cr = get_cr();
3980 +
3981 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3982 + /* make pages tables, etc before .text NX */
3983 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3984 + pgd = pgd_offset_k(addr);
3985 + pud = pud_offset(pgd, addr);
3986 + pmd = pmd_offset(pud, addr);
3987 + __section_update(pmd, addr, PMD_SECT_XN);
3988 + }
3989 + /* make init NX */
3990 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3991 + pgd = pgd_offset_k(addr);
3992 + pud = pud_offset(pgd, addr);
3993 + pmd = pmd_offset(pud, addr);
3994 + __section_update(pmd, addr, PMD_SECT_XN);
3995 + }
3996 + /* make kernel code/rodata RX */
3997 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3998 + pgd = pgd_offset_k(addr);
3999 + pud = pud_offset(pgd, addr);
4000 + pmd = pmd_offset(pud, addr);
4001 +#ifdef CONFIG_ARM_LPAE
4002 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4003 +#else
4004 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4005 +#endif
4006 + }
4007 + }
4008 +#endif
4009 +
4010 +#ifdef CONFIG_HAVE_TCM
4011 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4012 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4013 #endif
4014 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4015 index f123d6e..04bf569 100644
4016 --- a/arch/arm/mm/ioremap.c
4017 +++ b/arch/arm/mm/ioremap.c
4018 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4019 unsigned int mtype;
4020
4021 if (cached)
4022 - mtype = MT_MEMORY;
4023 + mtype = MT_MEMORY_RX;
4024 else
4025 - mtype = MT_MEMORY_NONCACHED;
4026 + mtype = MT_MEMORY_NONCACHED_RX;
4027
4028 return __arm_ioremap_caller(phys_addr, size, mtype,
4029 __builtin_return_address(0));
4030 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4031 index 0c63562..7128a90 100644
4032 --- a/arch/arm/mm/mmap.c
4033 +++ b/arch/arm/mm/mmap.c
4034 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4035 struct vm_area_struct *vma;
4036 int do_align = 0;
4037 int aliasing = cache_is_vipt_aliasing();
4038 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4039 struct vm_unmapped_area_info info;
4040
4041 /*
4042 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4043 if (len > TASK_SIZE)
4044 return -ENOMEM;
4045
4046 +#ifdef CONFIG_PAX_RANDMMAP
4047 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4048 +#endif
4049 +
4050 if (addr) {
4051 if (do_align)
4052 addr = COLOUR_ALIGN(addr, pgoff);
4053 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4054 addr = PAGE_ALIGN(addr);
4055
4056 vma = find_vma(mm, addr);
4057 - if (TASK_SIZE - len >= addr &&
4058 - (!vma || addr + len <= vma->vm_start))
4059 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4060 return addr;
4061 }
4062
4063 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4064 info.high_limit = TASK_SIZE;
4065 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4066 info.align_offset = pgoff << PAGE_SHIFT;
4067 + info.threadstack_offset = offset;
4068 return vm_unmapped_area(&info);
4069 }
4070
4071 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4072 unsigned long addr = addr0;
4073 int do_align = 0;
4074 int aliasing = cache_is_vipt_aliasing();
4075 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4076 struct vm_unmapped_area_info info;
4077
4078 /*
4079 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4080 return addr;
4081 }
4082
4083 +#ifdef CONFIG_PAX_RANDMMAP
4084 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4085 +#endif
4086 +
4087 /* requesting a specific address */
4088 if (addr) {
4089 if (do_align)
4090 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4091 else
4092 addr = PAGE_ALIGN(addr);
4093 vma = find_vma(mm, addr);
4094 - if (TASK_SIZE - len >= addr &&
4095 - (!vma || addr + len <= vma->vm_start))
4096 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4097 return addr;
4098 }
4099
4100 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4101 info.high_limit = mm->mmap_base;
4102 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4103 info.align_offset = pgoff << PAGE_SHIFT;
4104 + info.threadstack_offset = offset;
4105 addr = vm_unmapped_area(&info);
4106
4107 /*
4108 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4109 {
4110 unsigned long random_factor = 0UL;
4111
4112 +#ifdef CONFIG_PAX_RANDMMAP
4113 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4114 +#endif
4115 +
4116 /* 8 bits of randomness in 20 address space bits */
4117 if ((current->flags & PF_RANDOMIZE) &&
4118 !(current->personality & ADDR_NO_RANDOMIZE))
4119 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4120
4121 if (mmap_is_legacy()) {
4122 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4123 +
4124 +#ifdef CONFIG_PAX_RANDMMAP
4125 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4126 + mm->mmap_base += mm->delta_mmap;
4127 +#endif
4128 +
4129 mm->get_unmapped_area = arch_get_unmapped_area;
4130 } else {
4131 mm->mmap_base = mmap_base(random_factor);
4132 +
4133 +#ifdef CONFIG_PAX_RANDMMAP
4134 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4135 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4136 +#endif
4137 +
4138 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4139 }
4140 }
4141 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4142 index 53cdbd3..670f177 100644
4143 --- a/arch/arm/mm/mmu.c
4144 +++ b/arch/arm/mm/mmu.c
4145 @@ -36,6 +36,22 @@
4146 #include "mm.h"
4147 #include "tcm.h"
4148
4149 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4150 +void modify_domain(unsigned int dom, unsigned int type)
4151 +{
4152 + struct thread_info *thread = current_thread_info();
4153 + unsigned int domain = thread->cpu_domain;
4154 + /*
4155 + * DOMAIN_MANAGER might be defined to some other value,
4156 + * use the arch-defined constant
4157 + */
4158 + domain &= ~domain_val(dom, 3);
4159 + thread->cpu_domain = domain | domain_val(dom, type);
4160 + set_domain(thread->cpu_domain);
4161 +}
4162 +EXPORT_SYMBOL(modify_domain);
4163 +#endif
4164 +
4165 /*
4166 * empty_zero_page is a special page that is used for
4167 * zero-initialized data and COW.
4168 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4169
4170 #endif /* ifdef CONFIG_CPU_CP15 / else */
4171
4172 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4173 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4174 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4175
4176 -static struct mem_type mem_types[] = {
4177 +#ifdef CONFIG_PAX_KERNEXEC
4178 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4179 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4180 +#else
4181 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4182 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4183 +#endif
4184 +
4185 +static struct mem_type mem_types[] __read_only = {
4186 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4187 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4188 L_PTE_SHARED,
4189 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4190 [MT_UNCACHED] = {
4191 .prot_pte = PROT_PTE_DEVICE,
4192 .prot_l1 = PMD_TYPE_TABLE,
4193 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4194 + .prot_sect = PROT_SECT_DEVICE,
4195 .domain = DOMAIN_IO,
4196 },
4197 [MT_CACHECLEAN] = {
4198 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4199 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4200 .domain = DOMAIN_KERNEL,
4201 },
4202 #ifndef CONFIG_ARM_LPAE
4203 [MT_MINICLEAN] = {
4204 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4205 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4206 .domain = DOMAIN_KERNEL,
4207 },
4208 #endif
4209 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4210 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4211 L_PTE_RDONLY,
4212 .prot_l1 = PMD_TYPE_TABLE,
4213 - .domain = DOMAIN_USER,
4214 + .domain = DOMAIN_VECTORS,
4215 },
4216 [MT_HIGH_VECTORS] = {
4217 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4218 L_PTE_USER | L_PTE_RDONLY,
4219 .prot_l1 = PMD_TYPE_TABLE,
4220 - .domain = DOMAIN_USER,
4221 + .domain = DOMAIN_VECTORS,
4222 },
4223 - [MT_MEMORY] = {
4224 + [MT_MEMORY_RWX] = {
4225 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4226 .prot_l1 = PMD_TYPE_TABLE,
4227 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4228 .domain = DOMAIN_KERNEL,
4229 },
4230 + [MT_MEMORY_RW] = {
4231 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4232 + .prot_l1 = PMD_TYPE_TABLE,
4233 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4234 + .domain = DOMAIN_KERNEL,
4235 + },
4236 + [MT_MEMORY_RX] = {
4237 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4238 + .prot_l1 = PMD_TYPE_TABLE,
4239 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4240 + .domain = DOMAIN_KERNEL,
4241 + },
4242 [MT_ROM] = {
4243 - .prot_sect = PMD_TYPE_SECT,
4244 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4245 .domain = DOMAIN_KERNEL,
4246 },
4247 - [MT_MEMORY_NONCACHED] = {
4248 + [MT_MEMORY_NONCACHED_RW] = {
4249 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4250 L_PTE_MT_BUFFERABLE,
4251 .prot_l1 = PMD_TYPE_TABLE,
4252 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4253 .domain = DOMAIN_KERNEL,
4254 },
4255 + [MT_MEMORY_NONCACHED_RX] = {
4256 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4257 + L_PTE_MT_BUFFERABLE,
4258 + .prot_l1 = PMD_TYPE_TABLE,
4259 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4260 + .domain = DOMAIN_KERNEL,
4261 + },
4262 [MT_MEMORY_DTCM] = {
4263 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4264 - L_PTE_XN,
4265 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4266 .prot_l1 = PMD_TYPE_TABLE,
4267 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4268 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4269 .domain = DOMAIN_KERNEL,
4270 },
4271 [MT_MEMORY_ITCM] = {
4272 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4273 },
4274 [MT_MEMORY_SO] = {
4275 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4276 - L_PTE_MT_UNCACHED | L_PTE_XN,
4277 + L_PTE_MT_UNCACHED,
4278 .prot_l1 = PMD_TYPE_TABLE,
4279 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4280 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4281 + PMD_SECT_UNCACHED,
4282 .domain = DOMAIN_KERNEL,
4283 },
4284 [MT_MEMORY_DMA_READY] = {
4285 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4286 * to prevent speculative instruction fetches.
4287 */
4288 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4289 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4290 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4291 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4292 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4293 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4294 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4295 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4296 +
4297 + /* Mark other regions on ARMv6+ as execute-never */
4298 +
4299 +#ifdef CONFIG_PAX_KERNEXEC
4300 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4301 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4302 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4303 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4304 +#ifndef CONFIG_ARM_LPAE
4305 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4306 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4307 +#endif
4308 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4309 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4310 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4311 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4312 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4313 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4314 +#endif
4315 +
4316 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4317 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4318 }
4319 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4320 /*
4321 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4322 * from SVC mode and no access from userspace.
4323 */
4324 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4325 +#ifdef CONFIG_PAX_KERNEXEC
4326 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4327 +#endif
4328 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4329 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4330 #endif
4331 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4332 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4333 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4334 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4335 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4336 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4337 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4338 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4339 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4340 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4341 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4342 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4343 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4344 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4345 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4346 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4347 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4348 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4349 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4350 }
4351 }
4352
4353 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4354 if (cpu_arch >= CPU_ARCH_ARMv6) {
4355 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4356 /* Non-cacheable Normal is XCB = 001 */
4357 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4358 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4359 + PMD_SECT_BUFFERED;
4360 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4361 PMD_SECT_BUFFERED;
4362 } else {
4363 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4364 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4365 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4366 + PMD_SECT_TEX(1);
4367 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4368 PMD_SECT_TEX(1);
4369 }
4370 } else {
4371 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4372 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4373 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4374 }
4375
4376 #ifdef CONFIG_ARM_LPAE
4377 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4378 vecs_pgprot |= PTE_EXT_AF;
4379 #endif
4380
4381 + user_pgprot |= __supported_pte_mask;
4382 +
4383 for (i = 0; i < 16; i++) {
4384 pteval_t v = pgprot_val(protection_map[i]);
4385 protection_map[i] = __pgprot(v | user_pgprot);
4386 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4387
4388 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4389 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4390 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4391 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4392 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4393 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4394 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4395 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4396 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4397 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4398 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4399 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4400 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4401 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4402 mem_types[MT_ROM].prot_sect |= cp->pmd;
4403
4404 switch (cp->pmd) {
4405 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4406 * called function. This means you can't use any function or debugging
4407 * method which may touch any device, otherwise the kernel _will_ crash.
4408 */
4409 +
4410 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4411 +
4412 static void __init devicemaps_init(struct machine_desc *mdesc)
4413 {
4414 struct map_desc map;
4415 unsigned long addr;
4416 - void *vectors;
4417
4418 - /*
4419 - * Allocate the vector page early.
4420 - */
4421 - vectors = early_alloc(PAGE_SIZE * 2);
4422 -
4423 - early_trap_init(vectors);
4424 + early_trap_init(&vectors);
4425
4426 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4427 pmd_clear(pmd_off_k(addr));
4428 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4429 * location (0xffff0000). If we aren't using high-vectors, also
4430 * create a mapping at the low-vectors virtual address.
4431 */
4432 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4433 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4434 map.virtual = 0xffff0000;
4435 map.length = PAGE_SIZE;
4436 #ifdef CONFIG_KUSER_HELPERS
4437 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4438 map.pfn = __phys_to_pfn(start);
4439 map.virtual = __phys_to_virt(start);
4440 map.length = end - start;
4441 - map.type = MT_MEMORY;
4442
4443 +#ifdef CONFIG_PAX_KERNEXEC
4444 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4445 + struct map_desc kernel;
4446 + struct map_desc initmap;
4447 +
4448 + /* when freeing initmem we will make this RW */
4449 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4450 + initmap.virtual = (unsigned long)__init_begin;
4451 + initmap.length = _sdata - __init_begin;
4452 + initmap.type = MT_MEMORY_RWX;
4453 + create_mapping(&initmap);
4454 +
4455 + /* when freeing initmem we will make this RX */
4456 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4457 + kernel.virtual = (unsigned long)_stext;
4458 + kernel.length = __init_begin - _stext;
4459 + kernel.type = MT_MEMORY_RWX;
4460 + create_mapping(&kernel);
4461 +
4462 + if (map.virtual < (unsigned long)_stext) {
4463 + map.length = (unsigned long)_stext - map.virtual;
4464 + map.type = MT_MEMORY_RWX;
4465 + create_mapping(&map);
4466 + }
4467 +
4468 + map.pfn = __phys_to_pfn(__pa(_sdata));
4469 + map.virtual = (unsigned long)_sdata;
4470 + map.length = end - __pa(_sdata);
4471 + }
4472 +#endif
4473 +
4474 + map.type = MT_MEMORY_RW;
4475 create_mapping(&map);
4476 }
4477 }
4478 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4479 index a5bc92d..0bb4730 100644
4480 --- a/arch/arm/plat-omap/sram.c
4481 +++ b/arch/arm/plat-omap/sram.c
4482 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4483 * Looks like we need to preserve some bootloader code at the
4484 * beginning of SRAM for jumping to flash for reboot to work...
4485 */
4486 + pax_open_kernel();
4487 memset_io(omap_sram_base + omap_sram_skip, 0,
4488 omap_sram_size - omap_sram_skip);
4489 + pax_close_kernel();
4490 }
4491 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4492 index ce6d763..cfea917 100644
4493 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4494 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4495 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4496 int (*started)(unsigned ch);
4497 int (*flush)(unsigned ch);
4498 int (*stop)(unsigned ch);
4499 -};
4500 +} __no_const;
4501
4502 extern void *samsung_dmadev_get_ops(void);
4503 extern void *s3c_dma_get_ops(void);
4504 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4505 index c3a58a1..78fbf54 100644
4506 --- a/arch/avr32/include/asm/cache.h
4507 +++ b/arch/avr32/include/asm/cache.h
4508 @@ -1,8 +1,10 @@
4509 #ifndef __ASM_AVR32_CACHE_H
4510 #define __ASM_AVR32_CACHE_H
4511
4512 +#include <linux/const.h>
4513 +
4514 #define L1_CACHE_SHIFT 5
4515 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4516 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4517
4518 /*
4519 * Memory returned by kmalloc() may be used for DMA, so we must make
4520 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4521 index d232888..87c8df1 100644
4522 --- a/arch/avr32/include/asm/elf.h
4523 +++ b/arch/avr32/include/asm/elf.h
4524 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4525 the loader. We need to make sure that it is out of the way of the program
4526 that it will "exec", and that there is sufficient room for the brk. */
4527
4528 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4529 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4530
4531 +#ifdef CONFIG_PAX_ASLR
4532 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4533 +
4534 +#define PAX_DELTA_MMAP_LEN 15
4535 +#define PAX_DELTA_STACK_LEN 15
4536 +#endif
4537
4538 /* This yields a mask that user programs can use to figure out what
4539 instruction set this CPU supports. This could be done in user space,
4540 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4541 index 479330b..53717a8 100644
4542 --- a/arch/avr32/include/asm/kmap_types.h
4543 +++ b/arch/avr32/include/asm/kmap_types.h
4544 @@ -2,9 +2,9 @@
4545 #define __ASM_AVR32_KMAP_TYPES_H
4546
4547 #ifdef CONFIG_DEBUG_HIGHMEM
4548 -# define KM_TYPE_NR 29
4549 +# define KM_TYPE_NR 30
4550 #else
4551 -# define KM_TYPE_NR 14
4552 +# define KM_TYPE_NR 15
4553 #endif
4554
4555 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4556 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4557 index b2f2d2d..d1c85cb 100644
4558 --- a/arch/avr32/mm/fault.c
4559 +++ b/arch/avr32/mm/fault.c
4560 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4561
4562 int exception_trace = 1;
4563
4564 +#ifdef CONFIG_PAX_PAGEEXEC
4565 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4566 +{
4567 + unsigned long i;
4568 +
4569 + printk(KERN_ERR "PAX: bytes at PC: ");
4570 + for (i = 0; i < 20; i++) {
4571 + unsigned char c;
4572 + if (get_user(c, (unsigned char *)pc+i))
4573 + printk(KERN_CONT "???????? ");
4574 + else
4575 + printk(KERN_CONT "%02x ", c);
4576 + }
4577 + printk("\n");
4578 +}
4579 +#endif
4580 +
4581 /*
4582 * This routine handles page faults. It determines the address and the
4583 * problem, and then passes it off to one of the appropriate routines.
4584 @@ -174,6 +191,16 @@ bad_area:
4585 up_read(&mm->mmap_sem);
4586
4587 if (user_mode(regs)) {
4588 +
4589 +#ifdef CONFIG_PAX_PAGEEXEC
4590 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4591 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4592 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4593 + do_group_exit(SIGKILL);
4594 + }
4595 + }
4596 +#endif
4597 +
4598 if (exception_trace && printk_ratelimit())
4599 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4600 "sp %08lx ecr %lu\n",
4601 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4602 index 568885a..f8008df 100644
4603 --- a/arch/blackfin/include/asm/cache.h
4604 +++ b/arch/blackfin/include/asm/cache.h
4605 @@ -7,6 +7,7 @@
4606 #ifndef __ARCH_BLACKFIN_CACHE_H
4607 #define __ARCH_BLACKFIN_CACHE_H
4608
4609 +#include <linux/const.h>
4610 #include <linux/linkage.h> /* for asmlinkage */
4611
4612 /*
4613 @@ -14,7 +15,7 @@
4614 * Blackfin loads 32 bytes for cache
4615 */
4616 #define L1_CACHE_SHIFT 5
4617 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4618 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4619 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4620
4621 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4622 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4623 index aea2718..3639a60 100644
4624 --- a/arch/cris/include/arch-v10/arch/cache.h
4625 +++ b/arch/cris/include/arch-v10/arch/cache.h
4626 @@ -1,8 +1,9 @@
4627 #ifndef _ASM_ARCH_CACHE_H
4628 #define _ASM_ARCH_CACHE_H
4629
4630 +#include <linux/const.h>
4631 /* Etrax 100LX have 32-byte cache-lines. */
4632 -#define L1_CACHE_BYTES 32
4633 #define L1_CACHE_SHIFT 5
4634 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4635
4636 #endif /* _ASM_ARCH_CACHE_H */
4637 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4638 index 7caf25d..ee65ac5 100644
4639 --- a/arch/cris/include/arch-v32/arch/cache.h
4640 +++ b/arch/cris/include/arch-v32/arch/cache.h
4641 @@ -1,11 +1,12 @@
4642 #ifndef _ASM_CRIS_ARCH_CACHE_H
4643 #define _ASM_CRIS_ARCH_CACHE_H
4644
4645 +#include <linux/const.h>
4646 #include <arch/hwregs/dma.h>
4647
4648 /* A cache-line is 32 bytes. */
4649 -#define L1_CACHE_BYTES 32
4650 #define L1_CACHE_SHIFT 5
4651 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4652
4653 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4654
4655 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4656 index b86329d..6709906 100644
4657 --- a/arch/frv/include/asm/atomic.h
4658 +++ b/arch/frv/include/asm/atomic.h
4659 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4660 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4661 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4662
4663 +#define atomic64_read_unchecked(v) atomic64_read(v)
4664 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4665 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4666 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4667 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4668 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4669 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4670 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4671 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4672 +
4673 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4674 {
4675 int c, old;
4676 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4677 index 2797163..c2a401d 100644
4678 --- a/arch/frv/include/asm/cache.h
4679 +++ b/arch/frv/include/asm/cache.h
4680 @@ -12,10 +12,11 @@
4681 #ifndef __ASM_CACHE_H
4682 #define __ASM_CACHE_H
4683
4684 +#include <linux/const.h>
4685
4686 /* bytes per L1 cache line */
4687 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4688 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4689 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4690
4691 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4692 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4693 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4694 index 43901f2..0d8b865 100644
4695 --- a/arch/frv/include/asm/kmap_types.h
4696 +++ b/arch/frv/include/asm/kmap_types.h
4697 @@ -2,6 +2,6 @@
4698 #ifndef _ASM_KMAP_TYPES_H
4699 #define _ASM_KMAP_TYPES_H
4700
4701 -#define KM_TYPE_NR 17
4702 +#define KM_TYPE_NR 18
4703
4704 #endif
4705 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4706 index 836f147..4cf23f5 100644
4707 --- a/arch/frv/mm/elf-fdpic.c
4708 +++ b/arch/frv/mm/elf-fdpic.c
4709 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4710 {
4711 struct vm_area_struct *vma;
4712 struct vm_unmapped_area_info info;
4713 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4714
4715 if (len > TASK_SIZE)
4716 return -ENOMEM;
4717 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4718 if (addr) {
4719 addr = PAGE_ALIGN(addr);
4720 vma = find_vma(current->mm, addr);
4721 - if (TASK_SIZE - len >= addr &&
4722 - (!vma || addr + len <= vma->vm_start))
4723 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4724 goto success;
4725 }
4726
4727 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4728 info.high_limit = (current->mm->start_stack - 0x00200000);
4729 info.align_mask = 0;
4730 info.align_offset = 0;
4731 + info.threadstack_offset = offset;
4732 addr = vm_unmapped_area(&info);
4733 if (!(addr & ~PAGE_MASK))
4734 goto success;
4735 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4736 index f4ca594..adc72fd6 100644
4737 --- a/arch/hexagon/include/asm/cache.h
4738 +++ b/arch/hexagon/include/asm/cache.h
4739 @@ -21,9 +21,11 @@
4740 #ifndef __ASM_CACHE_H
4741 #define __ASM_CACHE_H
4742
4743 +#include <linux/const.h>
4744 +
4745 /* Bytes per L1 cache line */
4746 -#define L1_CACHE_SHIFT (5)
4747 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4748 +#define L1_CACHE_SHIFT 5
4749 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4750
4751 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4752 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4753 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4754 index 6e6fe18..a6ae668 100644
4755 --- a/arch/ia64/include/asm/atomic.h
4756 +++ b/arch/ia64/include/asm/atomic.h
4757 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4758 #define atomic64_inc(v) atomic64_add(1, (v))
4759 #define atomic64_dec(v) atomic64_sub(1, (v))
4760
4761 +#define atomic64_read_unchecked(v) atomic64_read(v)
4762 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4763 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4764 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4765 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4766 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4767 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4768 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4769 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4770 +
4771 /* Atomic operations are already serializing */
4772 #define smp_mb__before_atomic_dec() barrier()
4773 #define smp_mb__after_atomic_dec() barrier()
4774 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4775 index 988254a..e1ee885 100644
4776 --- a/arch/ia64/include/asm/cache.h
4777 +++ b/arch/ia64/include/asm/cache.h
4778 @@ -1,6 +1,7 @@
4779 #ifndef _ASM_IA64_CACHE_H
4780 #define _ASM_IA64_CACHE_H
4781
4782 +#include <linux/const.h>
4783
4784 /*
4785 * Copyright (C) 1998-2000 Hewlett-Packard Co
4786 @@ -9,7 +10,7 @@
4787
4788 /* Bytes per L1 (data) cache line. */
4789 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4790 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4791 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4792
4793 #ifdef CONFIG_SMP
4794 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4795 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4796 index 5a83c5c..4d7f553 100644
4797 --- a/arch/ia64/include/asm/elf.h
4798 +++ b/arch/ia64/include/asm/elf.h
4799 @@ -42,6 +42,13 @@
4800 */
4801 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4802
4803 +#ifdef CONFIG_PAX_ASLR
4804 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4805 +
4806 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4807 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4808 +#endif
4809 +
4810 #define PT_IA_64_UNWIND 0x70000001
4811
4812 /* IA-64 relocations: */
4813 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4814 index 96a8d92..617a1cf 100644
4815 --- a/arch/ia64/include/asm/pgalloc.h
4816 +++ b/arch/ia64/include/asm/pgalloc.h
4817 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4818 pgd_val(*pgd_entry) = __pa(pud);
4819 }
4820
4821 +static inline void
4822 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4823 +{
4824 + pgd_populate(mm, pgd_entry, pud);
4825 +}
4826 +
4827 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4828 {
4829 return quicklist_alloc(0, GFP_KERNEL, NULL);
4830 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4831 pud_val(*pud_entry) = __pa(pmd);
4832 }
4833
4834 +static inline void
4835 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4836 +{
4837 + pud_populate(mm, pud_entry, pmd);
4838 +}
4839 +
4840 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4841 {
4842 return quicklist_alloc(0, GFP_KERNEL, NULL);
4843 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4844 index 7935115..c0eca6a 100644
4845 --- a/arch/ia64/include/asm/pgtable.h
4846 +++ b/arch/ia64/include/asm/pgtable.h
4847 @@ -12,7 +12,7 @@
4848 * David Mosberger-Tang <davidm@hpl.hp.com>
4849 */
4850
4851 -
4852 +#include <linux/const.h>
4853 #include <asm/mman.h>
4854 #include <asm/page.h>
4855 #include <asm/processor.h>
4856 @@ -142,6 +142,17 @@
4857 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4858 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4859 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4860 +
4861 +#ifdef CONFIG_PAX_PAGEEXEC
4862 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4863 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4864 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4865 +#else
4866 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4867 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4868 +# define PAGE_COPY_NOEXEC PAGE_COPY
4869 +#endif
4870 +
4871 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4872 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4873 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4874 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4875 index 54ff557..70c88b7 100644
4876 --- a/arch/ia64/include/asm/spinlock.h
4877 +++ b/arch/ia64/include/asm/spinlock.h
4878 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4879 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4880
4881 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4882 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4883 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4884 }
4885
4886 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4887 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4888 index 449c8c0..18965fb 100644
4889 --- a/arch/ia64/include/asm/uaccess.h
4890 +++ b/arch/ia64/include/asm/uaccess.h
4891 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4892 static inline unsigned long
4893 __copy_to_user (void __user *to, const void *from, unsigned long count)
4894 {
4895 + if (count > INT_MAX)
4896 + return count;
4897 +
4898 + if (!__builtin_constant_p(count))
4899 + check_object_size(from, count, true);
4900 +
4901 return __copy_user(to, (__force void __user *) from, count);
4902 }
4903
4904 static inline unsigned long
4905 __copy_from_user (void *to, const void __user *from, unsigned long count)
4906 {
4907 + if (count > INT_MAX)
4908 + return count;
4909 +
4910 + if (!__builtin_constant_p(count))
4911 + check_object_size(to, count, false);
4912 +
4913 return __copy_user((__force void __user *) to, from, count);
4914 }
4915
4916 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4917 ({ \
4918 void __user *__cu_to = (to); \
4919 const void *__cu_from = (from); \
4920 - long __cu_len = (n); \
4921 + unsigned long __cu_len = (n); \
4922 \
4923 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4924 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4925 + if (!__builtin_constant_p(n)) \
4926 + check_object_size(__cu_from, __cu_len, true); \
4927 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4928 + } \
4929 __cu_len; \
4930 })
4931
4932 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4933 ({ \
4934 void *__cu_to = (to); \
4935 const void __user *__cu_from = (from); \
4936 - long __cu_len = (n); \
4937 + unsigned long __cu_len = (n); \
4938 \
4939 __chk_user_ptr(__cu_from); \
4940 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4941 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4942 + if (!__builtin_constant_p(n)) \
4943 + check_object_size(__cu_to, __cu_len, false); \
4944 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4945 + } \
4946 __cu_len; \
4947 })
4948
4949 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4950 index 24603be..948052d 100644
4951 --- a/arch/ia64/kernel/module.c
4952 +++ b/arch/ia64/kernel/module.c
4953 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4954 void
4955 module_free (struct module *mod, void *module_region)
4956 {
4957 - if (mod && mod->arch.init_unw_table &&
4958 - module_region == mod->module_init) {
4959 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4960 unw_remove_unwind_table(mod->arch.init_unw_table);
4961 mod->arch.init_unw_table = NULL;
4962 }
4963 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4964 }
4965
4966 static inline int
4967 +in_init_rx (const struct module *mod, uint64_t addr)
4968 +{
4969 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4970 +}
4971 +
4972 +static inline int
4973 +in_init_rw (const struct module *mod, uint64_t addr)
4974 +{
4975 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4976 +}
4977 +
4978 +static inline int
4979 in_init (const struct module *mod, uint64_t addr)
4980 {
4981 - return addr - (uint64_t) mod->module_init < mod->init_size;
4982 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4983 +}
4984 +
4985 +static inline int
4986 +in_core_rx (const struct module *mod, uint64_t addr)
4987 +{
4988 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4989 +}
4990 +
4991 +static inline int
4992 +in_core_rw (const struct module *mod, uint64_t addr)
4993 +{
4994 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4995 }
4996
4997 static inline int
4998 in_core (const struct module *mod, uint64_t addr)
4999 {
5000 - return addr - (uint64_t) mod->module_core < mod->core_size;
5001 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5002 }
5003
5004 static inline int
5005 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5006 break;
5007
5008 case RV_BDREL:
5009 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5010 + if (in_init_rx(mod, val))
5011 + val -= (uint64_t) mod->module_init_rx;
5012 + else if (in_init_rw(mod, val))
5013 + val -= (uint64_t) mod->module_init_rw;
5014 + else if (in_core_rx(mod, val))
5015 + val -= (uint64_t) mod->module_core_rx;
5016 + else if (in_core_rw(mod, val))
5017 + val -= (uint64_t) mod->module_core_rw;
5018 break;
5019
5020 case RV_LTV:
5021 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5022 * addresses have been selected...
5023 */
5024 uint64_t gp;
5025 - if (mod->core_size > MAX_LTOFF)
5026 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5027 /*
5028 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5029 * at the end of the module.
5030 */
5031 - gp = mod->core_size - MAX_LTOFF / 2;
5032 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5033 else
5034 - gp = mod->core_size / 2;
5035 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5036 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5037 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5038 mod->arch.gp = gp;
5039 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5040 }
5041 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5042 index ab33328..f39506c 100644
5043 --- a/arch/ia64/kernel/palinfo.c
5044 +++ b/arch/ia64/kernel/palinfo.c
5045 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5046 return NOTIFY_OK;
5047 }
5048
5049 -static struct notifier_block __refdata palinfo_cpu_notifier =
5050 +static struct notifier_block palinfo_cpu_notifier =
5051 {
5052 .notifier_call = palinfo_cpu_callback,
5053 .priority = 0,
5054 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5055 index 41e33f8..65180b2 100644
5056 --- a/arch/ia64/kernel/sys_ia64.c
5057 +++ b/arch/ia64/kernel/sys_ia64.c
5058 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5059 unsigned long align_mask = 0;
5060 struct mm_struct *mm = current->mm;
5061 struct vm_unmapped_area_info info;
5062 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5063
5064 if (len > RGN_MAP_LIMIT)
5065 return -ENOMEM;
5066 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5067 if (REGION_NUMBER(addr) == RGN_HPAGE)
5068 addr = 0;
5069 #endif
5070 +
5071 +#ifdef CONFIG_PAX_RANDMMAP
5072 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5073 + addr = mm->free_area_cache;
5074 + else
5075 +#endif
5076 +
5077 if (!addr)
5078 addr = TASK_UNMAPPED_BASE;
5079
5080 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5081 info.high_limit = TASK_SIZE;
5082 info.align_mask = align_mask;
5083 info.align_offset = 0;
5084 + info.threadstack_offset = offset;
5085 return vm_unmapped_area(&info);
5086 }
5087
5088 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5089 index 0ccb28f..8992469 100644
5090 --- a/arch/ia64/kernel/vmlinux.lds.S
5091 +++ b/arch/ia64/kernel/vmlinux.lds.S
5092 @@ -198,7 +198,7 @@ SECTIONS {
5093 /* Per-cpu data: */
5094 . = ALIGN(PERCPU_PAGE_SIZE);
5095 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5096 - __phys_per_cpu_start = __per_cpu_load;
5097 + __phys_per_cpu_start = per_cpu_load;
5098 /*
5099 * ensure percpu data fits
5100 * into percpu page size
5101 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5102 index 6cf0341..d352594 100644
5103 --- a/arch/ia64/mm/fault.c
5104 +++ b/arch/ia64/mm/fault.c
5105 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5106 return pte_present(pte);
5107 }
5108
5109 +#ifdef CONFIG_PAX_PAGEEXEC
5110 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5111 +{
5112 + unsigned long i;
5113 +
5114 + printk(KERN_ERR "PAX: bytes at PC: ");
5115 + for (i = 0; i < 8; i++) {
5116 + unsigned int c;
5117 + if (get_user(c, (unsigned int *)pc+i))
5118 + printk(KERN_CONT "???????? ");
5119 + else
5120 + printk(KERN_CONT "%08x ", c);
5121 + }
5122 + printk("\n");
5123 +}
5124 +#endif
5125 +
5126 # define VM_READ_BIT 0
5127 # define VM_WRITE_BIT 1
5128 # define VM_EXEC_BIT 2
5129 @@ -149,8 +166,21 @@ retry:
5130 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5131 goto bad_area;
5132
5133 - if ((vma->vm_flags & mask) != mask)
5134 + if ((vma->vm_flags & mask) != mask) {
5135 +
5136 +#ifdef CONFIG_PAX_PAGEEXEC
5137 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5138 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5139 + goto bad_area;
5140 +
5141 + up_read(&mm->mmap_sem);
5142 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5143 + do_group_exit(SIGKILL);
5144 + }
5145 +#endif
5146 +
5147 goto bad_area;
5148 + }
5149
5150 /*
5151 * If for any reason at all we couldn't handle the fault, make
5152 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5153 index 76069c1..c2aa816 100644
5154 --- a/arch/ia64/mm/hugetlbpage.c
5155 +++ b/arch/ia64/mm/hugetlbpage.c
5156 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5157 unsigned long pgoff, unsigned long flags)
5158 {
5159 struct vm_unmapped_area_info info;
5160 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5161
5162 if (len > RGN_MAP_LIMIT)
5163 return -ENOMEM;
5164 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5165 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5166 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5167 info.align_offset = 0;
5168 + info.threadstack_offset = offset;
5169 return vm_unmapped_area(&info);
5170 }
5171
5172 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5173 index b6f7f43..c04320d 100644
5174 --- a/arch/ia64/mm/init.c
5175 +++ b/arch/ia64/mm/init.c
5176 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5177 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5178 vma->vm_end = vma->vm_start + PAGE_SIZE;
5179 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5180 +
5181 +#ifdef CONFIG_PAX_PAGEEXEC
5182 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5183 + vma->vm_flags &= ~VM_EXEC;
5184 +
5185 +#ifdef CONFIG_PAX_MPROTECT
5186 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5187 + vma->vm_flags &= ~VM_MAYEXEC;
5188 +#endif
5189 +
5190 + }
5191 +#endif
5192 +
5193 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5194 down_write(&current->mm->mmap_sem);
5195 if (insert_vm_struct(current->mm, vma)) {
5196 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5197 index 40b3ee9..8c2c112 100644
5198 --- a/arch/m32r/include/asm/cache.h
5199 +++ b/arch/m32r/include/asm/cache.h
5200 @@ -1,8 +1,10 @@
5201 #ifndef _ASM_M32R_CACHE_H
5202 #define _ASM_M32R_CACHE_H
5203
5204 +#include <linux/const.h>
5205 +
5206 /* L1 cache line size */
5207 #define L1_CACHE_SHIFT 4
5208 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5209 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5210
5211 #endif /* _ASM_M32R_CACHE_H */
5212 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5213 index 82abd15..d95ae5d 100644
5214 --- a/arch/m32r/lib/usercopy.c
5215 +++ b/arch/m32r/lib/usercopy.c
5216 @@ -14,6 +14,9 @@
5217 unsigned long
5218 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5219 {
5220 + if ((long)n < 0)
5221 + return n;
5222 +
5223 prefetch(from);
5224 if (access_ok(VERIFY_WRITE, to, n))
5225 __copy_user(to,from,n);
5226 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5227 unsigned long
5228 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5229 {
5230 + if ((long)n < 0)
5231 + return n;
5232 +
5233 prefetchw(to);
5234 if (access_ok(VERIFY_READ, from, n))
5235 __copy_user_zeroing(to,from,n);
5236 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5237 index 0395c51..5f26031 100644
5238 --- a/arch/m68k/include/asm/cache.h
5239 +++ b/arch/m68k/include/asm/cache.h
5240 @@ -4,9 +4,11 @@
5241 #ifndef __ARCH_M68K_CACHE_H
5242 #define __ARCH_M68K_CACHE_H
5243
5244 +#include <linux/const.h>
5245 +
5246 /* bytes per L1 cache line */
5247 #define L1_CACHE_SHIFT 4
5248 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5249 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5250
5251 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5252
5253 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5254 index 3c52fa6..11b2ad8 100644
5255 --- a/arch/metag/mm/hugetlbpage.c
5256 +++ b/arch/metag/mm/hugetlbpage.c
5257 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5258 info.high_limit = TASK_SIZE;
5259 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5260 info.align_offset = 0;
5261 + info.threadstack_offset = 0;
5262 return vm_unmapped_area(&info);
5263 }
5264
5265 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5266 index 4efe96a..60e8699 100644
5267 --- a/arch/microblaze/include/asm/cache.h
5268 +++ b/arch/microblaze/include/asm/cache.h
5269 @@ -13,11 +13,12 @@
5270 #ifndef _ASM_MICROBLAZE_CACHE_H
5271 #define _ASM_MICROBLAZE_CACHE_H
5272
5273 +#include <linux/const.h>
5274 #include <asm/registers.h>
5275
5276 #define L1_CACHE_SHIFT 5
5277 /* word-granular cache in microblaze */
5278 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5279 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5280
5281 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5282
5283 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5284 index 08b6079..8b554d2 100644
5285 --- a/arch/mips/include/asm/atomic.h
5286 +++ b/arch/mips/include/asm/atomic.h
5287 @@ -21,15 +21,39 @@
5288 #include <asm/cmpxchg.h>
5289 #include <asm/war.h>
5290
5291 +#ifdef CONFIG_GENERIC_ATOMIC64
5292 +#include <asm-generic/atomic64.h>
5293 +#endif
5294 +
5295 #define ATOMIC_INIT(i) { (i) }
5296
5297 +#ifdef CONFIG_64BIT
5298 +#define _ASM_EXTABLE(from, to) \
5299 +" .section __ex_table,\"a\"\n" \
5300 +" .dword " #from ", " #to"\n" \
5301 +" .previous\n"
5302 +#else
5303 +#define _ASM_EXTABLE(from, to) \
5304 +" .section __ex_table,\"a\"\n" \
5305 +" .word " #from ", " #to"\n" \
5306 +" .previous\n"
5307 +#endif
5308 +
5309 /*
5310 * atomic_read - read atomic variable
5311 * @v: pointer of type atomic_t
5312 *
5313 * Atomically reads the value of @v.
5314 */
5315 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5316 +static inline int atomic_read(const atomic_t *v)
5317 +{
5318 + return (*(volatile const int *) &v->counter);
5319 +}
5320 +
5321 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5322 +{
5323 + return (*(volatile const int *) &v->counter);
5324 +}
5325
5326 /*
5327 * atomic_set - set atomic variable
5328 @@ -38,7 +62,15 @@
5329 *
5330 * Atomically sets the value of @v to @i.
5331 */
5332 -#define atomic_set(v, i) ((v)->counter = (i))
5333 +static inline void atomic_set(atomic_t *v, int i)
5334 +{
5335 + v->counter = i;
5336 +}
5337 +
5338 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5339 +{
5340 + v->counter = i;
5341 +}
5342
5343 /*
5344 * atomic_add - add integer to atomic variable
5345 @@ -47,7 +79,67 @@
5346 *
5347 * Atomically adds @i to @v.
5348 */
5349 -static __inline__ void atomic_add(int i, atomic_t * v)
5350 +static __inline__ void atomic_add(int i, atomic_t *v)
5351 +{
5352 + int temp;
5353 +
5354 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5355 + __asm__ __volatile__(
5356 + " .set mips3 \n"
5357 + "1: ll %0, %1 # atomic_add \n"
5358 +#ifdef CONFIG_PAX_REFCOUNT
5359 + /* Exception on overflow. */
5360 + "2: add %0, %2 \n"
5361 +#else
5362 + " addu %0, %2 \n"
5363 +#endif
5364 + " sc %0, %1 \n"
5365 + " beqzl %0, 1b \n"
5366 +#ifdef CONFIG_PAX_REFCOUNT
5367 + "3: \n"
5368 + _ASM_EXTABLE(2b, 3b)
5369 +#endif
5370 + " .set mips0 \n"
5371 + : "=&r" (temp), "+m" (v->counter)
5372 + : "Ir" (i));
5373 + } else if (kernel_uses_llsc) {
5374 + __asm__ __volatile__(
5375 + " .set mips3 \n"
5376 + "1: ll %0, %1 # atomic_add \n"
5377 +#ifdef CONFIG_PAX_REFCOUNT
5378 + /* Exception on overflow. */
5379 + "2: add %0, %2 \n"
5380 +#else
5381 + " addu %0, %2 \n"
5382 +#endif
5383 + " sc %0, %1 \n"
5384 + " beqz %0, 1b \n"
5385 +#ifdef CONFIG_PAX_REFCOUNT
5386 + "3: \n"
5387 + _ASM_EXTABLE(2b, 3b)
5388 +#endif
5389 + " .set mips0 \n"
5390 + : "=&r" (temp), "+m" (v->counter)
5391 + : "Ir" (i));
5392 + } else {
5393 + unsigned long flags;
5394 +
5395 + raw_local_irq_save(flags);
5396 + __asm__ __volatile__(
5397 +#ifdef CONFIG_PAX_REFCOUNT
5398 + /* Exception on overflow. */
5399 + "1: add %0, %1 \n"
5400 + "2: \n"
5401 + _ASM_EXTABLE(1b, 2b)
5402 +#else
5403 + " addu %0, %1 \n"
5404 +#endif
5405 + : "+r" (v->counter) : "Ir" (i));
5406 + raw_local_irq_restore(flags);
5407 + }
5408 +}
5409 +
5410 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5411 {
5412 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5413 int temp;
5414 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5415 *
5416 * Atomically subtracts @i from @v.
5417 */
5418 -static __inline__ void atomic_sub(int i, atomic_t * v)
5419 +static __inline__ void atomic_sub(int i, atomic_t *v)
5420 +{
5421 + int temp;
5422 +
5423 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5424 + __asm__ __volatile__(
5425 + " .set mips3 \n"
5426 + "1: ll %0, %1 # atomic64_sub \n"
5427 +#ifdef CONFIG_PAX_REFCOUNT
5428 + /* Exception on overflow. */
5429 + "2: sub %0, %2 \n"
5430 +#else
5431 + " subu %0, %2 \n"
5432 +#endif
5433 + " sc %0, %1 \n"
5434 + " beqzl %0, 1b \n"
5435 +#ifdef CONFIG_PAX_REFCOUNT
5436 + "3: \n"
5437 + _ASM_EXTABLE(2b, 3b)
5438 +#endif
5439 + " .set mips0 \n"
5440 + : "=&r" (temp), "+m" (v->counter)
5441 + : "Ir" (i));
5442 + } else if (kernel_uses_llsc) {
5443 + __asm__ __volatile__(
5444 + " .set mips3 \n"
5445 + "1: ll %0, %1 # atomic64_sub \n"
5446 +#ifdef CONFIG_PAX_REFCOUNT
5447 + /* Exception on overflow. */
5448 + "2: sub %0, %2 \n"
5449 +#else
5450 + " subu %0, %2 \n"
5451 +#endif
5452 + " sc %0, %1 \n"
5453 + " beqz %0, 1b \n"
5454 +#ifdef CONFIG_PAX_REFCOUNT
5455 + "3: \n"
5456 + _ASM_EXTABLE(2b, 3b)
5457 +#endif
5458 + " .set mips0 \n"
5459 + : "=&r" (temp), "+m" (v->counter)
5460 + : "Ir" (i));
5461 + } else {
5462 + unsigned long flags;
5463 +
5464 + raw_local_irq_save(flags);
5465 + __asm__ __volatile__(
5466 +#ifdef CONFIG_PAX_REFCOUNT
5467 + /* Exception on overflow. */
5468 + "1: sub %0, %1 \n"
5469 + "2: \n"
5470 + _ASM_EXTABLE(1b, 2b)
5471 +#else
5472 + " subu %0, %1 \n"
5473 +#endif
5474 + : "+r" (v->counter) : "Ir" (i));
5475 + raw_local_irq_restore(flags);
5476 + }
5477 +}
5478 +
5479 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5480 {
5481 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5482 int temp;
5483 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5484 /*
5485 * Same as above, but return the result value
5486 */
5487 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5488 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5489 +{
5490 + int result;
5491 + int temp;
5492 +
5493 + smp_mb__before_llsc();
5494 +
5495 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5496 + __asm__ __volatile__(
5497 + " .set mips3 \n"
5498 + "1: ll %1, %2 # atomic_add_return \n"
5499 +#ifdef CONFIG_PAX_REFCOUNT
5500 + "2: add %0, %1, %3 \n"
5501 +#else
5502 + " addu %0, %1, %3 \n"
5503 +#endif
5504 + " sc %0, %2 \n"
5505 + " beqzl %0, 1b \n"
5506 +#ifdef CONFIG_PAX_REFCOUNT
5507 + " b 4f \n"
5508 + " .set noreorder \n"
5509 + "3: b 5f \n"
5510 + " move %0, %1 \n"
5511 + " .set reorder \n"
5512 + _ASM_EXTABLE(2b, 3b)
5513 +#endif
5514 + "4: addu %0, %1, %3 \n"
5515 +#ifdef CONFIG_PAX_REFCOUNT
5516 + "5: \n"
5517 +#endif
5518 + " .set mips0 \n"
5519 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5520 + : "Ir" (i));
5521 + } else if (kernel_uses_llsc) {
5522 + __asm__ __volatile__(
5523 + " .set mips3 \n"
5524 + "1: ll %1, %2 # atomic_add_return \n"
5525 +#ifdef CONFIG_PAX_REFCOUNT
5526 + "2: add %0, %1, %3 \n"
5527 +#else
5528 + " addu %0, %1, %3 \n"
5529 +#endif
5530 + " sc %0, %2 \n"
5531 + " bnez %0, 4f \n"
5532 + " b 1b \n"
5533 +#ifdef CONFIG_PAX_REFCOUNT
5534 + " .set noreorder \n"
5535 + "3: b 5f \n"
5536 + " move %0, %1 \n"
5537 + " .set reorder \n"
5538 + _ASM_EXTABLE(2b, 3b)
5539 +#endif
5540 + "4: addu %0, %1, %3 \n"
5541 +#ifdef CONFIG_PAX_REFCOUNT
5542 + "5: \n"
5543 +#endif
5544 + " .set mips0 \n"
5545 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5546 + : "Ir" (i));
5547 + } else {
5548 + unsigned long flags;
5549 +
5550 + raw_local_irq_save(flags);
5551 + __asm__ __volatile__(
5552 + " lw %0, %1 \n"
5553 +#ifdef CONFIG_PAX_REFCOUNT
5554 + /* Exception on overflow. */
5555 + "1: add %0, %2 \n"
5556 +#else
5557 + " addu %0, %2 \n"
5558 +#endif
5559 + " sw %0, %1 \n"
5560 +#ifdef CONFIG_PAX_REFCOUNT
5561 + /* Note: Dest reg is not modified on overflow */
5562 + "2: \n"
5563 + _ASM_EXTABLE(1b, 2b)
5564 +#endif
5565 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5566 + raw_local_irq_restore(flags);
5567 + }
5568 +
5569 + smp_llsc_mb();
5570 +
5571 + return result;
5572 +}
5573 +
5574 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5575 {
5576 int result;
5577
5578 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5579 return result;
5580 }
5581
5582 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5583 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5584 +{
5585 + int result;
5586 + int temp;
5587 +
5588 + smp_mb__before_llsc();
5589 +
5590 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5591 + __asm__ __volatile__(
5592 + " .set mips3 \n"
5593 + "1: ll %1, %2 # atomic_sub_return \n"
5594 +#ifdef CONFIG_PAX_REFCOUNT
5595 + "2: sub %0, %1, %3 \n"
5596 +#else
5597 + " subu %0, %1, %3 \n"
5598 +#endif
5599 + " sc %0, %2 \n"
5600 + " beqzl %0, 1b \n"
5601 +#ifdef CONFIG_PAX_REFCOUNT
5602 + " b 4f \n"
5603 + " .set noreorder \n"
5604 + "3: b 5f \n"
5605 + " move %0, %1 \n"
5606 + " .set reorder \n"
5607 + _ASM_EXTABLE(2b, 3b)
5608 +#endif
5609 + "4: subu %0, %1, %3 \n"
5610 +#ifdef CONFIG_PAX_REFCOUNT
5611 + "5: \n"
5612 +#endif
5613 + " .set mips0 \n"
5614 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5615 + : "Ir" (i), "m" (v->counter)
5616 + : "memory");
5617 + } else if (kernel_uses_llsc) {
5618 + __asm__ __volatile__(
5619 + " .set mips3 \n"
5620 + "1: ll %1, %2 # atomic_sub_return \n"
5621 +#ifdef CONFIG_PAX_REFCOUNT
5622 + "2: sub %0, %1, %3 \n"
5623 +#else
5624 + " subu %0, %1, %3 \n"
5625 +#endif
5626 + " sc %0, %2 \n"
5627 + " bnez %0, 4f \n"
5628 + " b 1b \n"
5629 +#ifdef CONFIG_PAX_REFCOUNT
5630 + " .set noreorder \n"
5631 + "3: b 5f \n"
5632 + " move %0, %1 \n"
5633 + " .set reorder \n"
5634 + _ASM_EXTABLE(2b, 3b)
5635 +#endif
5636 + "4: subu %0, %1, %3 \n"
5637 +#ifdef CONFIG_PAX_REFCOUNT
5638 + "5: \n"
5639 +#endif
5640 + " .set mips0 \n"
5641 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5642 + : "Ir" (i));
5643 + } else {
5644 + unsigned long flags;
5645 +
5646 + raw_local_irq_save(flags);
5647 + __asm__ __volatile__(
5648 + " lw %0, %1 \n"
5649 +#ifdef CONFIG_PAX_REFCOUNT
5650 + /* Exception on overflow. */
5651 + "1: sub %0, %2 \n"
5652 +#else
5653 + " subu %0, %2 \n"
5654 +#endif
5655 + " sw %0, %1 \n"
5656 +#ifdef CONFIG_PAX_REFCOUNT
5657 + /* Note: Dest reg is not modified on overflow */
5658 + "2: \n"
5659 + _ASM_EXTABLE(1b, 2b)
5660 +#endif
5661 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5662 + raw_local_irq_restore(flags);
5663 + }
5664 +
5665 + smp_llsc_mb();
5666 +
5667 + return result;
5668 +}
5669 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5670 {
5671 int result;
5672
5673 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5674 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5675 * The function returns the old value of @v minus @i.
5676 */
5677 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5678 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5679 {
5680 int result;
5681
5682 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5683 return result;
5684 }
5685
5686 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5687 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5688 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5689 +{
5690 + return cmpxchg(&v->counter, old, new);
5691 +}
5692 +
5693 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5694 + int new)
5695 +{
5696 + return cmpxchg(&(v->counter), old, new);
5697 +}
5698 +
5699 +static inline int atomic_xchg(atomic_t *v, int new)
5700 +{
5701 + return xchg(&v->counter, new);
5702 +}
5703 +
5704 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5705 +{
5706 + return xchg(&(v->counter), new);
5707 +}
5708
5709 /**
5710 * __atomic_add_unless - add unless the number is a given value
5711 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5712
5713 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5714 #define atomic_inc_return(v) atomic_add_return(1, (v))
5715 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5716 +{
5717 + return atomic_add_return_unchecked(1, v);
5718 +}
5719
5720 /*
5721 * atomic_sub_and_test - subtract value from variable and test result
5722 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5723 * other cases.
5724 */
5725 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5726 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5727 +{
5728 + return atomic_add_return_unchecked(1, v) == 0;
5729 +}
5730
5731 /*
5732 * atomic_dec_and_test - decrement by 1 and test
5733 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5734 * Atomically increments @v by 1.
5735 */
5736 #define atomic_inc(v) atomic_add(1, (v))
5737 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5738 +{
5739 + atomic_add_unchecked(1, v);
5740 +}
5741
5742 /*
5743 * atomic_dec - decrement and test
5744 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5745 * Atomically decrements @v by 1.
5746 */
5747 #define atomic_dec(v) atomic_sub(1, (v))
5748 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5749 +{
5750 + atomic_sub_unchecked(1, v);
5751 +}
5752
5753 /*
5754 * atomic_add_negative - add and test if negative
5755 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5756 * @v: pointer of type atomic64_t
5757 *
5758 */
5759 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5760 +static inline long atomic64_read(const atomic64_t *v)
5761 +{
5762 + return (*(volatile const long *) &v->counter);
5763 +}
5764 +
5765 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5766 +{
5767 + return (*(volatile const long *) &v->counter);
5768 +}
5769
5770 /*
5771 * atomic64_set - set atomic variable
5772 * @v: pointer of type atomic64_t
5773 * @i: required value
5774 */
5775 -#define atomic64_set(v, i) ((v)->counter = (i))
5776 +static inline void atomic64_set(atomic64_t *v, long i)
5777 +{
5778 + v->counter = i;
5779 +}
5780 +
5781 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5782 +{
5783 + v->counter = i;
5784 +}
5785
5786 /*
5787 * atomic64_add - add integer to atomic variable
5788 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5789 *
5790 * Atomically adds @i to @v.
5791 */
5792 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5793 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5794 +{
5795 + long temp;
5796 +
5797 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5798 + __asm__ __volatile__(
5799 + " .set mips3 \n"
5800 + "1: lld %0, %1 # atomic64_add \n"
5801 +#ifdef CONFIG_PAX_REFCOUNT
5802 + /* Exception on overflow. */
5803 + "2: dadd %0, %2 \n"
5804 +#else
5805 + " daddu %0, %2 \n"
5806 +#endif
5807 + " scd %0, %1 \n"
5808 + " beqzl %0, 1b \n"
5809 +#ifdef CONFIG_PAX_REFCOUNT
5810 + "3: \n"
5811 + _ASM_EXTABLE(2b, 3b)
5812 +#endif
5813 + " .set mips0 \n"
5814 + : "=&r" (temp), "+m" (v->counter)
5815 + : "Ir" (i));
5816 + } else if (kernel_uses_llsc) {
5817 + __asm__ __volatile__(
5818 + " .set mips3 \n"
5819 + "1: lld %0, %1 # atomic64_add \n"
5820 +#ifdef CONFIG_PAX_REFCOUNT
5821 + /* Exception on overflow. */
5822 + "2: dadd %0, %2 \n"
5823 +#else
5824 + " daddu %0, %2 \n"
5825 +#endif
5826 + " scd %0, %1 \n"
5827 + " beqz %0, 1b \n"
5828 +#ifdef CONFIG_PAX_REFCOUNT
5829 + "3: \n"
5830 + _ASM_EXTABLE(2b, 3b)
5831 +#endif
5832 + " .set mips0 \n"
5833 + : "=&r" (temp), "+m" (v->counter)
5834 + : "Ir" (i));
5835 + } else {
5836 + unsigned long flags;
5837 +
5838 + raw_local_irq_save(flags);
5839 + __asm__ __volatile__(
5840 +#ifdef CONFIG_PAX_REFCOUNT
5841 + /* Exception on overflow. */
5842 + "1: dadd %0, %1 \n"
5843 + "2: \n"
5844 + _ASM_EXTABLE(1b, 2b)
5845 +#else
5846 + " daddu %0, %1 \n"
5847 +#endif
5848 + : "+r" (v->counter) : "Ir" (i));
5849 + raw_local_irq_restore(flags);
5850 + }
5851 +}
5852 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5853 {
5854 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5855 long temp;
5856 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5857 *
5858 * Atomically subtracts @i from @v.
5859 */
5860 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5861 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5862 +{
5863 + long temp;
5864 +
5865 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5866 + __asm__ __volatile__(
5867 + " .set mips3 \n"
5868 + "1: lld %0, %1 # atomic64_sub \n"
5869 +#ifdef CONFIG_PAX_REFCOUNT
5870 + /* Exception on overflow. */
5871 + "2: dsub %0, %2 \n"
5872 +#else
5873 + " dsubu %0, %2 \n"
5874 +#endif
5875 + " scd %0, %1 \n"
5876 + " beqzl %0, 1b \n"
5877 +#ifdef CONFIG_PAX_REFCOUNT
5878 + "3: \n"
5879 + _ASM_EXTABLE(2b, 3b)
5880 +#endif
5881 + " .set mips0 \n"
5882 + : "=&r" (temp), "+m" (v->counter)
5883 + : "Ir" (i));
5884 + } else if (kernel_uses_llsc) {
5885 + __asm__ __volatile__(
5886 + " .set mips3 \n"
5887 + "1: lld %0, %1 # atomic64_sub \n"
5888 +#ifdef CONFIG_PAX_REFCOUNT
5889 + /* Exception on overflow. */
5890 + "2: dsub %0, %2 \n"
5891 +#else
5892 + " dsubu %0, %2 \n"
5893 +#endif
5894 + " scd %0, %1 \n"
5895 + " beqz %0, 1b \n"
5896 +#ifdef CONFIG_PAX_REFCOUNT
5897 + "3: \n"
5898 + _ASM_EXTABLE(2b, 3b)
5899 +#endif
5900 + " .set mips0 \n"
5901 + : "=&r" (temp), "+m" (v->counter)
5902 + : "Ir" (i));
5903 + } else {
5904 + unsigned long flags;
5905 +
5906 + raw_local_irq_save(flags);
5907 + __asm__ __volatile__(
5908 +#ifdef CONFIG_PAX_REFCOUNT
5909 + /* Exception on overflow. */
5910 + "1: dsub %0, %1 \n"
5911 + "2: \n"
5912 + _ASM_EXTABLE(1b, 2b)
5913 +#else
5914 + " dsubu %0, %1 \n"
5915 +#endif
5916 + : "+r" (v->counter) : "Ir" (i));
5917 + raw_local_irq_restore(flags);
5918 + }
5919 +}
5920 +
5921 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5922 {
5923 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5924 long temp;
5925 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
5926 /*
5927 * Same as above, but return the result value
5928 */
5929 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
5930 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
5931 +{
5932 + long result;
5933 + long temp;
5934 +
5935 + smp_mb__before_llsc();
5936 +
5937 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5938 + __asm__ __volatile__(
5939 + " .set mips3 \n"
5940 + "1: lld %1, %2 # atomic64_add_return \n"
5941 +#ifdef CONFIG_PAX_REFCOUNT
5942 + "2: dadd %0, %1, %3 \n"
5943 +#else
5944 + " daddu %0, %1, %3 \n"
5945 +#endif
5946 + " scd %0, %2 \n"
5947 + " beqzl %0, 1b \n"
5948 +#ifdef CONFIG_PAX_REFCOUNT
5949 + " b 4f \n"
5950 + " .set noreorder \n"
5951 + "3: b 5f \n"
5952 + " move %0, %1 \n"
5953 + " .set reorder \n"
5954 + _ASM_EXTABLE(2b, 3b)
5955 +#endif
5956 + "4: daddu %0, %1, %3 \n"
5957 +#ifdef CONFIG_PAX_REFCOUNT
5958 + "5: \n"
5959 +#endif
5960 + " .set mips0 \n"
5961 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5962 + : "Ir" (i));
5963 + } else if (kernel_uses_llsc) {
5964 + __asm__ __volatile__(
5965 + " .set mips3 \n"
5966 + "1: lld %1, %2 # atomic64_add_return \n"
5967 +#ifdef CONFIG_PAX_REFCOUNT
5968 + "2: dadd %0, %1, %3 \n"
5969 +#else
5970 + " daddu %0, %1, %3 \n"
5971 +#endif
5972 + " scd %0, %2 \n"
5973 + " bnez %0, 4f \n"
5974 + " b 1b \n"
5975 +#ifdef CONFIG_PAX_REFCOUNT
5976 + " .set noreorder \n"
5977 + "3: b 5f \n"
5978 + " move %0, %1 \n"
5979 + " .set reorder \n"
5980 + _ASM_EXTABLE(2b, 3b)
5981 +#endif
5982 + "4: daddu %0, %1, %3 \n"
5983 +#ifdef CONFIG_PAX_REFCOUNT
5984 + "5: \n"
5985 +#endif
5986 + " .set mips0 \n"
5987 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5988 + : "Ir" (i), "m" (v->counter)
5989 + : "memory");
5990 + } else {
5991 + unsigned long flags;
5992 +
5993 + raw_local_irq_save(flags);
5994 + __asm__ __volatile__(
5995 + " ld %0, %1 \n"
5996 +#ifdef CONFIG_PAX_REFCOUNT
5997 + /* Exception on overflow. */
5998 + "1: dadd %0, %2 \n"
5999 +#else
6000 + " daddu %0, %2 \n"
6001 +#endif
6002 + " sd %0, %1 \n"
6003 +#ifdef CONFIG_PAX_REFCOUNT
6004 + /* Note: Dest reg is not modified on overflow */
6005 + "2: \n"
6006 + _ASM_EXTABLE(1b, 2b)
6007 +#endif
6008 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6009 + raw_local_irq_restore(flags);
6010 + }
6011 +
6012 + smp_llsc_mb();
6013 +
6014 + return result;
6015 +}
6016 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6017 {
6018 long result;
6019
6020 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6021 return result;
6022 }
6023
6024 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6025 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6026 +{
6027 + long result;
6028 + long temp;
6029 +
6030 + smp_mb__before_llsc();
6031 +
6032 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6033 + long temp;
6034 +
6035 + __asm__ __volatile__(
6036 + " .set mips3 \n"
6037 + "1: lld %1, %2 # atomic64_sub_return \n"
6038 +#ifdef CONFIG_PAX_REFCOUNT
6039 + "2: dsub %0, %1, %3 \n"
6040 +#else
6041 + " dsubu %0, %1, %3 \n"
6042 +#endif
6043 + " scd %0, %2 \n"
6044 + " beqzl %0, 1b \n"
6045 +#ifdef CONFIG_PAX_REFCOUNT
6046 + " b 4f \n"
6047 + " .set noreorder \n"
6048 + "3: b 5f \n"
6049 + " move %0, %1 \n"
6050 + " .set reorder \n"
6051 + _ASM_EXTABLE(2b, 3b)
6052 +#endif
6053 + "4: dsubu %0, %1, %3 \n"
6054 +#ifdef CONFIG_PAX_REFCOUNT
6055 + "5: \n"
6056 +#endif
6057 + " .set mips0 \n"
6058 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6059 + : "Ir" (i), "m" (v->counter)
6060 + : "memory");
6061 + } else if (kernel_uses_llsc) {
6062 + __asm__ __volatile__(
6063 + " .set mips3 \n"
6064 + "1: lld %1, %2 # atomic64_sub_return \n"
6065 +#ifdef CONFIG_PAX_REFCOUNT
6066 + "2: dsub %0, %1, %3 \n"
6067 +#else
6068 + " dsubu %0, %1, %3 \n"
6069 +#endif
6070 + " scd %0, %2 \n"
6071 + " bnez %0, 4f \n"
6072 + " b 1b \n"
6073 +#ifdef CONFIG_PAX_REFCOUNT
6074 + " .set noreorder \n"
6075 + "3: b 5f \n"
6076 + " move %0, %1 \n"
6077 + " .set reorder \n"
6078 + _ASM_EXTABLE(2b, 3b)
6079 +#endif
6080 + "4: dsubu %0, %1, %3 \n"
6081 +#ifdef CONFIG_PAX_REFCOUNT
6082 + "5: \n"
6083 +#endif
6084 + " .set mips0 \n"
6085 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6086 + : "Ir" (i), "m" (v->counter)
6087 + : "memory");
6088 + } else {
6089 + unsigned long flags;
6090 +
6091 + raw_local_irq_save(flags);
6092 + __asm__ __volatile__(
6093 + " ld %0, %1 \n"
6094 +#ifdef CONFIG_PAX_REFCOUNT
6095 + /* Exception on overflow. */
6096 + "1: dsub %0, %2 \n"
6097 +#else
6098 + " dsubu %0, %2 \n"
6099 +#endif
6100 + " sd %0, %1 \n"
6101 +#ifdef CONFIG_PAX_REFCOUNT
6102 + /* Note: Dest reg is not modified on overflow */
6103 + "2: \n"
6104 + _ASM_EXTABLE(1b, 2b)
6105 +#endif
6106 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6107 + raw_local_irq_restore(flags);
6108 + }
6109 +
6110 + smp_llsc_mb();
6111 +
6112 + return result;
6113 +}
6114 +
6115 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6116 {
6117 long result;
6118
6119 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6120 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6121 * The function returns the old value of @v minus @i.
6122 */
6123 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6124 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6125 {
6126 long result;
6127
6128 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6129 return result;
6130 }
6131
6132 -#define atomic64_cmpxchg(v, o, n) \
6133 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6134 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6135 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6136 +{
6137 + return cmpxchg(&v->counter, old, new);
6138 +}
6139 +
6140 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6141 + long new)
6142 +{
6143 + return cmpxchg(&(v->counter), old, new);
6144 +}
6145 +
6146 +static inline long atomic64_xchg(atomic64_t *v, long new)
6147 +{
6148 + return xchg(&v->counter, new);
6149 +}
6150 +
6151 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6152 +{
6153 + return xchg(&(v->counter), new);
6154 +}
6155
6156 /**
6157 * atomic64_add_unless - add unless the number is a given value
6158 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6159
6160 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6161 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6162 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6163
6164 /*
6165 * atomic64_sub_and_test - subtract value from variable and test result
6166 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6167 * other cases.
6168 */
6169 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6170 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6171
6172 /*
6173 * atomic64_dec_and_test - decrement by 1 and test
6174 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6175 * Atomically increments @v by 1.
6176 */
6177 #define atomic64_inc(v) atomic64_add(1, (v))
6178 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6179
6180 /*
6181 * atomic64_dec - decrement and test
6182 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6183 * Atomically decrements @v by 1.
6184 */
6185 #define atomic64_dec(v) atomic64_sub(1, (v))
6186 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6187
6188 /*
6189 * atomic64_add_negative - add and test if negative
6190 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6191 index b4db69f..8f3b093 100644
6192 --- a/arch/mips/include/asm/cache.h
6193 +++ b/arch/mips/include/asm/cache.h
6194 @@ -9,10 +9,11 @@
6195 #ifndef _ASM_CACHE_H
6196 #define _ASM_CACHE_H
6197
6198 +#include <linux/const.h>
6199 #include <kmalloc.h>
6200
6201 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6202 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6203 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6204
6205 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6206 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6207 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6208 index cf3ae24..238d22f 100644
6209 --- a/arch/mips/include/asm/elf.h
6210 +++ b/arch/mips/include/asm/elf.h
6211 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6212 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6213 #endif
6214
6215 +#ifdef CONFIG_PAX_ASLR
6216 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6217 +
6218 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6219 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6220 +#endif
6221 +
6222 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6223 struct linux_binprm;
6224 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6225 int uses_interp);
6226
6227 -struct mm_struct;
6228 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6229 -#define arch_randomize_brk arch_randomize_brk
6230 -
6231 #endif /* _ASM_ELF_H */
6232 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6233 index c1f6afa..38cc6e9 100644
6234 --- a/arch/mips/include/asm/exec.h
6235 +++ b/arch/mips/include/asm/exec.h
6236 @@ -12,6 +12,6 @@
6237 #ifndef _ASM_EXEC_H
6238 #define _ASM_EXEC_H
6239
6240 -extern unsigned long arch_align_stack(unsigned long sp);
6241 +#define arch_align_stack(x) ((x) & ~0xfUL)
6242
6243 #endif /* _ASM_EXEC_H */
6244 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6245 index d44622c..64990d2 100644
6246 --- a/arch/mips/include/asm/local.h
6247 +++ b/arch/mips/include/asm/local.h
6248 @@ -12,15 +12,25 @@ typedef struct
6249 atomic_long_t a;
6250 } local_t;
6251
6252 +typedef struct {
6253 + atomic_long_unchecked_t a;
6254 +} local_unchecked_t;
6255 +
6256 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6257
6258 #define local_read(l) atomic_long_read(&(l)->a)
6259 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6260 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6261 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6262
6263 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6264 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6265 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6266 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6267 #define local_inc(l) atomic_long_inc(&(l)->a)
6268 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6269 #define local_dec(l) atomic_long_dec(&(l)->a)
6270 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6271
6272 /*
6273 * Same as above, but return the result value
6274 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6275 return result;
6276 }
6277
6278 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6279 +{
6280 + unsigned long result;
6281 +
6282 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6283 + unsigned long temp;
6284 +
6285 + __asm__ __volatile__(
6286 + " .set mips3 \n"
6287 + "1:" __LL "%1, %2 # local_add_return \n"
6288 + " addu %0, %1, %3 \n"
6289 + __SC "%0, %2 \n"
6290 + " beqzl %0, 1b \n"
6291 + " addu %0, %1, %3 \n"
6292 + " .set mips0 \n"
6293 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6294 + : "Ir" (i), "m" (l->a.counter)
6295 + : "memory");
6296 + } else if (kernel_uses_llsc) {
6297 + unsigned long temp;
6298 +
6299 + __asm__ __volatile__(
6300 + " .set mips3 \n"
6301 + "1:" __LL "%1, %2 # local_add_return \n"
6302 + " addu %0, %1, %3 \n"
6303 + __SC "%0, %2 \n"
6304 + " beqz %0, 1b \n"
6305 + " addu %0, %1, %3 \n"
6306 + " .set mips0 \n"
6307 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6308 + : "Ir" (i), "m" (l->a.counter)
6309 + : "memory");
6310 + } else {
6311 + unsigned long flags;
6312 +
6313 + local_irq_save(flags);
6314 + result = l->a.counter;
6315 + result += i;
6316 + l->a.counter = result;
6317 + local_irq_restore(flags);
6318 + }
6319 +
6320 + return result;
6321 +}
6322 +
6323 static __inline__ long local_sub_return(long i, local_t * l)
6324 {
6325 unsigned long result;
6326 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6327
6328 #define local_cmpxchg(l, o, n) \
6329 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6330 +#define local_cmpxchg_unchecked(l, o, n) \
6331 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6332 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6333
6334 /**
6335 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6336 index f6be474..12ad554 100644
6337 --- a/arch/mips/include/asm/page.h
6338 +++ b/arch/mips/include/asm/page.h
6339 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6340 #ifdef CONFIG_CPU_MIPS32
6341 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6342 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6343 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6344 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6345 #else
6346 typedef struct { unsigned long long pte; } pte_t;
6347 #define pte_val(x) ((x).pte)
6348 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6349 index 881d18b..cea38bc 100644
6350 --- a/arch/mips/include/asm/pgalloc.h
6351 +++ b/arch/mips/include/asm/pgalloc.h
6352 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6353 {
6354 set_pud(pud, __pud((unsigned long)pmd));
6355 }
6356 +
6357 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6358 +{
6359 + pud_populate(mm, pud, pmd);
6360 +}
6361 #endif
6362
6363 /*
6364 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6365 index 25da651..ae2a259 100644
6366 --- a/arch/mips/include/asm/smtc_proc.h
6367 +++ b/arch/mips/include/asm/smtc_proc.h
6368 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6369
6370 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6371
6372 -extern atomic_t smtc_fpu_recoveries;
6373 +extern atomic_unchecked_t smtc_fpu_recoveries;
6374
6375 #endif /* __ASM_SMTC_PROC_H */
6376 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6377 index 61215a3..213ee0e 100644
6378 --- a/arch/mips/include/asm/thread_info.h
6379 +++ b/arch/mips/include/asm/thread_info.h
6380 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6381 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6382 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6383 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6384 +/* li takes a 32bit immediate */
6385 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6386 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6387
6388 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6389 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6390 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6391 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6392 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6393 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6394
6395 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6396 - _TIF_SYSCALL_AUDIT)
6397 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6398
6399 /* work to do in syscall_trace_leave() */
6400 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6401 - _TIF_SYSCALL_AUDIT)
6402 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6403
6404 /* work to do on interrupt/exception return */
6405 #define _TIF_WORK_MASK \
6406 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6407 /* work to do on any return to u-space */
6408 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6409 - _TIF_WORK_SYSCALL_EXIT)
6410 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6411
6412 #endif /* __KERNEL__ */
6413
6414 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6415 index 1188e00..41cf144 100644
6416 --- a/arch/mips/kernel/binfmt_elfn32.c
6417 +++ b/arch/mips/kernel/binfmt_elfn32.c
6418 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6419 #undef ELF_ET_DYN_BASE
6420 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6421
6422 +#ifdef CONFIG_PAX_ASLR
6423 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6424 +
6425 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6426 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6427 +#endif
6428 +
6429 #include <asm/processor.h>
6430 #include <linux/module.h>
6431 #include <linux/elfcore.h>
6432 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6433 index 202e581..689ca79 100644
6434 --- a/arch/mips/kernel/binfmt_elfo32.c
6435 +++ b/arch/mips/kernel/binfmt_elfo32.c
6436 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6437 #undef ELF_ET_DYN_BASE
6438 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6439
6440 +#ifdef CONFIG_PAX_ASLR
6441 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6442 +
6443 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6444 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6445 +#endif
6446 +
6447 #include <asm/processor.h>
6448
6449 /*
6450 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6451 index d1fea7a..45602ea 100644
6452 --- a/arch/mips/kernel/irq.c
6453 +++ b/arch/mips/kernel/irq.c
6454 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6455 printk("unexpected IRQ # %d\n", irq);
6456 }
6457
6458 -atomic_t irq_err_count;
6459 +atomic_unchecked_t irq_err_count;
6460
6461 int arch_show_interrupts(struct seq_file *p, int prec)
6462 {
6463 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6464 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6465 return 0;
6466 }
6467
6468 asmlinkage void spurious_interrupt(void)
6469 {
6470 - atomic_inc(&irq_err_count);
6471 + atomic_inc_unchecked(&irq_err_count);
6472 }
6473
6474 void __init init_IRQ(void)
6475 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6476 index ddc7610..8c58f17 100644
6477 --- a/arch/mips/kernel/process.c
6478 +++ b/arch/mips/kernel/process.c
6479 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6480 out:
6481 return pc;
6482 }
6483 -
6484 -/*
6485 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6486 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6487 - */
6488 -unsigned long arch_align_stack(unsigned long sp)
6489 -{
6490 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6491 - sp -= get_random_int() & ~PAGE_MASK;
6492 -
6493 - return sp & ALMASK;
6494 -}
6495 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6496 index 8ae1ebe..1bcbf47 100644
6497 --- a/arch/mips/kernel/ptrace.c
6498 +++ b/arch/mips/kernel/ptrace.c
6499 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6500 return arch;
6501 }
6502
6503 +#ifdef CONFIG_GRKERNSEC_SETXID
6504 +extern void gr_delayed_cred_worker(void);
6505 +#endif
6506 +
6507 /*
6508 * Notification of system call entry/exit
6509 * - triggered by current->work.syscall_trace
6510 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6511 /* do the secure computing check first */
6512 secure_computing_strict(regs->regs[2]);
6513
6514 +#ifdef CONFIG_GRKERNSEC_SETXID
6515 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6516 + gr_delayed_cred_worker();
6517 +#endif
6518 +
6519 if (!(current->ptrace & PT_PTRACED))
6520 goto out;
6521
6522 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6523 index c10aa84..9ec2e60 100644
6524 --- a/arch/mips/kernel/smtc-proc.c
6525 +++ b/arch/mips/kernel/smtc-proc.c
6526 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6527
6528 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6529
6530 -atomic_t smtc_fpu_recoveries;
6531 +atomic_unchecked_t smtc_fpu_recoveries;
6532
6533 static int smtc_proc_show(struct seq_file *m, void *v)
6534 {
6535 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6536 for(i = 0; i < NR_CPUS; i++)
6537 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6538 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6539 - atomic_read(&smtc_fpu_recoveries));
6540 + atomic_read_unchecked(&smtc_fpu_recoveries));
6541 return 0;
6542 }
6543
6544 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6545 smtc_cpu_stats[i].selfipis = 0;
6546 }
6547
6548 - atomic_set(&smtc_fpu_recoveries, 0);
6549 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6550
6551 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6552 }
6553 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6554 index dfc1b91..11a2c07 100644
6555 --- a/arch/mips/kernel/smtc.c
6556 +++ b/arch/mips/kernel/smtc.c
6557 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6558 }
6559 smtc_ipi_qdump();
6560 printk("%d Recoveries of \"stolen\" FPU\n",
6561 - atomic_read(&smtc_fpu_recoveries));
6562 + atomic_read_unchecked(&smtc_fpu_recoveries));
6563 }
6564
6565
6566 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6567 index 84536bf..79caa4d 100644
6568 --- a/arch/mips/kernel/sync-r4k.c
6569 +++ b/arch/mips/kernel/sync-r4k.c
6570 @@ -21,8 +21,8 @@
6571 #include <asm/mipsregs.h>
6572
6573 static atomic_t count_start_flag = ATOMIC_INIT(0);
6574 -static atomic_t count_count_start = ATOMIC_INIT(0);
6575 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6576 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6577 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6578 static atomic_t count_reference = ATOMIC_INIT(0);
6579
6580 #define COUNTON 100
6581 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6582
6583 for (i = 0; i < NR_LOOPS; i++) {
6584 /* slaves loop on '!= 2' */
6585 - while (atomic_read(&count_count_start) != 1)
6586 + while (atomic_read_unchecked(&count_count_start) != 1)
6587 mb();
6588 - atomic_set(&count_count_stop, 0);
6589 + atomic_set_unchecked(&count_count_stop, 0);
6590 smp_wmb();
6591
6592 /* this lets the slaves write their count register */
6593 - atomic_inc(&count_count_start);
6594 + atomic_inc_unchecked(&count_count_start);
6595
6596 /*
6597 * Everyone initialises count in the last loop:
6598 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6599 /*
6600 * Wait for all slaves to leave the synchronization point:
6601 */
6602 - while (atomic_read(&count_count_stop) != 1)
6603 + while (atomic_read_unchecked(&count_count_stop) != 1)
6604 mb();
6605 - atomic_set(&count_count_start, 0);
6606 + atomic_set_unchecked(&count_count_start, 0);
6607 smp_wmb();
6608 - atomic_inc(&count_count_stop);
6609 + atomic_inc_unchecked(&count_count_stop);
6610 }
6611 /* Arrange for an interrupt in a short while */
6612 write_c0_compare(read_c0_count() + COUNTON);
6613 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6614 initcount = atomic_read(&count_reference);
6615
6616 for (i = 0; i < NR_LOOPS; i++) {
6617 - atomic_inc(&count_count_start);
6618 - while (atomic_read(&count_count_start) != 2)
6619 + atomic_inc_unchecked(&count_count_start);
6620 + while (atomic_read_unchecked(&count_count_start) != 2)
6621 mb();
6622
6623 /*
6624 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6625 if (i == NR_LOOPS-1)
6626 write_c0_count(initcount);
6627
6628 - atomic_inc(&count_count_stop);
6629 - while (atomic_read(&count_count_stop) != 2)
6630 + atomic_inc_unchecked(&count_count_stop);
6631 + while (atomic_read_unchecked(&count_count_stop) != 2)
6632 mb();
6633 }
6634 /* Arrange for an interrupt in a short while */
6635 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6636 index aec3408..74d79d3 100644
6637 --- a/arch/mips/kernel/traps.c
6638 +++ b/arch/mips/kernel/traps.c
6639 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6640 siginfo_t info;
6641
6642 prev_state = exception_enter();
6643 - die_if_kernel("Integer overflow", regs);
6644 + if (unlikely(!user_mode(regs))) {
6645 +
6646 +#ifdef CONFIG_PAX_REFCOUNT
6647 + if (fixup_exception(regs)) {
6648 + pax_report_refcount_overflow(regs);
6649 + exception_exit(prev_state);
6650 + return;
6651 + }
6652 +#endif
6653 +
6654 + die("Integer overflow", regs);
6655 + }
6656
6657 info.si_code = FPE_INTOVF;
6658 info.si_signo = SIGFPE;
6659 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6660 index 85df1cd..4f0a4de 100644
6661 --- a/arch/mips/mm/fault.c
6662 +++ b/arch/mips/mm/fault.c
6663 @@ -28,6 +28,23 @@
6664 #include <asm/highmem.h> /* For VMALLOC_END */
6665 #include <linux/kdebug.h>
6666
6667 +#ifdef CONFIG_PAX_PAGEEXEC
6668 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6669 +{
6670 + unsigned long i;
6671 +
6672 + printk(KERN_ERR "PAX: bytes at PC: ");
6673 + for (i = 0; i < 5; i++) {
6674 + unsigned int c;
6675 + if (get_user(c, (unsigned int *)pc+i))
6676 + printk(KERN_CONT "???????? ");
6677 + else
6678 + printk(KERN_CONT "%08x ", c);
6679 + }
6680 + printk("\n");
6681 +}
6682 +#endif
6683 +
6684 /*
6685 * This routine handles page faults. It determines the address,
6686 * and the problem, and then passes it off to one of the appropriate
6687 @@ -197,6 +214,14 @@ bad_area:
6688 bad_area_nosemaphore:
6689 /* User mode accesses just cause a SIGSEGV */
6690 if (user_mode(regs)) {
6691 +
6692 +#ifdef CONFIG_PAX_PAGEEXEC
6693 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6694 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6695 + do_group_exit(SIGKILL);
6696 + }
6697 +#endif
6698 +
6699 tsk->thread.cp0_badvaddr = address;
6700 tsk->thread.error_code = write;
6701 #if 0
6702 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6703 index f1baadd..8537544 100644
6704 --- a/arch/mips/mm/mmap.c
6705 +++ b/arch/mips/mm/mmap.c
6706 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6707 struct vm_area_struct *vma;
6708 unsigned long addr = addr0;
6709 int do_color_align;
6710 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6711 struct vm_unmapped_area_info info;
6712
6713 if (unlikely(len > TASK_SIZE))
6714 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6715 do_color_align = 1;
6716
6717 /* requesting a specific address */
6718 +
6719 +#ifdef CONFIG_PAX_RANDMMAP
6720 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6721 +#endif
6722 +
6723 if (addr) {
6724 if (do_color_align)
6725 addr = COLOUR_ALIGN(addr, pgoff);
6726 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6727 addr = PAGE_ALIGN(addr);
6728
6729 vma = find_vma(mm, addr);
6730 - if (TASK_SIZE - len >= addr &&
6731 - (!vma || addr + len <= vma->vm_start))
6732 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6733 return addr;
6734 }
6735
6736 info.length = len;
6737 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6738 info.align_offset = pgoff << PAGE_SHIFT;
6739 + info.threadstack_offset = offset;
6740
6741 if (dir == DOWN) {
6742 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6743 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6744 {
6745 unsigned long random_factor = 0UL;
6746
6747 +#ifdef CONFIG_PAX_RANDMMAP
6748 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6749 +#endif
6750 +
6751 if (current->flags & PF_RANDOMIZE) {
6752 random_factor = get_random_int();
6753 random_factor = random_factor << PAGE_SHIFT;
6754 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6755
6756 if (mmap_is_legacy()) {
6757 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6758 +
6759 +#ifdef CONFIG_PAX_RANDMMAP
6760 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6761 + mm->mmap_base += mm->delta_mmap;
6762 +#endif
6763 +
6764 mm->get_unmapped_area = arch_get_unmapped_area;
6765 } else {
6766 mm->mmap_base = mmap_base(random_factor);
6767 +
6768 +#ifdef CONFIG_PAX_RANDMMAP
6769 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6770 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6771 +#endif
6772 +
6773 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6774 }
6775 }
6776
6777 -static inline unsigned long brk_rnd(void)
6778 -{
6779 - unsigned long rnd = get_random_int();
6780 -
6781 - rnd = rnd << PAGE_SHIFT;
6782 - /* 8MB for 32bit, 256MB for 64bit */
6783 - if (TASK_IS_32BIT_ADDR)
6784 - rnd = rnd & 0x7ffffful;
6785 - else
6786 - rnd = rnd & 0xffffffful;
6787 -
6788 - return rnd;
6789 -}
6790 -
6791 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6792 -{
6793 - unsigned long base = mm->brk;
6794 - unsigned long ret;
6795 -
6796 - ret = PAGE_ALIGN(base + brk_rnd());
6797 -
6798 - if (ret < mm->brk)
6799 - return mm->brk;
6800 -
6801 - return ret;
6802 -}
6803 -
6804 int __virt_addr_valid(const volatile void *kaddr)
6805 {
6806 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6807 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6808 index a2358b4..7cead4f 100644
6809 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6810 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6811 @@ -187,9 +187,9 @@ void
6812 cont_nmi_dump(void)
6813 {
6814 #ifndef REAL_NMI_SIGNAL
6815 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6816 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6817
6818 - atomic_inc(&nmied_cpus);
6819 + atomic_inc_unchecked(&nmied_cpus);
6820 #endif
6821 /*
6822 * Only allow 1 cpu to proceed
6823 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6824 udelay(10000);
6825 }
6826 #else
6827 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6828 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6829 #endif
6830
6831 /*
6832 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6833 index 967d144..db12197 100644
6834 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6835 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6836 @@ -11,12 +11,14 @@
6837 #ifndef _ASM_PROC_CACHE_H
6838 #define _ASM_PROC_CACHE_H
6839
6840 +#include <linux/const.h>
6841 +
6842 /* L1 cache */
6843
6844 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6845 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6846 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6847 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6848 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6849 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6850
6851 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6852 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6853 index bcb5df2..84fabd2 100644
6854 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6855 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6856 @@ -16,13 +16,15 @@
6857 #ifndef _ASM_PROC_CACHE_H
6858 #define _ASM_PROC_CACHE_H
6859
6860 +#include <linux/const.h>
6861 +
6862 /*
6863 * L1 cache
6864 */
6865 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6866 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6867 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6868 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6869 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6870 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6871
6872 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6873 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6874 index 4ce7a01..449202a 100644
6875 --- a/arch/openrisc/include/asm/cache.h
6876 +++ b/arch/openrisc/include/asm/cache.h
6877 @@ -19,11 +19,13 @@
6878 #ifndef __ASM_OPENRISC_CACHE_H
6879 #define __ASM_OPENRISC_CACHE_H
6880
6881 +#include <linux/const.h>
6882 +
6883 /* FIXME: How can we replace these with values from the CPU...
6884 * they shouldn't be hard-coded!
6885 */
6886
6887 -#define L1_CACHE_BYTES 16
6888 #define L1_CACHE_SHIFT 4
6889 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6890
6891 #endif /* __ASM_OPENRISC_CACHE_H */
6892 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6893 index 472886c..00e7df9 100644
6894 --- a/arch/parisc/include/asm/atomic.h
6895 +++ b/arch/parisc/include/asm/atomic.h
6896 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6897 return dec;
6898 }
6899
6900 +#define atomic64_read_unchecked(v) atomic64_read(v)
6901 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6902 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6903 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6904 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6905 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6906 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6907 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6908 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6909 +
6910 #endif /* !CONFIG_64BIT */
6911
6912
6913 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6914 index 47f11c7..3420df2 100644
6915 --- a/arch/parisc/include/asm/cache.h
6916 +++ b/arch/parisc/include/asm/cache.h
6917 @@ -5,6 +5,7 @@
6918 #ifndef __ARCH_PARISC_CACHE_H
6919 #define __ARCH_PARISC_CACHE_H
6920
6921 +#include <linux/const.h>
6922
6923 /*
6924 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6925 @@ -15,13 +16,13 @@
6926 * just ruin performance.
6927 */
6928 #ifdef CONFIG_PA20
6929 -#define L1_CACHE_BYTES 64
6930 #define L1_CACHE_SHIFT 6
6931 #else
6932 -#define L1_CACHE_BYTES 32
6933 #define L1_CACHE_SHIFT 5
6934 #endif
6935
6936 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6937 +
6938 #ifndef __ASSEMBLY__
6939
6940 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6941 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
6942 index ad2b503..bdf1651 100644
6943 --- a/arch/parisc/include/asm/elf.h
6944 +++ b/arch/parisc/include/asm/elf.h
6945 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
6946
6947 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
6948
6949 +#ifdef CONFIG_PAX_ASLR
6950 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
6951 +
6952 +#define PAX_DELTA_MMAP_LEN 16
6953 +#define PAX_DELTA_STACK_LEN 16
6954 +#endif
6955 +
6956 /* This yields a mask that user programs can use to figure out what
6957 instruction set this CPU supports. This could be done in user space,
6958 but it's not easy, and we've already done it here. */
6959 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
6960 index fc987a1..6e068ef 100644
6961 --- a/arch/parisc/include/asm/pgalloc.h
6962 +++ b/arch/parisc/include/asm/pgalloc.h
6963 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6964 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
6965 }
6966
6967 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6968 +{
6969 + pgd_populate(mm, pgd, pmd);
6970 +}
6971 +
6972 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
6973 {
6974 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
6975 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
6976 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
6977 #define pmd_free(mm, x) do { } while (0)
6978 #define pgd_populate(mm, pmd, pte) BUG()
6979 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
6980
6981 #endif
6982
6983 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
6984 index 34899b5..02dd060 100644
6985 --- a/arch/parisc/include/asm/pgtable.h
6986 +++ b/arch/parisc/include/asm/pgtable.h
6987 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6988 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6989 #define PAGE_COPY PAGE_EXECREAD
6990 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6991 +
6992 +#ifdef CONFIG_PAX_PAGEEXEC
6993 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6994 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6995 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6996 +#else
6997 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6998 +# define PAGE_COPY_NOEXEC PAGE_COPY
6999 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7000 +#endif
7001 +
7002 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7003 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7004 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7005 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7006 index e0a8235..ce2f1e1 100644
7007 --- a/arch/parisc/include/asm/uaccess.h
7008 +++ b/arch/parisc/include/asm/uaccess.h
7009 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7010 const void __user *from,
7011 unsigned long n)
7012 {
7013 - int sz = __compiletime_object_size(to);
7014 + size_t sz = __compiletime_object_size(to);
7015 int ret = -EFAULT;
7016
7017 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7018 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7019 ret = __copy_from_user(to, from, n);
7020 else
7021 copy_from_user_overflow();
7022 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7023 index 2a625fb..9908930 100644
7024 --- a/arch/parisc/kernel/module.c
7025 +++ b/arch/parisc/kernel/module.c
7026 @@ -98,16 +98,38 @@
7027
7028 /* three functions to determine where in the module core
7029 * or init pieces the location is */
7030 +static inline int in_init_rx(struct module *me, void *loc)
7031 +{
7032 + return (loc >= me->module_init_rx &&
7033 + loc < (me->module_init_rx + me->init_size_rx));
7034 +}
7035 +
7036 +static inline int in_init_rw(struct module *me, void *loc)
7037 +{
7038 + return (loc >= me->module_init_rw &&
7039 + loc < (me->module_init_rw + me->init_size_rw));
7040 +}
7041 +
7042 static inline int in_init(struct module *me, void *loc)
7043 {
7044 - return (loc >= me->module_init &&
7045 - loc <= (me->module_init + me->init_size));
7046 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7047 +}
7048 +
7049 +static inline int in_core_rx(struct module *me, void *loc)
7050 +{
7051 + return (loc >= me->module_core_rx &&
7052 + loc < (me->module_core_rx + me->core_size_rx));
7053 +}
7054 +
7055 +static inline int in_core_rw(struct module *me, void *loc)
7056 +{
7057 + return (loc >= me->module_core_rw &&
7058 + loc < (me->module_core_rw + me->core_size_rw));
7059 }
7060
7061 static inline int in_core(struct module *me, void *loc)
7062 {
7063 - return (loc >= me->module_core &&
7064 - loc <= (me->module_core + me->core_size));
7065 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7066 }
7067
7068 static inline int in_local(struct module *me, void *loc)
7069 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7070 }
7071
7072 /* align things a bit */
7073 - me->core_size = ALIGN(me->core_size, 16);
7074 - me->arch.got_offset = me->core_size;
7075 - me->core_size += gots * sizeof(struct got_entry);
7076 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7077 + me->arch.got_offset = me->core_size_rw;
7078 + me->core_size_rw += gots * sizeof(struct got_entry);
7079
7080 - me->core_size = ALIGN(me->core_size, 16);
7081 - me->arch.fdesc_offset = me->core_size;
7082 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7083 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7084 + me->arch.fdesc_offset = me->core_size_rw;
7085 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7086
7087 me->arch.got_max = gots;
7088 me->arch.fdesc_max = fdescs;
7089 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7090
7091 BUG_ON(value == 0);
7092
7093 - got = me->module_core + me->arch.got_offset;
7094 + got = me->module_core_rw + me->arch.got_offset;
7095 for (i = 0; got[i].addr; i++)
7096 if (got[i].addr == value)
7097 goto out;
7098 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7099 #ifdef CONFIG_64BIT
7100 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7101 {
7102 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7103 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7104
7105 if (!value) {
7106 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7107 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7108
7109 /* Create new one */
7110 fdesc->addr = value;
7111 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7112 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7113 return (Elf_Addr)fdesc;
7114 }
7115 #endif /* CONFIG_64BIT */
7116 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7117
7118 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7119 end = table + sechdrs[me->arch.unwind_section].sh_size;
7120 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7121 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7122
7123 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7124 me->arch.unwind_section, table, end, gp);
7125 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7126 index 5dfd248..64914ac 100644
7127 --- a/arch/parisc/kernel/sys_parisc.c
7128 +++ b/arch/parisc/kernel/sys_parisc.c
7129 @@ -33,9 +33,11 @@
7130 #include <linux/utsname.h>
7131 #include <linux/personality.h>
7132
7133 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7134 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7135 + unsigned long flags)
7136 {
7137 struct vm_unmapped_area_info info;
7138 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7139
7140 info.flags = 0;
7141 info.length = len;
7142 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7143 info.high_limit = TASK_SIZE;
7144 info.align_mask = 0;
7145 info.align_offset = 0;
7146 + info.threadstack_offset = offset;
7147 return vm_unmapped_area(&info);
7148 }
7149
7150 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7151 return (unsigned long) mapping >> 8;
7152 }
7153
7154 -static unsigned long get_shared_area(struct address_space *mapping,
7155 - unsigned long addr, unsigned long len, unsigned long pgoff)
7156 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7157 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7158 {
7159 struct vm_unmapped_area_info info;
7160 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7161
7162 info.flags = 0;
7163 info.length = len;
7164 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7165 info.high_limit = TASK_SIZE;
7166 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7167 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7168 + info.threadstack_offset = offset;
7169 return vm_unmapped_area(&info);
7170 }
7171
7172 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7173 return -EINVAL;
7174 return addr;
7175 }
7176 - if (!addr)
7177 + if (!addr) {
7178 addr = TASK_UNMAPPED_BASE;
7179
7180 +#ifdef CONFIG_PAX_RANDMMAP
7181 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7182 + addr += current->mm->delta_mmap;
7183 +#endif
7184 +
7185 + }
7186 +
7187 if (filp) {
7188 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7189 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7190 } else if(flags & MAP_SHARED) {
7191 - addr = get_shared_area(NULL, addr, len, pgoff);
7192 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7193 } else {
7194 - addr = get_unshared_area(addr, len);
7195 + addr = get_unshared_area(filp, addr, len, flags);
7196 }
7197 return addr;
7198 }
7199 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7200 index 04e47c6..7a8faf6 100644
7201 --- a/arch/parisc/kernel/traps.c
7202 +++ b/arch/parisc/kernel/traps.c
7203 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7204
7205 down_read(&current->mm->mmap_sem);
7206 vma = find_vma(current->mm,regs->iaoq[0]);
7207 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7208 - && (vma->vm_flags & VM_EXEC)) {
7209 -
7210 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7211 fault_address = regs->iaoq[0];
7212 fault_space = regs->iasq[0];
7213
7214 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7215 index f247a34..dc0f219 100644
7216 --- a/arch/parisc/mm/fault.c
7217 +++ b/arch/parisc/mm/fault.c
7218 @@ -15,6 +15,7 @@
7219 #include <linux/sched.h>
7220 #include <linux/interrupt.h>
7221 #include <linux/module.h>
7222 +#include <linux/unistd.h>
7223
7224 #include <asm/uaccess.h>
7225 #include <asm/traps.h>
7226 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7227 static unsigned long
7228 parisc_acctyp(unsigned long code, unsigned int inst)
7229 {
7230 - if (code == 6 || code == 16)
7231 + if (code == 6 || code == 7 || code == 16)
7232 return VM_EXEC;
7233
7234 switch (inst & 0xf0000000) {
7235 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7236 }
7237 #endif
7238
7239 +#ifdef CONFIG_PAX_PAGEEXEC
7240 +/*
7241 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7242 + *
7243 + * returns 1 when task should be killed
7244 + * 2 when rt_sigreturn trampoline was detected
7245 + * 3 when unpatched PLT trampoline was detected
7246 + */
7247 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7248 +{
7249 +
7250 +#ifdef CONFIG_PAX_EMUPLT
7251 + int err;
7252 +
7253 + do { /* PaX: unpatched PLT emulation */
7254 + unsigned int bl, depwi;
7255 +
7256 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7257 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7258 +
7259 + if (err)
7260 + break;
7261 +
7262 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7263 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7264 +
7265 + err = get_user(ldw, (unsigned int *)addr);
7266 + err |= get_user(bv, (unsigned int *)(addr+4));
7267 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7268 +
7269 + if (err)
7270 + break;
7271 +
7272 + if (ldw == 0x0E801096U &&
7273 + bv == 0xEAC0C000U &&
7274 + ldw2 == 0x0E881095U)
7275 + {
7276 + unsigned int resolver, map;
7277 +
7278 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7279 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7280 + if (err)
7281 + break;
7282 +
7283 + regs->gr[20] = instruction_pointer(regs)+8;
7284 + regs->gr[21] = map;
7285 + regs->gr[22] = resolver;
7286 + regs->iaoq[0] = resolver | 3UL;
7287 + regs->iaoq[1] = regs->iaoq[0] + 4;
7288 + return 3;
7289 + }
7290 + }
7291 + } while (0);
7292 +#endif
7293 +
7294 +#ifdef CONFIG_PAX_EMUTRAMP
7295 +
7296 +#ifndef CONFIG_PAX_EMUSIGRT
7297 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7298 + return 1;
7299 +#endif
7300 +
7301 + do { /* PaX: rt_sigreturn emulation */
7302 + unsigned int ldi1, ldi2, bel, nop;
7303 +
7304 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7305 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7306 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7307 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7308 +
7309 + if (err)
7310 + break;
7311 +
7312 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7313 + ldi2 == 0x3414015AU &&
7314 + bel == 0xE4008200U &&
7315 + nop == 0x08000240U)
7316 + {
7317 + regs->gr[25] = (ldi1 & 2) >> 1;
7318 + regs->gr[20] = __NR_rt_sigreturn;
7319 + regs->gr[31] = regs->iaoq[1] + 16;
7320 + regs->sr[0] = regs->iasq[1];
7321 + regs->iaoq[0] = 0x100UL;
7322 + regs->iaoq[1] = regs->iaoq[0] + 4;
7323 + regs->iasq[0] = regs->sr[2];
7324 + regs->iasq[1] = regs->sr[2];
7325 + return 2;
7326 + }
7327 + } while (0);
7328 +#endif
7329 +
7330 + return 1;
7331 +}
7332 +
7333 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7334 +{
7335 + unsigned long i;
7336 +
7337 + printk(KERN_ERR "PAX: bytes at PC: ");
7338 + for (i = 0; i < 5; i++) {
7339 + unsigned int c;
7340 + if (get_user(c, (unsigned int *)pc+i))
7341 + printk(KERN_CONT "???????? ");
7342 + else
7343 + printk(KERN_CONT "%08x ", c);
7344 + }
7345 + printk("\n");
7346 +}
7347 +#endif
7348 +
7349 int fixup_exception(struct pt_regs *regs)
7350 {
7351 const struct exception_table_entry *fix;
7352 @@ -194,8 +305,33 @@ good_area:
7353
7354 acc_type = parisc_acctyp(code,regs->iir);
7355
7356 - if ((vma->vm_flags & acc_type) != acc_type)
7357 + if ((vma->vm_flags & acc_type) != acc_type) {
7358 +
7359 +#ifdef CONFIG_PAX_PAGEEXEC
7360 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7361 + (address & ~3UL) == instruction_pointer(regs))
7362 + {
7363 + up_read(&mm->mmap_sem);
7364 + switch (pax_handle_fetch_fault(regs)) {
7365 +
7366 +#ifdef CONFIG_PAX_EMUPLT
7367 + case 3:
7368 + return;
7369 +#endif
7370 +
7371 +#ifdef CONFIG_PAX_EMUTRAMP
7372 + case 2:
7373 + return;
7374 +#endif
7375 +
7376 + }
7377 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7378 + do_group_exit(SIGKILL);
7379 + }
7380 +#endif
7381 +
7382 goto bad_area;
7383 + }
7384
7385 /*
7386 * If for any reason at all we couldn't handle the fault, make
7387 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7388 index e3b1d41..8e81edf 100644
7389 --- a/arch/powerpc/include/asm/atomic.h
7390 +++ b/arch/powerpc/include/asm/atomic.h
7391 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7392 return t1;
7393 }
7394
7395 +#define atomic64_read_unchecked(v) atomic64_read(v)
7396 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7397 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7398 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7399 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7400 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7401 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7402 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7403 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7404 +
7405 #endif /* __powerpc64__ */
7406
7407 #endif /* __KERNEL__ */
7408 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7409 index 9e495c9..b6878e5 100644
7410 --- a/arch/powerpc/include/asm/cache.h
7411 +++ b/arch/powerpc/include/asm/cache.h
7412 @@ -3,6 +3,7 @@
7413
7414 #ifdef __KERNEL__
7415
7416 +#include <linux/const.h>
7417
7418 /* bytes per L1 cache line */
7419 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7420 @@ -22,7 +23,7 @@
7421 #define L1_CACHE_SHIFT 7
7422 #endif
7423
7424 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7425 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7426
7427 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7428
7429 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7430 index cc0655a..13eac2e 100644
7431 --- a/arch/powerpc/include/asm/elf.h
7432 +++ b/arch/powerpc/include/asm/elf.h
7433 @@ -28,8 +28,19 @@
7434 the loader. We need to make sure that it is out of the way of the program
7435 that it will "exec", and that there is sufficient room for the brk. */
7436
7437 -extern unsigned long randomize_et_dyn(unsigned long base);
7438 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7439 +#define ELF_ET_DYN_BASE (0x20000000)
7440 +
7441 +#ifdef CONFIG_PAX_ASLR
7442 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7443 +
7444 +#ifdef __powerpc64__
7445 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7446 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7447 +#else
7448 +#define PAX_DELTA_MMAP_LEN 15
7449 +#define PAX_DELTA_STACK_LEN 15
7450 +#endif
7451 +#endif
7452
7453 /*
7454 * Our registers are always unsigned longs, whether we're a 32 bit
7455 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7456 (0x7ff >> (PAGE_SHIFT - 12)) : \
7457 (0x3ffff >> (PAGE_SHIFT - 12)))
7458
7459 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7460 -#define arch_randomize_brk arch_randomize_brk
7461 -
7462 -
7463 #ifdef CONFIG_SPU_BASE
7464 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7465 #define NT_SPU 1
7466 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7467 index 8196e9c..d83a9f3 100644
7468 --- a/arch/powerpc/include/asm/exec.h
7469 +++ b/arch/powerpc/include/asm/exec.h
7470 @@ -4,6 +4,6 @@
7471 #ifndef _ASM_POWERPC_EXEC_H
7472 #define _ASM_POWERPC_EXEC_H
7473
7474 -extern unsigned long arch_align_stack(unsigned long sp);
7475 +#define arch_align_stack(x) ((x) & ~0xfUL)
7476
7477 #endif /* _ASM_POWERPC_EXEC_H */
7478 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7479 index 5acabbd..7ea14fa 100644
7480 --- a/arch/powerpc/include/asm/kmap_types.h
7481 +++ b/arch/powerpc/include/asm/kmap_types.h
7482 @@ -10,7 +10,7 @@
7483 * 2 of the License, or (at your option) any later version.
7484 */
7485
7486 -#define KM_TYPE_NR 16
7487 +#define KM_TYPE_NR 17
7488
7489 #endif /* __KERNEL__ */
7490 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7491 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7492 index 8565c25..2865190 100644
7493 --- a/arch/powerpc/include/asm/mman.h
7494 +++ b/arch/powerpc/include/asm/mman.h
7495 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7496 }
7497 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7498
7499 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7500 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7501 {
7502 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7503 }
7504 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7505 index b9f4262..dcf04f7 100644
7506 --- a/arch/powerpc/include/asm/page.h
7507 +++ b/arch/powerpc/include/asm/page.h
7508 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7509 * and needs to be executable. This means the whole heap ends
7510 * up being executable.
7511 */
7512 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7513 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7514 +#define VM_DATA_DEFAULT_FLAGS32 \
7515 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7516 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7517
7518 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7519 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7520 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7521 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7522 #endif
7523
7524 +#define ktla_ktva(addr) (addr)
7525 +#define ktva_ktla(addr) (addr)
7526 +
7527 #ifndef CONFIG_PPC_BOOK3S_64
7528 /*
7529 * Use the top bit of the higher-level page table entries to indicate whether
7530 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7531 index 88693ce..ac6f9ab 100644
7532 --- a/arch/powerpc/include/asm/page_64.h
7533 +++ b/arch/powerpc/include/asm/page_64.h
7534 @@ -153,15 +153,18 @@ do { \
7535 * stack by default, so in the absence of a PT_GNU_STACK program header
7536 * we turn execute permission off.
7537 */
7538 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7539 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7540 +#define VM_STACK_DEFAULT_FLAGS32 \
7541 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7542 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7543
7544 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7545 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7546
7547 +#ifndef CONFIG_PAX_PAGEEXEC
7548 #define VM_STACK_DEFAULT_FLAGS \
7549 (is_32bit_task() ? \
7550 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7551 +#endif
7552
7553 #include <asm-generic/getorder.h>
7554
7555 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7556 index f65e27b..23ffb5b 100644
7557 --- a/arch/powerpc/include/asm/pgalloc-64.h
7558 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7559 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7560 #ifndef CONFIG_PPC_64K_PAGES
7561
7562 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7563 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7564
7565 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7566 {
7567 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7568 pud_set(pud, (unsigned long)pmd);
7569 }
7570
7571 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7572 +{
7573 + pud_populate(mm, pud, pmd);
7574 +}
7575 +
7576 #define pmd_populate(mm, pmd, pte_page) \
7577 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7578 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7579 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7580 #endif
7581
7582 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7583 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7584
7585 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7586 pte_t *pte)
7587 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7588 index 7d6eacf..14c0240 100644
7589 --- a/arch/powerpc/include/asm/pgtable.h
7590 +++ b/arch/powerpc/include/asm/pgtable.h
7591 @@ -2,6 +2,7 @@
7592 #define _ASM_POWERPC_PGTABLE_H
7593 #ifdef __KERNEL__
7594
7595 +#include <linux/const.h>
7596 #ifndef __ASSEMBLY__
7597 #include <asm/processor.h> /* For TASK_SIZE */
7598 #include <asm/mmu.h>
7599 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7600 index 4aad413..85d86bf 100644
7601 --- a/arch/powerpc/include/asm/pte-hash32.h
7602 +++ b/arch/powerpc/include/asm/pte-hash32.h
7603 @@ -21,6 +21,7 @@
7604 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7605 #define _PAGE_USER 0x004 /* usermode access allowed */
7606 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7607 +#define _PAGE_EXEC _PAGE_GUARDED
7608 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7609 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7610 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7611 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7612 index 99222e2..f629aef 100644
7613 --- a/arch/powerpc/include/asm/reg.h
7614 +++ b/arch/powerpc/include/asm/reg.h
7615 @@ -234,6 +234,7 @@
7616 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7617 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7618 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7619 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7620 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7621 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7622 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7623 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7624 index 48cfc85..891382f 100644
7625 --- a/arch/powerpc/include/asm/smp.h
7626 +++ b/arch/powerpc/include/asm/smp.h
7627 @@ -50,7 +50,7 @@ struct smp_ops_t {
7628 int (*cpu_disable)(void);
7629 void (*cpu_die)(unsigned int nr);
7630 int (*cpu_bootable)(unsigned int nr);
7631 -};
7632 +} __no_const;
7633
7634 extern void smp_send_debugger_break(void);
7635 extern void start_secondary_resume(void);
7636 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7637 index ba7b197..d292e26 100644
7638 --- a/arch/powerpc/include/asm/thread_info.h
7639 +++ b/arch/powerpc/include/asm/thread_info.h
7640 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7641 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7642 TIF_NEED_RESCHED */
7643 #define TIF_32BIT 4 /* 32 bit binary */
7644 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7645 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7646 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7647 #define TIF_SINGLESTEP 8 /* singlestepping active */
7648 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7649 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7650 for stack store? */
7651 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7652 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7653 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7654 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7655
7656 /* as above, but as bit values */
7657 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7658 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7659 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7660 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7661 #define _TIF_NOHZ (1<<TIF_NOHZ)
7662 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7663 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7664 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7665 - _TIF_NOHZ)
7666 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7667
7668 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7669 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7670 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7671 index 9485b43..4718d50 100644
7672 --- a/arch/powerpc/include/asm/uaccess.h
7673 +++ b/arch/powerpc/include/asm/uaccess.h
7674 @@ -318,52 +318,6 @@ do { \
7675 extern unsigned long __copy_tofrom_user(void __user *to,
7676 const void __user *from, unsigned long size);
7677
7678 -#ifndef __powerpc64__
7679 -
7680 -static inline unsigned long copy_from_user(void *to,
7681 - const void __user *from, unsigned long n)
7682 -{
7683 - unsigned long over;
7684 -
7685 - if (access_ok(VERIFY_READ, from, n))
7686 - return __copy_tofrom_user((__force void __user *)to, from, n);
7687 - if ((unsigned long)from < TASK_SIZE) {
7688 - over = (unsigned long)from + n - TASK_SIZE;
7689 - return __copy_tofrom_user((__force void __user *)to, from,
7690 - n - over) + over;
7691 - }
7692 - return n;
7693 -}
7694 -
7695 -static inline unsigned long copy_to_user(void __user *to,
7696 - const void *from, unsigned long n)
7697 -{
7698 - unsigned long over;
7699 -
7700 - if (access_ok(VERIFY_WRITE, to, n))
7701 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7702 - if ((unsigned long)to < TASK_SIZE) {
7703 - over = (unsigned long)to + n - TASK_SIZE;
7704 - return __copy_tofrom_user(to, (__force void __user *)from,
7705 - n - over) + over;
7706 - }
7707 - return n;
7708 -}
7709 -
7710 -#else /* __powerpc64__ */
7711 -
7712 -#define __copy_in_user(to, from, size) \
7713 - __copy_tofrom_user((to), (from), (size))
7714 -
7715 -extern unsigned long copy_from_user(void *to, const void __user *from,
7716 - unsigned long n);
7717 -extern unsigned long copy_to_user(void __user *to, const void *from,
7718 - unsigned long n);
7719 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7720 - unsigned long n);
7721 -
7722 -#endif /* __powerpc64__ */
7723 -
7724 static inline unsigned long __copy_from_user_inatomic(void *to,
7725 const void __user *from, unsigned long n)
7726 {
7727 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7728 if (ret == 0)
7729 return 0;
7730 }
7731 +
7732 + if (!__builtin_constant_p(n))
7733 + check_object_size(to, n, false);
7734 +
7735 return __copy_tofrom_user((__force void __user *)to, from, n);
7736 }
7737
7738 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7739 if (ret == 0)
7740 return 0;
7741 }
7742 +
7743 + if (!__builtin_constant_p(n))
7744 + check_object_size(from, n, true);
7745 +
7746 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7747 }
7748
7749 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7750 return __copy_to_user_inatomic(to, from, size);
7751 }
7752
7753 +#ifndef __powerpc64__
7754 +
7755 +static inline unsigned long __must_check copy_from_user(void *to,
7756 + const void __user *from, unsigned long n)
7757 +{
7758 + unsigned long over;
7759 +
7760 + if ((long)n < 0)
7761 + return n;
7762 +
7763 + if (access_ok(VERIFY_READ, from, n)) {
7764 + if (!__builtin_constant_p(n))
7765 + check_object_size(to, n, false);
7766 + return __copy_tofrom_user((__force void __user *)to, from, n);
7767 + }
7768 + if ((unsigned long)from < TASK_SIZE) {
7769 + over = (unsigned long)from + n - TASK_SIZE;
7770 + if (!__builtin_constant_p(n - over))
7771 + check_object_size(to, n - over, false);
7772 + return __copy_tofrom_user((__force void __user *)to, from,
7773 + n - over) + over;
7774 + }
7775 + return n;
7776 +}
7777 +
7778 +static inline unsigned long __must_check copy_to_user(void __user *to,
7779 + const void *from, unsigned long n)
7780 +{
7781 + unsigned long over;
7782 +
7783 + if ((long)n < 0)
7784 + return n;
7785 +
7786 + if (access_ok(VERIFY_WRITE, to, n)) {
7787 + if (!__builtin_constant_p(n))
7788 + check_object_size(from, n, true);
7789 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7790 + }
7791 + if ((unsigned long)to < TASK_SIZE) {
7792 + over = (unsigned long)to + n - TASK_SIZE;
7793 + if (!__builtin_constant_p(n))
7794 + check_object_size(from, n - over, true);
7795 + return __copy_tofrom_user(to, (__force void __user *)from,
7796 + n - over) + over;
7797 + }
7798 + return n;
7799 +}
7800 +
7801 +#else /* __powerpc64__ */
7802 +
7803 +#define __copy_in_user(to, from, size) \
7804 + __copy_tofrom_user((to), (from), (size))
7805 +
7806 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7807 +{
7808 + if ((long)n < 0 || n > INT_MAX)
7809 + return n;
7810 +
7811 + if (!__builtin_constant_p(n))
7812 + check_object_size(to, n, false);
7813 +
7814 + if (likely(access_ok(VERIFY_READ, from, n)))
7815 + n = __copy_from_user(to, from, n);
7816 + else
7817 + memset(to, 0, n);
7818 + return n;
7819 +}
7820 +
7821 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7822 +{
7823 + if ((long)n < 0 || n > INT_MAX)
7824 + return n;
7825 +
7826 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7827 + if (!__builtin_constant_p(n))
7828 + check_object_size(from, n, true);
7829 + n = __copy_to_user(to, from, n);
7830 + }
7831 + return n;
7832 +}
7833 +
7834 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7835 + unsigned long n);
7836 +
7837 +#endif /* __powerpc64__ */
7838 +
7839 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7840
7841 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7842 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7843 index 645170a..6cf0271 100644
7844 --- a/arch/powerpc/kernel/exceptions-64e.S
7845 +++ b/arch/powerpc/kernel/exceptions-64e.S
7846 @@ -757,6 +757,7 @@ storage_fault_common:
7847 std r14,_DAR(r1)
7848 std r15,_DSISR(r1)
7849 addi r3,r1,STACK_FRAME_OVERHEAD
7850 + bl .save_nvgprs
7851 mr r4,r14
7852 mr r5,r15
7853 ld r14,PACA_EXGEN+EX_R14(r13)
7854 @@ -765,8 +766,7 @@ storage_fault_common:
7855 cmpdi r3,0
7856 bne- 1f
7857 b .ret_from_except_lite
7858 -1: bl .save_nvgprs
7859 - mr r5,r3
7860 +1: mr r5,r3
7861 addi r3,r1,STACK_FRAME_OVERHEAD
7862 ld r4,_DAR(r1)
7863 bl .bad_page_fault
7864 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7865 index 902ca3c..e942155 100644
7866 --- a/arch/powerpc/kernel/exceptions-64s.S
7867 +++ b/arch/powerpc/kernel/exceptions-64s.S
7868 @@ -1357,10 +1357,10 @@ handle_page_fault:
7869 11: ld r4,_DAR(r1)
7870 ld r5,_DSISR(r1)
7871 addi r3,r1,STACK_FRAME_OVERHEAD
7872 + bl .save_nvgprs
7873 bl .do_page_fault
7874 cmpdi r3,0
7875 beq+ 12f
7876 - bl .save_nvgprs
7877 mr r5,r3
7878 addi r3,r1,STACK_FRAME_OVERHEAD
7879 lwz r4,_DAR(r1)
7880 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7881 index 2e3200c..72095ce 100644
7882 --- a/arch/powerpc/kernel/module_32.c
7883 +++ b/arch/powerpc/kernel/module_32.c
7884 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7885 me->arch.core_plt_section = i;
7886 }
7887 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7888 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7889 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7890 return -ENOEXEC;
7891 }
7892
7893 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7894
7895 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7896 /* Init, or core PLT? */
7897 - if (location >= mod->module_core
7898 - && location < mod->module_core + mod->core_size)
7899 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7900 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7901 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7902 - else
7903 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7904 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7905 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7906 + else {
7907 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7908 + return ~0UL;
7909 + }
7910
7911 /* Find this entry, or if that fails, the next avail. entry */
7912 while (entry->jump[0]) {
7913 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7914 index 8083be2..10aa352 100644
7915 --- a/arch/powerpc/kernel/process.c
7916 +++ b/arch/powerpc/kernel/process.c
7917 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7918 * Lookup NIP late so we have the best change of getting the
7919 * above info out without failing
7920 */
7921 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7922 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7923 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7924 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7925 #endif
7926 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
7927 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
7928 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7929 newsp = stack[0];
7930 ip = stack[STACK_FRAME_LR_SAVE];
7931 if (!firstframe || ip != lr) {
7932 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7933 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7934 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7935 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7936 - printk(" (%pS)",
7937 + printk(" (%pA)",
7938 (void *)current->ret_stack[curr_frame].ret);
7939 curr_frame--;
7940 }
7941 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7942 struct pt_regs *regs = (struct pt_regs *)
7943 (sp + STACK_FRAME_OVERHEAD);
7944 lr = regs->link;
7945 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
7946 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
7947 regs->trap, (void *)regs->nip, (void *)lr);
7948 firstframe = 1;
7949 }
7950 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
7951 mtspr(SPRN_CTRLT, ctrl);
7952 }
7953 #endif /* CONFIG_PPC64 */
7954 -
7955 -unsigned long arch_align_stack(unsigned long sp)
7956 -{
7957 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7958 - sp -= get_random_int() & ~PAGE_MASK;
7959 - return sp & ~0xf;
7960 -}
7961 -
7962 -static inline unsigned long brk_rnd(void)
7963 -{
7964 - unsigned long rnd = 0;
7965 -
7966 - /* 8MB for 32bit, 1GB for 64bit */
7967 - if (is_32bit_task())
7968 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7969 - else
7970 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7971 -
7972 - return rnd << PAGE_SHIFT;
7973 -}
7974 -
7975 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7976 -{
7977 - unsigned long base = mm->brk;
7978 - unsigned long ret;
7979 -
7980 -#ifdef CONFIG_PPC_STD_MMU_64
7981 - /*
7982 - * If we are using 1TB segments and we are allowed to randomise
7983 - * the heap, we can put it above 1TB so it is backed by a 1TB
7984 - * segment. Otherwise the heap will be in the bottom 1TB
7985 - * which always uses 256MB segments and this may result in a
7986 - * performance penalty.
7987 - */
7988 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7989 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7990 -#endif
7991 -
7992 - ret = PAGE_ALIGN(base + brk_rnd());
7993 -
7994 - if (ret < mm->brk)
7995 - return mm->brk;
7996 -
7997 - return ret;
7998 -}
7999 -
8000 -unsigned long randomize_et_dyn(unsigned long base)
8001 -{
8002 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8003 -
8004 - if (ret < base)
8005 - return base;
8006 -
8007 - return ret;
8008 -}
8009 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8010 index 9a0d24c..e7fbedf 100644
8011 --- a/arch/powerpc/kernel/ptrace.c
8012 +++ b/arch/powerpc/kernel/ptrace.c
8013 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8014 return ret;
8015 }
8016
8017 +#ifdef CONFIG_GRKERNSEC_SETXID
8018 +extern void gr_delayed_cred_worker(void);
8019 +#endif
8020 +
8021 /*
8022 * We must return the syscall number to actually look up in the table.
8023 * This can be -1L to skip running any syscall at all.
8024 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8025
8026 secure_computing_strict(regs->gpr[0]);
8027
8028 +#ifdef CONFIG_GRKERNSEC_SETXID
8029 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8030 + gr_delayed_cred_worker();
8031 +#endif
8032 +
8033 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8034 tracehook_report_syscall_entry(regs))
8035 /*
8036 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8037 {
8038 int step;
8039
8040 +#ifdef CONFIG_GRKERNSEC_SETXID
8041 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8042 + gr_delayed_cred_worker();
8043 +#endif
8044 +
8045 audit_syscall_exit(regs);
8046
8047 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8048 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8049 index 0f83122..c0aca6a 100644
8050 --- a/arch/powerpc/kernel/signal_32.c
8051 +++ b/arch/powerpc/kernel/signal_32.c
8052 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8053 /* Save user registers on the stack */
8054 frame = &rt_sf->uc.uc_mcontext;
8055 addr = frame;
8056 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8057 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8058 sigret = 0;
8059 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8060 } else {
8061 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8062 index 887e99d..310bc11 100644
8063 --- a/arch/powerpc/kernel/signal_64.c
8064 +++ b/arch/powerpc/kernel/signal_64.c
8065 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8066 #endif
8067
8068 /* Set up to return from userspace. */
8069 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8070 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8071 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8072 } else {
8073 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8074 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8075 index e435bc0..41c2964 100644
8076 --- a/arch/powerpc/kernel/traps.c
8077 +++ b/arch/powerpc/kernel/traps.c
8078 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8079 return flags;
8080 }
8081
8082 +extern void gr_handle_kernel_exploit(void);
8083 +
8084 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8085 int signr)
8086 {
8087 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8088 panic("Fatal exception in interrupt");
8089 if (panic_on_oops)
8090 panic("Fatal exception");
8091 +
8092 + gr_handle_kernel_exploit();
8093 +
8094 do_exit(signr);
8095 }
8096
8097 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8098 index 1d9c926..25f4741 100644
8099 --- a/arch/powerpc/kernel/vdso.c
8100 +++ b/arch/powerpc/kernel/vdso.c
8101 @@ -34,6 +34,7 @@
8102 #include <asm/firmware.h>
8103 #include <asm/vdso.h>
8104 #include <asm/vdso_datapage.h>
8105 +#include <asm/mman.h>
8106
8107 #include "setup.h"
8108
8109 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8110 vdso_base = VDSO32_MBASE;
8111 #endif
8112
8113 - current->mm->context.vdso_base = 0;
8114 + current->mm->context.vdso_base = ~0UL;
8115
8116 /* vDSO has a problem and was disabled, just don't "enable" it for the
8117 * process
8118 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8119 vdso_base = get_unmapped_area(NULL, vdso_base,
8120 (vdso_pages << PAGE_SHIFT) +
8121 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8122 - 0, 0);
8123 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8124 if (IS_ERR_VALUE(vdso_base)) {
8125 rc = vdso_base;
8126 goto fail_mmapsem;
8127 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8128 index 5eea6f3..5d10396 100644
8129 --- a/arch/powerpc/lib/usercopy_64.c
8130 +++ b/arch/powerpc/lib/usercopy_64.c
8131 @@ -9,22 +9,6 @@
8132 #include <linux/module.h>
8133 #include <asm/uaccess.h>
8134
8135 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8136 -{
8137 - if (likely(access_ok(VERIFY_READ, from, n)))
8138 - n = __copy_from_user(to, from, n);
8139 - else
8140 - memset(to, 0, n);
8141 - return n;
8142 -}
8143 -
8144 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8145 -{
8146 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8147 - n = __copy_to_user(to, from, n);
8148 - return n;
8149 -}
8150 -
8151 unsigned long copy_in_user(void __user *to, const void __user *from,
8152 unsigned long n)
8153 {
8154 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8155 return n;
8156 }
8157
8158 -EXPORT_SYMBOL(copy_from_user);
8159 -EXPORT_SYMBOL(copy_to_user);
8160 EXPORT_SYMBOL(copy_in_user);
8161
8162 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8163 index 8726779..a33c512 100644
8164 --- a/arch/powerpc/mm/fault.c
8165 +++ b/arch/powerpc/mm/fault.c
8166 @@ -33,6 +33,10 @@
8167 #include <linux/magic.h>
8168 #include <linux/ratelimit.h>
8169 #include <linux/context_tracking.h>
8170 +#include <linux/slab.h>
8171 +#include <linux/pagemap.h>
8172 +#include <linux/compiler.h>
8173 +#include <linux/unistd.h>
8174
8175 #include <asm/firmware.h>
8176 #include <asm/page.h>
8177 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8178 }
8179 #endif
8180
8181 +#ifdef CONFIG_PAX_PAGEEXEC
8182 +/*
8183 + * PaX: decide what to do with offenders (regs->nip = fault address)
8184 + *
8185 + * returns 1 when task should be killed
8186 + */
8187 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8188 +{
8189 + return 1;
8190 +}
8191 +
8192 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8193 +{
8194 + unsigned long i;
8195 +
8196 + printk(KERN_ERR "PAX: bytes at PC: ");
8197 + for (i = 0; i < 5; i++) {
8198 + unsigned int c;
8199 + if (get_user(c, (unsigned int __user *)pc+i))
8200 + printk(KERN_CONT "???????? ");
8201 + else
8202 + printk(KERN_CONT "%08x ", c);
8203 + }
8204 + printk("\n");
8205 +}
8206 +#endif
8207 +
8208 /*
8209 * Check whether the instruction at regs->nip is a store using
8210 * an update addressing form which will update r1.
8211 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8212 * indicate errors in DSISR but can validly be set in SRR1.
8213 */
8214 if (trap == 0x400)
8215 - error_code &= 0x48200000;
8216 + error_code &= 0x58200000;
8217 else
8218 is_write = error_code & DSISR_ISSTORE;
8219 #else
8220 @@ -371,7 +402,7 @@ good_area:
8221 * "undefined". Of those that can be set, this is the only
8222 * one which seems bad.
8223 */
8224 - if (error_code & 0x10000000)
8225 + if (error_code & DSISR_GUARDED)
8226 /* Guarded storage error. */
8227 goto bad_area;
8228 #endif /* CONFIG_8xx */
8229 @@ -386,7 +417,7 @@ good_area:
8230 * processors use the same I/D cache coherency mechanism
8231 * as embedded.
8232 */
8233 - if (error_code & DSISR_PROTFAULT)
8234 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8235 goto bad_area;
8236 #endif /* CONFIG_PPC_STD_MMU */
8237
8238 @@ -471,6 +502,23 @@ bad_area:
8239 bad_area_nosemaphore:
8240 /* User mode accesses cause a SIGSEGV */
8241 if (user_mode(regs)) {
8242 +
8243 +#ifdef CONFIG_PAX_PAGEEXEC
8244 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8245 +#ifdef CONFIG_PPC_STD_MMU
8246 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8247 +#else
8248 + if (is_exec && regs->nip == address) {
8249 +#endif
8250 + switch (pax_handle_fetch_fault(regs)) {
8251 + }
8252 +
8253 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8254 + do_group_exit(SIGKILL);
8255 + }
8256 + }
8257 +#endif
8258 +
8259 _exception(SIGSEGV, regs, code, address);
8260 goto bail;
8261 }
8262 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8263 index cb8bdbe..d770680 100644
8264 --- a/arch/powerpc/mm/mmap.c
8265 +++ b/arch/powerpc/mm/mmap.c
8266 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8267 {
8268 unsigned long rnd = 0;
8269
8270 +#ifdef CONFIG_PAX_RANDMMAP
8271 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8272 +#endif
8273 +
8274 if (current->flags & PF_RANDOMIZE) {
8275 /* 8MB for 32bit, 1GB for 64bit */
8276 if (is_32bit_task())
8277 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8278 */
8279 if (mmap_is_legacy()) {
8280 mm->mmap_base = TASK_UNMAPPED_BASE;
8281 +
8282 +#ifdef CONFIG_PAX_RANDMMAP
8283 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8284 + mm->mmap_base += mm->delta_mmap;
8285 +#endif
8286 +
8287 mm->get_unmapped_area = arch_get_unmapped_area;
8288 } else {
8289 mm->mmap_base = mmap_base();
8290 +
8291 +#ifdef CONFIG_PAX_RANDMMAP
8292 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8293 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8294 +#endif
8295 +
8296 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8297 }
8298 }
8299 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8300 index 3e99c14..f00953c 100644
8301 --- a/arch/powerpc/mm/slice.c
8302 +++ b/arch/powerpc/mm/slice.c
8303 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8304 if ((mm->task_size - len) < addr)
8305 return 0;
8306 vma = find_vma(mm, addr);
8307 - return (!vma || (addr + len) <= vma->vm_start);
8308 + return check_heap_stack_gap(vma, addr, len, 0);
8309 }
8310
8311 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8312 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8313 info.align_offset = 0;
8314
8315 addr = TASK_UNMAPPED_BASE;
8316 +
8317 +#ifdef CONFIG_PAX_RANDMMAP
8318 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8319 + addr += mm->delta_mmap;
8320 +#endif
8321 +
8322 while (addr < TASK_SIZE) {
8323 info.low_limit = addr;
8324 if (!slice_scan_available(addr, available, 1, &addr))
8325 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8326 if (fixed && addr > (mm->task_size - len))
8327 return -EINVAL;
8328
8329 +#ifdef CONFIG_PAX_RANDMMAP
8330 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8331 + addr = 0;
8332 +#endif
8333 +
8334 /* If hint, make sure it matches our alignment restrictions */
8335 if (!fixed && addr) {
8336 addr = _ALIGN_UP(addr, 1ul << pshift);
8337 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8338 index 9098692..3d54cd1 100644
8339 --- a/arch/powerpc/platforms/cell/spufs/file.c
8340 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8341 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8342 return VM_FAULT_NOPAGE;
8343 }
8344
8345 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8346 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8347 unsigned long address,
8348 - void *buf, int len, int write)
8349 + void *buf, size_t len, int write)
8350 {
8351 struct spu_context *ctx = vma->vm_file->private_data;
8352 unsigned long offset = address - vma->vm_start;
8353 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8354 index c797832..ce575c8 100644
8355 --- a/arch/s390/include/asm/atomic.h
8356 +++ b/arch/s390/include/asm/atomic.h
8357 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8358 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8359 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8360
8361 +#define atomic64_read_unchecked(v) atomic64_read(v)
8362 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8363 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8364 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8365 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8366 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8367 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8368 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8369 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8370 +
8371 #define smp_mb__before_atomic_dec() smp_mb()
8372 #define smp_mb__after_atomic_dec() smp_mb()
8373 #define smp_mb__before_atomic_inc() smp_mb()
8374 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8375 index 4d7ccac..d03d0ad 100644
8376 --- a/arch/s390/include/asm/cache.h
8377 +++ b/arch/s390/include/asm/cache.h
8378 @@ -9,8 +9,10 @@
8379 #ifndef __ARCH_S390_CACHE_H
8380 #define __ARCH_S390_CACHE_H
8381
8382 -#define L1_CACHE_BYTES 256
8383 +#include <linux/const.h>
8384 +
8385 #define L1_CACHE_SHIFT 8
8386 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8387 #define NET_SKB_PAD 32
8388
8389 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8390 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8391 index 78f4f87..598ce39 100644
8392 --- a/arch/s390/include/asm/elf.h
8393 +++ b/arch/s390/include/asm/elf.h
8394 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8395 the loader. We need to make sure that it is out of the way of the program
8396 that it will "exec", and that there is sufficient room for the brk. */
8397
8398 -extern unsigned long randomize_et_dyn(unsigned long base);
8399 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8400 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8401 +
8402 +#ifdef CONFIG_PAX_ASLR
8403 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8404 +
8405 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8406 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8407 +#endif
8408
8409 /* This yields a mask that user programs can use to figure out what
8410 instruction set this CPU supports. */
8411 @@ -222,9 +228,6 @@ struct linux_binprm;
8412 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8413 int arch_setup_additional_pages(struct linux_binprm *, int);
8414
8415 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8416 -#define arch_randomize_brk arch_randomize_brk
8417 -
8418 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8419
8420 #endif
8421 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8422 index c4a93d6..4d2a9b4 100644
8423 --- a/arch/s390/include/asm/exec.h
8424 +++ b/arch/s390/include/asm/exec.h
8425 @@ -7,6 +7,6 @@
8426 #ifndef __ASM_EXEC_H
8427 #define __ASM_EXEC_H
8428
8429 -extern unsigned long arch_align_stack(unsigned long sp);
8430 +#define arch_align_stack(x) ((x) & ~0xfUL)
8431
8432 #endif /* __ASM_EXEC_H */
8433 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8434 index 9c33ed4..e40cbef 100644
8435 --- a/arch/s390/include/asm/uaccess.h
8436 +++ b/arch/s390/include/asm/uaccess.h
8437 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8438 copy_to_user(void __user *to, const void *from, unsigned long n)
8439 {
8440 might_fault();
8441 +
8442 + if ((long)n < 0)
8443 + return n;
8444 +
8445 return __copy_to_user(to, from, n);
8446 }
8447
8448 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8449 static inline unsigned long __must_check
8450 __copy_from_user(void *to, const void __user *from, unsigned long n)
8451 {
8452 + if ((long)n < 0)
8453 + return n;
8454 +
8455 if (__builtin_constant_p(n) && (n <= 256))
8456 return uaccess.copy_from_user_small(n, from, to);
8457 else
8458 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8459 static inline unsigned long __must_check
8460 copy_from_user(void *to, const void __user *from, unsigned long n)
8461 {
8462 - unsigned int sz = __compiletime_object_size(to);
8463 + size_t sz = __compiletime_object_size(to);
8464
8465 might_fault();
8466 - if (unlikely(sz != -1 && sz < n)) {
8467 +
8468 + if ((long)n < 0)
8469 + return n;
8470 +
8471 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8472 copy_from_user_overflow();
8473 return n;
8474 }
8475 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8476 index 7845e15..59c4353 100644
8477 --- a/arch/s390/kernel/module.c
8478 +++ b/arch/s390/kernel/module.c
8479 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8480
8481 /* Increase core size by size of got & plt and set start
8482 offsets for got and plt. */
8483 - me->core_size = ALIGN(me->core_size, 4);
8484 - me->arch.got_offset = me->core_size;
8485 - me->core_size += me->arch.got_size;
8486 - me->arch.plt_offset = me->core_size;
8487 - me->core_size += me->arch.plt_size;
8488 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8489 + me->arch.got_offset = me->core_size_rw;
8490 + me->core_size_rw += me->arch.got_size;
8491 + me->arch.plt_offset = me->core_size_rx;
8492 + me->core_size_rx += me->arch.plt_size;
8493 return 0;
8494 }
8495
8496 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8497 if (info->got_initialized == 0) {
8498 Elf_Addr *gotent;
8499
8500 - gotent = me->module_core + me->arch.got_offset +
8501 + gotent = me->module_core_rw + me->arch.got_offset +
8502 info->got_offset;
8503 *gotent = val;
8504 info->got_initialized = 1;
8505 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8506 rc = apply_rela_bits(loc, val, 0, 64, 0);
8507 else if (r_type == R_390_GOTENT ||
8508 r_type == R_390_GOTPLTENT) {
8509 - val += (Elf_Addr) me->module_core - loc;
8510 + val += (Elf_Addr) me->module_core_rw - loc;
8511 rc = apply_rela_bits(loc, val, 1, 32, 1);
8512 }
8513 break;
8514 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8515 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8516 if (info->plt_initialized == 0) {
8517 unsigned int *ip;
8518 - ip = me->module_core + me->arch.plt_offset +
8519 + ip = me->module_core_rx + me->arch.plt_offset +
8520 info->plt_offset;
8521 #ifndef CONFIG_64BIT
8522 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8523 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8524 val - loc + 0xffffUL < 0x1ffffeUL) ||
8525 (r_type == R_390_PLT32DBL &&
8526 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8527 - val = (Elf_Addr) me->module_core +
8528 + val = (Elf_Addr) me->module_core_rx +
8529 me->arch.plt_offset +
8530 info->plt_offset;
8531 val += rela->r_addend - loc;
8532 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8533 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8534 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8535 val = val + rela->r_addend -
8536 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8537 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8538 if (r_type == R_390_GOTOFF16)
8539 rc = apply_rela_bits(loc, val, 0, 16, 0);
8540 else if (r_type == R_390_GOTOFF32)
8541 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8542 break;
8543 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8544 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8545 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8546 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8547 rela->r_addend - loc;
8548 if (r_type == R_390_GOTPC)
8549 rc = apply_rela_bits(loc, val, 1, 32, 0);
8550 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8551 index 2bc3edd..ab9d598 100644
8552 --- a/arch/s390/kernel/process.c
8553 +++ b/arch/s390/kernel/process.c
8554 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8555 }
8556 return 0;
8557 }
8558 -
8559 -unsigned long arch_align_stack(unsigned long sp)
8560 -{
8561 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8562 - sp -= get_random_int() & ~PAGE_MASK;
8563 - return sp & ~0xf;
8564 -}
8565 -
8566 -static inline unsigned long brk_rnd(void)
8567 -{
8568 - /* 8MB for 32bit, 1GB for 64bit */
8569 - if (is_32bit_task())
8570 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8571 - else
8572 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8573 -}
8574 -
8575 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8576 -{
8577 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8578 -
8579 - if (ret < mm->brk)
8580 - return mm->brk;
8581 - return ret;
8582 -}
8583 -
8584 -unsigned long randomize_et_dyn(unsigned long base)
8585 -{
8586 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8587 -
8588 - if (!(current->flags & PF_RANDOMIZE))
8589 - return base;
8590 - if (ret < base)
8591 - return base;
8592 - return ret;
8593 -}
8594 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8595 index 4002329..99b67cb 100644
8596 --- a/arch/s390/mm/mmap.c
8597 +++ b/arch/s390/mm/mmap.c
8598 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8599 */
8600 if (mmap_is_legacy()) {
8601 mm->mmap_base = TASK_UNMAPPED_BASE;
8602 +
8603 +#ifdef CONFIG_PAX_RANDMMAP
8604 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8605 + mm->mmap_base += mm->delta_mmap;
8606 +#endif
8607 +
8608 mm->get_unmapped_area = arch_get_unmapped_area;
8609 } else {
8610 mm->mmap_base = mmap_base();
8611 +
8612 +#ifdef CONFIG_PAX_RANDMMAP
8613 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8614 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8615 +#endif
8616 +
8617 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8618 }
8619 }
8620 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8621 */
8622 if (mmap_is_legacy()) {
8623 mm->mmap_base = TASK_UNMAPPED_BASE;
8624 +
8625 +#ifdef CONFIG_PAX_RANDMMAP
8626 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8627 + mm->mmap_base += mm->delta_mmap;
8628 +#endif
8629 +
8630 mm->get_unmapped_area = s390_get_unmapped_area;
8631 } else {
8632 mm->mmap_base = mmap_base();
8633 +
8634 +#ifdef CONFIG_PAX_RANDMMAP
8635 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8636 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8637 +#endif
8638 +
8639 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8640 }
8641 }
8642 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8643 index ae3d59f..f65f075 100644
8644 --- a/arch/score/include/asm/cache.h
8645 +++ b/arch/score/include/asm/cache.h
8646 @@ -1,7 +1,9 @@
8647 #ifndef _ASM_SCORE_CACHE_H
8648 #define _ASM_SCORE_CACHE_H
8649
8650 +#include <linux/const.h>
8651 +
8652 #define L1_CACHE_SHIFT 4
8653 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8654 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8655
8656 #endif /* _ASM_SCORE_CACHE_H */
8657 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8658 index f9f3cd5..58ff438 100644
8659 --- a/arch/score/include/asm/exec.h
8660 +++ b/arch/score/include/asm/exec.h
8661 @@ -1,6 +1,6 @@
8662 #ifndef _ASM_SCORE_EXEC_H
8663 #define _ASM_SCORE_EXEC_H
8664
8665 -extern unsigned long arch_align_stack(unsigned long sp);
8666 +#define arch_align_stack(x) (x)
8667
8668 #endif /* _ASM_SCORE_EXEC_H */
8669 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8670 index f4c6d02..e9355c3 100644
8671 --- a/arch/score/kernel/process.c
8672 +++ b/arch/score/kernel/process.c
8673 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8674
8675 return task_pt_regs(task)->cp0_epc;
8676 }
8677 -
8678 -unsigned long arch_align_stack(unsigned long sp)
8679 -{
8680 - return sp;
8681 -}
8682 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8683 index ef9e555..331bd29 100644
8684 --- a/arch/sh/include/asm/cache.h
8685 +++ b/arch/sh/include/asm/cache.h
8686 @@ -9,10 +9,11 @@
8687 #define __ASM_SH_CACHE_H
8688 #ifdef __KERNEL__
8689
8690 +#include <linux/const.h>
8691 #include <linux/init.h>
8692 #include <cpu/cache.h>
8693
8694 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8695 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8696
8697 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8698
8699 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8700 index 6777177..cb5e44f 100644
8701 --- a/arch/sh/mm/mmap.c
8702 +++ b/arch/sh/mm/mmap.c
8703 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8704 struct mm_struct *mm = current->mm;
8705 struct vm_area_struct *vma;
8706 int do_colour_align;
8707 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8708 struct vm_unmapped_area_info info;
8709
8710 if (flags & MAP_FIXED) {
8711 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8712 if (filp || (flags & MAP_SHARED))
8713 do_colour_align = 1;
8714
8715 +#ifdef CONFIG_PAX_RANDMMAP
8716 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8717 +#endif
8718 +
8719 if (addr) {
8720 if (do_colour_align)
8721 addr = COLOUR_ALIGN(addr, pgoff);
8722 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8723 addr = PAGE_ALIGN(addr);
8724
8725 vma = find_vma(mm, addr);
8726 - if (TASK_SIZE - len >= addr &&
8727 - (!vma || addr + len <= vma->vm_start))
8728 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8729 return addr;
8730 }
8731
8732 info.flags = 0;
8733 info.length = len;
8734 - info.low_limit = TASK_UNMAPPED_BASE;
8735 + info.low_limit = mm->mmap_base;
8736 info.high_limit = TASK_SIZE;
8737 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8738 info.align_offset = pgoff << PAGE_SHIFT;
8739 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8740 struct mm_struct *mm = current->mm;
8741 unsigned long addr = addr0;
8742 int do_colour_align;
8743 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8744 struct vm_unmapped_area_info info;
8745
8746 if (flags & MAP_FIXED) {
8747 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8748 if (filp || (flags & MAP_SHARED))
8749 do_colour_align = 1;
8750
8751 +#ifdef CONFIG_PAX_RANDMMAP
8752 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8753 +#endif
8754 +
8755 /* requesting a specific address */
8756 if (addr) {
8757 if (do_colour_align)
8758 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8759 addr = PAGE_ALIGN(addr);
8760
8761 vma = find_vma(mm, addr);
8762 - if (TASK_SIZE - len >= addr &&
8763 - (!vma || addr + len <= vma->vm_start))
8764 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8765 return addr;
8766 }
8767
8768 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8769 VM_BUG_ON(addr != -ENOMEM);
8770 info.flags = 0;
8771 info.low_limit = TASK_UNMAPPED_BASE;
8772 +
8773 +#ifdef CONFIG_PAX_RANDMMAP
8774 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8775 + info.low_limit += mm->delta_mmap;
8776 +#endif
8777 +
8778 info.high_limit = TASK_SIZE;
8779 addr = vm_unmapped_area(&info);
8780 }
8781 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8782 index be56a24..443328f 100644
8783 --- a/arch/sparc/include/asm/atomic_64.h
8784 +++ b/arch/sparc/include/asm/atomic_64.h
8785 @@ -14,18 +14,40 @@
8786 #define ATOMIC64_INIT(i) { (i) }
8787
8788 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8789 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8790 +{
8791 + return v->counter;
8792 +}
8793 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8794 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8795 +{
8796 + return v->counter;
8797 +}
8798
8799 #define atomic_set(v, i) (((v)->counter) = i)
8800 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8801 +{
8802 + v->counter = i;
8803 +}
8804 #define atomic64_set(v, i) (((v)->counter) = i)
8805 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8806 +{
8807 + v->counter = i;
8808 +}
8809
8810 extern void atomic_add(int, atomic_t *);
8811 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8812 extern void atomic64_add(long, atomic64_t *);
8813 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8814 extern void atomic_sub(int, atomic_t *);
8815 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8816 extern void atomic64_sub(long, atomic64_t *);
8817 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8818
8819 extern int atomic_add_ret(int, atomic_t *);
8820 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8821 extern long atomic64_add_ret(long, atomic64_t *);
8822 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8823 extern int atomic_sub_ret(int, atomic_t *);
8824 extern long atomic64_sub_ret(long, atomic64_t *);
8825
8826 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8827 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8828
8829 #define atomic_inc_return(v) atomic_add_ret(1, v)
8830 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8831 +{
8832 + return atomic_add_ret_unchecked(1, v);
8833 +}
8834 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8835 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8836 +{
8837 + return atomic64_add_ret_unchecked(1, v);
8838 +}
8839
8840 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8841 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8842
8843 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8844 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8845 +{
8846 + return atomic_add_ret_unchecked(i, v);
8847 +}
8848 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8849 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8850 +{
8851 + return atomic64_add_ret_unchecked(i, v);
8852 +}
8853
8854 /*
8855 * atomic_inc_and_test - increment and test
8856 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8857 * other cases.
8858 */
8859 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8860 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8861 +{
8862 + return atomic_inc_return_unchecked(v) == 0;
8863 +}
8864 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8865
8866 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8867 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8868 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8869
8870 #define atomic_inc(v) atomic_add(1, v)
8871 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8872 +{
8873 + atomic_add_unchecked(1, v);
8874 +}
8875 #define atomic64_inc(v) atomic64_add(1, v)
8876 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8877 +{
8878 + atomic64_add_unchecked(1, v);
8879 +}
8880
8881 #define atomic_dec(v) atomic_sub(1, v)
8882 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8883 +{
8884 + atomic_sub_unchecked(1, v);
8885 +}
8886 #define atomic64_dec(v) atomic64_sub(1, v)
8887 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8888 +{
8889 + atomic64_sub_unchecked(1, v);
8890 +}
8891
8892 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8893 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8894
8895 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8896 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8897 +{
8898 + return cmpxchg(&v->counter, old, new);
8899 +}
8900 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8901 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8902 +{
8903 + return xchg(&v->counter, new);
8904 +}
8905
8906 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8907 {
8908 - int c, old;
8909 + int c, old, new;
8910 c = atomic_read(v);
8911 for (;;) {
8912 - if (unlikely(c == (u)))
8913 + if (unlikely(c == u))
8914 break;
8915 - old = atomic_cmpxchg((v), c, c + (a));
8916 +
8917 + asm volatile("addcc %2, %0, %0\n"
8918 +
8919 +#ifdef CONFIG_PAX_REFCOUNT
8920 + "tvs %%icc, 6\n"
8921 +#endif
8922 +
8923 + : "=r" (new)
8924 + : "0" (c), "ir" (a)
8925 + : "cc");
8926 +
8927 + old = atomic_cmpxchg(v, c, new);
8928 if (likely(old == c))
8929 break;
8930 c = old;
8931 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8932 #define atomic64_cmpxchg(v, o, n) \
8933 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8934 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8935 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8936 +{
8937 + return xchg(&v->counter, new);
8938 +}
8939
8940 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8941 {
8942 - long c, old;
8943 + long c, old, new;
8944 c = atomic64_read(v);
8945 for (;;) {
8946 - if (unlikely(c == (u)))
8947 + if (unlikely(c == u))
8948 break;
8949 - old = atomic64_cmpxchg((v), c, c + (a));
8950 +
8951 + asm volatile("addcc %2, %0, %0\n"
8952 +
8953 +#ifdef CONFIG_PAX_REFCOUNT
8954 + "tvs %%xcc, 6\n"
8955 +#endif
8956 +
8957 + : "=r" (new)
8958 + : "0" (c), "ir" (a)
8959 + : "cc");
8960 +
8961 + old = atomic64_cmpxchg(v, c, new);
8962 if (likely(old == c))
8963 break;
8964 c = old;
8965 }
8966 - return c != (u);
8967 + return c != u;
8968 }
8969
8970 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8971 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8972 index 5bb6991..5c2132e 100644
8973 --- a/arch/sparc/include/asm/cache.h
8974 +++ b/arch/sparc/include/asm/cache.h
8975 @@ -7,10 +7,12 @@
8976 #ifndef _SPARC_CACHE_H
8977 #define _SPARC_CACHE_H
8978
8979 +#include <linux/const.h>
8980 +
8981 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8982
8983 #define L1_CACHE_SHIFT 5
8984 -#define L1_CACHE_BYTES 32
8985 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8986
8987 #ifdef CONFIG_SPARC32
8988 #define SMP_CACHE_BYTES_SHIFT 5
8989 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8990 index a24e41f..47677ff 100644
8991 --- a/arch/sparc/include/asm/elf_32.h
8992 +++ b/arch/sparc/include/asm/elf_32.h
8993 @@ -114,6 +114,13 @@ typedef struct {
8994
8995 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8996
8997 +#ifdef CONFIG_PAX_ASLR
8998 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8999 +
9000 +#define PAX_DELTA_MMAP_LEN 16
9001 +#define PAX_DELTA_STACK_LEN 16
9002 +#endif
9003 +
9004 /* This yields a mask that user programs can use to figure out what
9005 instruction set this cpu supports. This can NOT be done in userspace
9006 on Sparc. */
9007 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9008 index 370ca1e..d4f4a98 100644
9009 --- a/arch/sparc/include/asm/elf_64.h
9010 +++ b/arch/sparc/include/asm/elf_64.h
9011 @@ -189,6 +189,13 @@ typedef struct {
9012 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9013 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9014
9015 +#ifdef CONFIG_PAX_ASLR
9016 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9017 +
9018 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9019 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9020 +#endif
9021 +
9022 extern unsigned long sparc64_elf_hwcap;
9023 #define ELF_HWCAP sparc64_elf_hwcap
9024
9025 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9026 index 9b1c36d..209298b 100644
9027 --- a/arch/sparc/include/asm/pgalloc_32.h
9028 +++ b/arch/sparc/include/asm/pgalloc_32.h
9029 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9030 }
9031
9032 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9033 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9034
9035 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9036 unsigned long address)
9037 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9038 index bcfe063..b333142 100644
9039 --- a/arch/sparc/include/asm/pgalloc_64.h
9040 +++ b/arch/sparc/include/asm/pgalloc_64.h
9041 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9042 }
9043
9044 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9045 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9046
9047 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9048 {
9049 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9050 index 502f632..da1917f 100644
9051 --- a/arch/sparc/include/asm/pgtable_32.h
9052 +++ b/arch/sparc/include/asm/pgtable_32.h
9053 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9054 #define PAGE_SHARED SRMMU_PAGE_SHARED
9055 #define PAGE_COPY SRMMU_PAGE_COPY
9056 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9057 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9058 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9059 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9060 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9061
9062 /* Top-level page directory - dummy used by init-mm.
9063 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9064
9065 /* xwr */
9066 #define __P000 PAGE_NONE
9067 -#define __P001 PAGE_READONLY
9068 -#define __P010 PAGE_COPY
9069 -#define __P011 PAGE_COPY
9070 +#define __P001 PAGE_READONLY_NOEXEC
9071 +#define __P010 PAGE_COPY_NOEXEC
9072 +#define __P011 PAGE_COPY_NOEXEC
9073 #define __P100 PAGE_READONLY
9074 #define __P101 PAGE_READONLY
9075 #define __P110 PAGE_COPY
9076 #define __P111 PAGE_COPY
9077
9078 #define __S000 PAGE_NONE
9079 -#define __S001 PAGE_READONLY
9080 -#define __S010 PAGE_SHARED
9081 -#define __S011 PAGE_SHARED
9082 +#define __S001 PAGE_READONLY_NOEXEC
9083 +#define __S010 PAGE_SHARED_NOEXEC
9084 +#define __S011 PAGE_SHARED_NOEXEC
9085 #define __S100 PAGE_READONLY
9086 #define __S101 PAGE_READONLY
9087 #define __S110 PAGE_SHARED
9088 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9089 index 79da178..c2eede8 100644
9090 --- a/arch/sparc/include/asm/pgtsrmmu.h
9091 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9092 @@ -115,6 +115,11 @@
9093 SRMMU_EXEC | SRMMU_REF)
9094 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9095 SRMMU_EXEC | SRMMU_REF)
9096 +
9097 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9098 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9099 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9100 +
9101 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9102 SRMMU_DIRTY | SRMMU_REF)
9103
9104 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9105 index 9689176..63c18ea 100644
9106 --- a/arch/sparc/include/asm/spinlock_64.h
9107 +++ b/arch/sparc/include/asm/spinlock_64.h
9108 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9109
9110 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9111
9112 -static void inline arch_read_lock(arch_rwlock_t *lock)
9113 +static inline void arch_read_lock(arch_rwlock_t *lock)
9114 {
9115 unsigned long tmp1, tmp2;
9116
9117 __asm__ __volatile__ (
9118 "1: ldsw [%2], %0\n"
9119 " brlz,pn %0, 2f\n"
9120 -"4: add %0, 1, %1\n"
9121 +"4: addcc %0, 1, %1\n"
9122 +
9123 +#ifdef CONFIG_PAX_REFCOUNT
9124 +" tvs %%icc, 6\n"
9125 +#endif
9126 +
9127 " cas [%2], %0, %1\n"
9128 " cmp %0, %1\n"
9129 " bne,pn %%icc, 1b\n"
9130 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9131 " .previous"
9132 : "=&r" (tmp1), "=&r" (tmp2)
9133 : "r" (lock)
9134 - : "memory");
9135 + : "memory", "cc");
9136 }
9137
9138 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9139 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9140 {
9141 int tmp1, tmp2;
9142
9143 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9144 "1: ldsw [%2], %0\n"
9145 " brlz,a,pn %0, 2f\n"
9146 " mov 0, %0\n"
9147 -" add %0, 1, %1\n"
9148 +" addcc %0, 1, %1\n"
9149 +
9150 +#ifdef CONFIG_PAX_REFCOUNT
9151 +" tvs %%icc, 6\n"
9152 +#endif
9153 +
9154 " cas [%2], %0, %1\n"
9155 " cmp %0, %1\n"
9156 " bne,pn %%icc, 1b\n"
9157 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9158 return tmp1;
9159 }
9160
9161 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9162 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9163 {
9164 unsigned long tmp1, tmp2;
9165
9166 __asm__ __volatile__(
9167 "1: lduw [%2], %0\n"
9168 -" sub %0, 1, %1\n"
9169 +" subcc %0, 1, %1\n"
9170 +
9171 +#ifdef CONFIG_PAX_REFCOUNT
9172 +" tvs %%icc, 6\n"
9173 +#endif
9174 +
9175 " cas [%2], %0, %1\n"
9176 " cmp %0, %1\n"
9177 " bne,pn %%xcc, 1b\n"
9178 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9179 : "memory");
9180 }
9181
9182 -static void inline arch_write_lock(arch_rwlock_t *lock)
9183 +static inline void arch_write_lock(arch_rwlock_t *lock)
9184 {
9185 unsigned long mask, tmp1, tmp2;
9186
9187 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9188 : "memory");
9189 }
9190
9191 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9192 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9193 {
9194 __asm__ __volatile__(
9195 " stw %%g0, [%0]"
9196 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9197 : "memory");
9198 }
9199
9200 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9201 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9202 {
9203 unsigned long mask, tmp1, tmp2, result;
9204
9205 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9206 index dd38075..e7cac83 100644
9207 --- a/arch/sparc/include/asm/thread_info_32.h
9208 +++ b/arch/sparc/include/asm/thread_info_32.h
9209 @@ -49,6 +49,8 @@ struct thread_info {
9210 unsigned long w_saved;
9211
9212 struct restart_block restart_block;
9213 +
9214 + unsigned long lowest_stack;
9215 };
9216
9217 /*
9218 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9219 index d5e5042..9bfee76 100644
9220 --- a/arch/sparc/include/asm/thread_info_64.h
9221 +++ b/arch/sparc/include/asm/thread_info_64.h
9222 @@ -63,6 +63,8 @@ struct thread_info {
9223 struct pt_regs *kern_una_regs;
9224 unsigned int kern_una_insn;
9225
9226 + unsigned long lowest_stack;
9227 +
9228 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9229 };
9230
9231 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9232 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9233 /* flag bit 6 is available */
9234 #define TIF_32BIT 7 /* 32-bit binary */
9235 -/* flag bit 8 is available */
9236 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9237 #define TIF_SECCOMP 9 /* secure computing */
9238 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9239 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9240 +
9241 /* NOTE: Thread flags >= 12 should be ones we have no interest
9242 * in using in assembly, else we can't use the mask as
9243 * an immediate value in instructions such as andcc.
9244 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9245 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9246 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9247 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9248 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9249
9250 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9251 _TIF_DO_NOTIFY_RESUME_MASK | \
9252 _TIF_NEED_RESCHED)
9253 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9254
9255 +#define _TIF_WORK_SYSCALL \
9256 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9257 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9258 +
9259 +
9260 /*
9261 * Thread-synchronous status.
9262 *
9263 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9264 index 0167d26..767bb0c 100644
9265 --- a/arch/sparc/include/asm/uaccess.h
9266 +++ b/arch/sparc/include/asm/uaccess.h
9267 @@ -1,5 +1,6 @@
9268 #ifndef ___ASM_SPARC_UACCESS_H
9269 #define ___ASM_SPARC_UACCESS_H
9270 +
9271 #if defined(__sparc__) && defined(__arch64__)
9272 #include <asm/uaccess_64.h>
9273 #else
9274 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9275 index 53a28dd..50c38c3 100644
9276 --- a/arch/sparc/include/asm/uaccess_32.h
9277 +++ b/arch/sparc/include/asm/uaccess_32.h
9278 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9279
9280 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9281 {
9282 - if (n && __access_ok((unsigned long) to, n))
9283 + if ((long)n < 0)
9284 + return n;
9285 +
9286 + if (n && __access_ok((unsigned long) to, n)) {
9287 + if (!__builtin_constant_p(n))
9288 + check_object_size(from, n, true);
9289 return __copy_user(to, (__force void __user *) from, n);
9290 - else
9291 + } else
9292 return n;
9293 }
9294
9295 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9296 {
9297 + if ((long)n < 0)
9298 + return n;
9299 +
9300 + if (!__builtin_constant_p(n))
9301 + check_object_size(from, n, true);
9302 +
9303 return __copy_user(to, (__force void __user *) from, n);
9304 }
9305
9306 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9307 {
9308 - if (n && __access_ok((unsigned long) from, n))
9309 + if ((long)n < 0)
9310 + return n;
9311 +
9312 + if (n && __access_ok((unsigned long) from, n)) {
9313 + if (!__builtin_constant_p(n))
9314 + check_object_size(to, n, false);
9315 return __copy_user((__force void __user *) to, from, n);
9316 - else
9317 + } else
9318 return n;
9319 }
9320
9321 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9322 {
9323 + if ((long)n < 0)
9324 + return n;
9325 +
9326 return __copy_user((__force void __user *) to, from, n);
9327 }
9328
9329 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9330 index e562d3c..191f176 100644
9331 --- a/arch/sparc/include/asm/uaccess_64.h
9332 +++ b/arch/sparc/include/asm/uaccess_64.h
9333 @@ -10,6 +10,7 @@
9334 #include <linux/compiler.h>
9335 #include <linux/string.h>
9336 #include <linux/thread_info.h>
9337 +#include <linux/kernel.h>
9338 #include <asm/asi.h>
9339 #include <asm/spitfire.h>
9340 #include <asm-generic/uaccess-unaligned.h>
9341 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9342 static inline unsigned long __must_check
9343 copy_from_user(void *to, const void __user *from, unsigned long size)
9344 {
9345 - unsigned long ret = ___copy_from_user(to, from, size);
9346 + unsigned long ret;
9347
9348 + if ((long)size < 0 || size > INT_MAX)
9349 + return size;
9350 +
9351 + if (!__builtin_constant_p(size))
9352 + check_object_size(to, size, false);
9353 +
9354 + ret = ___copy_from_user(to, from, size);
9355 if (unlikely(ret))
9356 ret = copy_from_user_fixup(to, from, size);
9357
9358 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9359 static inline unsigned long __must_check
9360 copy_to_user(void __user *to, const void *from, unsigned long size)
9361 {
9362 - unsigned long ret = ___copy_to_user(to, from, size);
9363 + unsigned long ret;
9364
9365 + if ((long)size < 0 || size > INT_MAX)
9366 + return size;
9367 +
9368 + if (!__builtin_constant_p(size))
9369 + check_object_size(from, size, true);
9370 +
9371 + ret = ___copy_to_user(to, from, size);
9372 if (unlikely(ret))
9373 ret = copy_to_user_fixup(to, from, size);
9374 return ret;
9375 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9376 index d432fb2..6056af1 100644
9377 --- a/arch/sparc/kernel/Makefile
9378 +++ b/arch/sparc/kernel/Makefile
9379 @@ -3,7 +3,7 @@
9380 #
9381
9382 asflags-y := -ansi
9383 -ccflags-y := -Werror
9384 +#ccflags-y := -Werror
9385
9386 extra-y := head_$(BITS).o
9387
9388 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9389 index fdd819d..5af08c8 100644
9390 --- a/arch/sparc/kernel/process_32.c
9391 +++ b/arch/sparc/kernel/process_32.c
9392 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9393
9394 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9395 r->psr, r->pc, r->npc, r->y, print_tainted());
9396 - printk("PC: <%pS>\n", (void *) r->pc);
9397 + printk("PC: <%pA>\n", (void *) r->pc);
9398 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9399 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9400 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9401 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9402 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9403 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9404 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9405 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9406
9407 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9408 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9409 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9410 rw = (struct reg_window32 *) fp;
9411 pc = rw->ins[7];
9412 printk("[%08lx : ", pc);
9413 - printk("%pS ] ", (void *) pc);
9414 + printk("%pA ] ", (void *) pc);
9415 fp = rw->ins[6];
9416 } while (++count < 16);
9417 printk("\n");
9418 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9419 index baebab2..9cd13b1 100644
9420 --- a/arch/sparc/kernel/process_64.c
9421 +++ b/arch/sparc/kernel/process_64.c
9422 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9423 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9424 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9425 if (regs->tstate & TSTATE_PRIV)
9426 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9427 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9428 }
9429
9430 void show_regs(struct pt_regs *regs)
9431 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9432
9433 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9434 regs->tpc, regs->tnpc, regs->y, print_tainted());
9435 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9436 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9437 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9438 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9439 regs->u_regs[3]);
9440 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9441 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9442 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9443 regs->u_regs[15]);
9444 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9445 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9446 show_regwindow(regs);
9447 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9448 }
9449 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9450 ((tp && tp->task) ? tp->task->pid : -1));
9451
9452 if (gp->tstate & TSTATE_PRIV) {
9453 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9454 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9455 (void *) gp->tpc,
9456 (void *) gp->o7,
9457 (void *) gp->i7,
9458 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9459 index 79cc0d1..ec62734 100644
9460 --- a/arch/sparc/kernel/prom_common.c
9461 +++ b/arch/sparc/kernel/prom_common.c
9462 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9463
9464 unsigned int prom_early_allocated __initdata;
9465
9466 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9467 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9468 .nextprop = prom_common_nextprop,
9469 .getproplen = prom_getproplen,
9470 .getproperty = prom_getproperty,
9471 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9472 index 7ff45e4..a58f271 100644
9473 --- a/arch/sparc/kernel/ptrace_64.c
9474 +++ b/arch/sparc/kernel/ptrace_64.c
9475 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9476 return ret;
9477 }
9478
9479 +#ifdef CONFIG_GRKERNSEC_SETXID
9480 +extern void gr_delayed_cred_worker(void);
9481 +#endif
9482 +
9483 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9484 {
9485 int ret = 0;
9486 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9487 /* do the secure computing check first */
9488 secure_computing_strict(regs->u_regs[UREG_G1]);
9489
9490 +#ifdef CONFIG_GRKERNSEC_SETXID
9491 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9492 + gr_delayed_cred_worker();
9493 +#endif
9494 +
9495 if (test_thread_flag(TIF_SYSCALL_TRACE))
9496 ret = tracehook_report_syscall_entry(regs);
9497
9498 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9499
9500 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9501 {
9502 +#ifdef CONFIG_GRKERNSEC_SETXID
9503 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9504 + gr_delayed_cred_worker();
9505 +#endif
9506 +
9507 audit_syscall_exit(regs);
9508
9509 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9510 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9511 index e142545..fd29654 100644
9512 --- a/arch/sparc/kernel/smp_64.c
9513 +++ b/arch/sparc/kernel/smp_64.c
9514 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9515 extern unsigned long xcall_flush_dcache_page_spitfire;
9516
9517 #ifdef CONFIG_DEBUG_DCFLUSH
9518 -extern atomic_t dcpage_flushes;
9519 -extern atomic_t dcpage_flushes_xcall;
9520 +extern atomic_unchecked_t dcpage_flushes;
9521 +extern atomic_unchecked_t dcpage_flushes_xcall;
9522 #endif
9523
9524 static inline void __local_flush_dcache_page(struct page *page)
9525 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9526 return;
9527
9528 #ifdef CONFIG_DEBUG_DCFLUSH
9529 - atomic_inc(&dcpage_flushes);
9530 + atomic_inc_unchecked(&dcpage_flushes);
9531 #endif
9532
9533 this_cpu = get_cpu();
9534 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9535 xcall_deliver(data0, __pa(pg_addr),
9536 (u64) pg_addr, cpumask_of(cpu));
9537 #ifdef CONFIG_DEBUG_DCFLUSH
9538 - atomic_inc(&dcpage_flushes_xcall);
9539 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9540 #endif
9541 }
9542 }
9543 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9544 preempt_disable();
9545
9546 #ifdef CONFIG_DEBUG_DCFLUSH
9547 - atomic_inc(&dcpage_flushes);
9548 + atomic_inc_unchecked(&dcpage_flushes);
9549 #endif
9550 data0 = 0;
9551 pg_addr = page_address(page);
9552 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9553 xcall_deliver(data0, __pa(pg_addr),
9554 (u64) pg_addr, cpu_online_mask);
9555 #ifdef CONFIG_DEBUG_DCFLUSH
9556 - atomic_inc(&dcpage_flushes_xcall);
9557 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9558 #endif
9559 }
9560 __local_flush_dcache_page(page);
9561 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9562 index 3a8d184..49498a8 100644
9563 --- a/arch/sparc/kernel/sys_sparc_32.c
9564 +++ b/arch/sparc/kernel/sys_sparc_32.c
9565 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9566 if (len > TASK_SIZE - PAGE_SIZE)
9567 return -ENOMEM;
9568 if (!addr)
9569 - addr = TASK_UNMAPPED_BASE;
9570 + addr = current->mm->mmap_base;
9571
9572 info.flags = 0;
9573 info.length = len;
9574 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9575 index 51561b8..8256764 100644
9576 --- a/arch/sparc/kernel/sys_sparc_64.c
9577 +++ b/arch/sparc/kernel/sys_sparc_64.c
9578 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9579 struct vm_area_struct * vma;
9580 unsigned long task_size = TASK_SIZE;
9581 int do_color_align;
9582 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9583 struct vm_unmapped_area_info info;
9584
9585 if (flags & MAP_FIXED) {
9586 /* We do not accept a shared mapping if it would violate
9587 * cache aliasing constraints.
9588 */
9589 - if ((flags & MAP_SHARED) &&
9590 + if ((filp || (flags & MAP_SHARED)) &&
9591 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9592 return -EINVAL;
9593 return addr;
9594 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9595 if (filp || (flags & MAP_SHARED))
9596 do_color_align = 1;
9597
9598 +#ifdef CONFIG_PAX_RANDMMAP
9599 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9600 +#endif
9601 +
9602 if (addr) {
9603 if (do_color_align)
9604 addr = COLOR_ALIGN(addr, pgoff);
9605 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9606 addr = PAGE_ALIGN(addr);
9607
9608 vma = find_vma(mm, addr);
9609 - if (task_size - len >= addr &&
9610 - (!vma || addr + len <= vma->vm_start))
9611 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9612 return addr;
9613 }
9614
9615 info.flags = 0;
9616 info.length = len;
9617 - info.low_limit = TASK_UNMAPPED_BASE;
9618 + info.low_limit = mm->mmap_base;
9619 info.high_limit = min(task_size, VA_EXCLUDE_START);
9620 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9621 info.align_offset = pgoff << PAGE_SHIFT;
9622 + info.threadstack_offset = offset;
9623 addr = vm_unmapped_area(&info);
9624
9625 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9626 VM_BUG_ON(addr != -ENOMEM);
9627 info.low_limit = VA_EXCLUDE_END;
9628 +
9629 +#ifdef CONFIG_PAX_RANDMMAP
9630 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9631 + info.low_limit += mm->delta_mmap;
9632 +#endif
9633 +
9634 info.high_limit = task_size;
9635 addr = vm_unmapped_area(&info);
9636 }
9637 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9638 unsigned long task_size = STACK_TOP32;
9639 unsigned long addr = addr0;
9640 int do_color_align;
9641 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9642 struct vm_unmapped_area_info info;
9643
9644 /* This should only ever run for 32-bit processes. */
9645 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9646 /* We do not accept a shared mapping if it would violate
9647 * cache aliasing constraints.
9648 */
9649 - if ((flags & MAP_SHARED) &&
9650 + if ((filp || (flags & MAP_SHARED)) &&
9651 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9652 return -EINVAL;
9653 return addr;
9654 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9655 if (filp || (flags & MAP_SHARED))
9656 do_color_align = 1;
9657
9658 +#ifdef CONFIG_PAX_RANDMMAP
9659 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9660 +#endif
9661 +
9662 /* requesting a specific address */
9663 if (addr) {
9664 if (do_color_align)
9665 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9666 addr = PAGE_ALIGN(addr);
9667
9668 vma = find_vma(mm, addr);
9669 - if (task_size - len >= addr &&
9670 - (!vma || addr + len <= vma->vm_start))
9671 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9672 return addr;
9673 }
9674
9675 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9676 info.high_limit = mm->mmap_base;
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 /*
9683 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9684 VM_BUG_ON(addr != -ENOMEM);
9685 info.flags = 0;
9686 info.low_limit = TASK_UNMAPPED_BASE;
9687 +
9688 +#ifdef CONFIG_PAX_RANDMMAP
9689 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9690 + info.low_limit += mm->delta_mmap;
9691 +#endif
9692 +
9693 info.high_limit = STACK_TOP32;
9694 addr = vm_unmapped_area(&info);
9695 }
9696 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9697 EXPORT_SYMBOL(get_fb_unmapped_area);
9698
9699 /* Essentially the same as PowerPC. */
9700 -static unsigned long mmap_rnd(void)
9701 +static unsigned long mmap_rnd(struct mm_struct *mm)
9702 {
9703 unsigned long rnd = 0UL;
9704
9705 +#ifdef CONFIG_PAX_RANDMMAP
9706 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9707 +#endif
9708 +
9709 if (current->flags & PF_RANDOMIZE) {
9710 unsigned long val = get_random_int();
9711 if (test_thread_flag(TIF_32BIT))
9712 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9713
9714 void arch_pick_mmap_layout(struct mm_struct *mm)
9715 {
9716 - unsigned long random_factor = mmap_rnd();
9717 + unsigned long random_factor = mmap_rnd(mm);
9718 unsigned long gap;
9719
9720 /*
9721 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9722 gap == RLIM_INFINITY ||
9723 sysctl_legacy_va_layout) {
9724 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9725 +
9726 +#ifdef CONFIG_PAX_RANDMMAP
9727 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9728 + mm->mmap_base += mm->delta_mmap;
9729 +#endif
9730 +
9731 mm->get_unmapped_area = arch_get_unmapped_area;
9732 } else {
9733 /* We know it's 32-bit */
9734 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9735 gap = (task_size / 6 * 5);
9736
9737 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9738 +
9739 +#ifdef CONFIG_PAX_RANDMMAP
9740 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9741 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9742 +#endif
9743 +
9744 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9745 }
9746 }
9747 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9748 index 22a1098..6255eb9 100644
9749 --- a/arch/sparc/kernel/syscalls.S
9750 +++ b/arch/sparc/kernel/syscalls.S
9751 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9752 #endif
9753 .align 32
9754 1: ldx [%g6 + TI_FLAGS], %l5
9755 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9756 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9757 be,pt %icc, rtrap
9758 nop
9759 call syscall_trace_leave
9760 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9761
9762 srl %i5, 0, %o5 ! IEU1
9763 srl %i2, 0, %o2 ! IEU0 Group
9764 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9765 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9766 bne,pn %icc, linux_syscall_trace32 ! CTI
9767 mov %i0, %l5 ! IEU1
9768 call %l7 ! CTI Group brk forced
9769 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9770
9771 mov %i3, %o3 ! IEU1
9772 mov %i4, %o4 ! IEU0 Group
9773 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9774 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9775 bne,pn %icc, linux_syscall_trace ! CTI Group
9776 mov %i0, %l5 ! IEU0
9777 2: call %l7 ! CTI Group brk forced
9778 @@ -223,7 +223,7 @@ ret_sys_call:
9779
9780 cmp %o0, -ERESTART_RESTARTBLOCK
9781 bgeu,pn %xcc, 1f
9782 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9783 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9784 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9785
9786 2:
9787 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9788 index 6629829..036032d 100644
9789 --- a/arch/sparc/kernel/traps_32.c
9790 +++ b/arch/sparc/kernel/traps_32.c
9791 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9792 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9793 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9794
9795 +extern void gr_handle_kernel_exploit(void);
9796 +
9797 void die_if_kernel(char *str, struct pt_regs *regs)
9798 {
9799 static int die_counter;
9800 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9801 count++ < 30 &&
9802 (((unsigned long) rw) >= PAGE_OFFSET) &&
9803 !(((unsigned long) rw) & 0x7)) {
9804 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9805 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9806 (void *) rw->ins[7]);
9807 rw = (struct reg_window32 *)rw->ins[6];
9808 }
9809 }
9810 printk("Instruction DUMP:");
9811 instruction_dump ((unsigned long *) regs->pc);
9812 - if(regs->psr & PSR_PS)
9813 + if(regs->psr & PSR_PS) {
9814 + gr_handle_kernel_exploit();
9815 do_exit(SIGKILL);
9816 + }
9817 do_exit(SIGSEGV);
9818 }
9819
9820 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9821 index b3f833a..f485f80 100644
9822 --- a/arch/sparc/kernel/traps_64.c
9823 +++ b/arch/sparc/kernel/traps_64.c
9824 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9825 i + 1,
9826 p->trapstack[i].tstate, p->trapstack[i].tpc,
9827 p->trapstack[i].tnpc, p->trapstack[i].tt);
9828 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9829 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9830 }
9831 }
9832
9833 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9834
9835 lvl -= 0x100;
9836 if (regs->tstate & TSTATE_PRIV) {
9837 +
9838 +#ifdef CONFIG_PAX_REFCOUNT
9839 + if (lvl == 6)
9840 + pax_report_refcount_overflow(regs);
9841 +#endif
9842 +
9843 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9844 die_if_kernel(buffer, regs);
9845 }
9846 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9847 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9848 {
9849 char buffer[32];
9850 -
9851 +
9852 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9853 0, lvl, SIGTRAP) == NOTIFY_STOP)
9854 return;
9855
9856 +#ifdef CONFIG_PAX_REFCOUNT
9857 + if (lvl == 6)
9858 + pax_report_refcount_overflow(regs);
9859 +#endif
9860 +
9861 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9862
9863 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9864 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9865 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9866 printk("%s" "ERROR(%d): ",
9867 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9868 - printk("TPC<%pS>\n", (void *) regs->tpc);
9869 + printk("TPC<%pA>\n", (void *) regs->tpc);
9870 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9871 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9872 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9873 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9874 smp_processor_id(),
9875 (type & 0x1) ? 'I' : 'D',
9876 regs->tpc);
9877 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9878 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9879 panic("Irrecoverable Cheetah+ parity error.");
9880 }
9881
9882 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9883 smp_processor_id(),
9884 (type & 0x1) ? 'I' : 'D',
9885 regs->tpc);
9886 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9887 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9888 }
9889
9890 struct sun4v_error_entry {
9891 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9892 /*0x38*/u64 reserved_5;
9893 };
9894
9895 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9896 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9897 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9898 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9899
9900 static const char *sun4v_err_type_to_str(u8 type)
9901 {
9902 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9903 }
9904
9905 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9906 - int cpu, const char *pfx, atomic_t *ocnt)
9907 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9908 {
9909 u64 *raw_ptr = (u64 *) ent;
9910 u32 attrs;
9911 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9912
9913 show_regs(regs);
9914
9915 - if ((cnt = atomic_read(ocnt)) != 0) {
9916 - atomic_set(ocnt, 0);
9917 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9918 + atomic_set_unchecked(ocnt, 0);
9919 wmb();
9920 printk("%s: Queue overflowed %d times.\n",
9921 pfx, cnt);
9922 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9923 */
9924 void sun4v_resum_overflow(struct pt_regs *regs)
9925 {
9926 - atomic_inc(&sun4v_resum_oflow_cnt);
9927 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
9928 }
9929
9930 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
9931 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
9932 /* XXX Actually even this can make not that much sense. Perhaps
9933 * XXX we should just pull the plug and panic directly from here?
9934 */
9935 - atomic_inc(&sun4v_nonresum_oflow_cnt);
9936 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
9937 }
9938
9939 unsigned long sun4v_err_itlb_vaddr;
9940 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9941
9942 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
9943 regs->tpc, tl);
9944 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
9945 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
9946 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9947 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
9948 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
9949 (void *) regs->u_regs[UREG_I7]);
9950 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
9951 "pte[%lx] error[%lx]\n",
9952 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
9953
9954 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
9955 regs->tpc, tl);
9956 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
9957 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
9958 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9959 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
9960 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
9961 (void *) regs->u_regs[UREG_I7]);
9962 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
9963 "pte[%lx] error[%lx]\n",
9964 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9965 fp = (unsigned long)sf->fp + STACK_BIAS;
9966 }
9967
9968 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9969 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9970 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9971 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9972 int index = tsk->curr_ret_stack;
9973 if (tsk->ret_stack && index >= graph) {
9974 pc = tsk->ret_stack[index - graph].ret;
9975 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9976 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9977 graph++;
9978 }
9979 }
9980 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9981 return (struct reg_window *) (fp + STACK_BIAS);
9982 }
9983
9984 +extern void gr_handle_kernel_exploit(void);
9985 +
9986 void die_if_kernel(char *str, struct pt_regs *regs)
9987 {
9988 static int die_counter;
9989 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9990 while (rw &&
9991 count++ < 30 &&
9992 kstack_valid(tp, (unsigned long) rw)) {
9993 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9994 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9995 (void *) rw->ins[7]);
9996
9997 rw = kernel_stack_up(rw);
9998 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9999 }
10000 user_instruction_dump ((unsigned int __user *) regs->tpc);
10001 }
10002 - if (regs->tstate & TSTATE_PRIV)
10003 + if (regs->tstate & TSTATE_PRIV) {
10004 + gr_handle_kernel_exploit();
10005 do_exit(SIGKILL);
10006 + }
10007 do_exit(SIGSEGV);
10008 }
10009 EXPORT_SYMBOL(die_if_kernel);
10010 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10011 index 8201c25e..072a2a7 100644
10012 --- a/arch/sparc/kernel/unaligned_64.c
10013 +++ b/arch/sparc/kernel/unaligned_64.c
10014 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10015 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10016
10017 if (__ratelimit(&ratelimit)) {
10018 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10019 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10020 regs->tpc, (void *) regs->tpc);
10021 }
10022 }
10023 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10024 index dbe119b..089c7c1 100644
10025 --- a/arch/sparc/lib/Makefile
10026 +++ b/arch/sparc/lib/Makefile
10027 @@ -2,7 +2,7 @@
10028 #
10029
10030 asflags-y := -ansi -DST_DIV0=0x02
10031 -ccflags-y := -Werror
10032 +#ccflags-y := -Werror
10033
10034 lib-$(CONFIG_SPARC32) += ashrdi3.o
10035 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10036 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10037 index 85c233d..68500e0 100644
10038 --- a/arch/sparc/lib/atomic_64.S
10039 +++ b/arch/sparc/lib/atomic_64.S
10040 @@ -17,7 +17,12 @@
10041 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10042 BACKOFF_SETUP(%o2)
10043 1: lduw [%o1], %g1
10044 - add %g1, %o0, %g7
10045 + addcc %g1, %o0, %g7
10046 +
10047 +#ifdef CONFIG_PAX_REFCOUNT
10048 + tvs %icc, 6
10049 +#endif
10050 +
10051 cas [%o1], %g1, %g7
10052 cmp %g1, %g7
10053 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10054 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10055 2: BACKOFF_SPIN(%o2, %o3, 1b)
10056 ENDPROC(atomic_add)
10057
10058 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10059 + BACKOFF_SETUP(%o2)
10060 +1: lduw [%o1], %g1
10061 + add %g1, %o0, %g7
10062 + cas [%o1], %g1, %g7
10063 + cmp %g1, %g7
10064 + bne,pn %icc, 2f
10065 + nop
10066 + retl
10067 + nop
10068 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10069 +ENDPROC(atomic_add_unchecked)
10070 +
10071 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10072 BACKOFF_SETUP(%o2)
10073 1: lduw [%o1], %g1
10074 - sub %g1, %o0, %g7
10075 + subcc %g1, %o0, %g7
10076 +
10077 +#ifdef CONFIG_PAX_REFCOUNT
10078 + tvs %icc, 6
10079 +#endif
10080 +
10081 cas [%o1], %g1, %g7
10082 cmp %g1, %g7
10083 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10084 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10085 2: BACKOFF_SPIN(%o2, %o3, 1b)
10086 ENDPROC(atomic_sub)
10087
10088 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10089 + BACKOFF_SETUP(%o2)
10090 +1: lduw [%o1], %g1
10091 + sub %g1, %o0, %g7
10092 + cas [%o1], %g1, %g7
10093 + cmp %g1, %g7
10094 + bne,pn %icc, 2f
10095 + nop
10096 + retl
10097 + nop
10098 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10099 +ENDPROC(atomic_sub_unchecked)
10100 +
10101 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10102 BACKOFF_SETUP(%o2)
10103 1: lduw [%o1], %g1
10104 - add %g1, %o0, %g7
10105 + addcc %g1, %o0, %g7
10106 +
10107 +#ifdef CONFIG_PAX_REFCOUNT
10108 + tvs %icc, 6
10109 +#endif
10110 +
10111 cas [%o1], %g1, %g7
10112 cmp %g1, %g7
10113 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10114 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10115 2: BACKOFF_SPIN(%o2, %o3, 1b)
10116 ENDPROC(atomic_add_ret)
10117
10118 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10119 + BACKOFF_SETUP(%o2)
10120 +1: lduw [%o1], %g1
10121 + addcc %g1, %o0, %g7
10122 + cas [%o1], %g1, %g7
10123 + cmp %g1, %g7
10124 + bne,pn %icc, 2f
10125 + add %g7, %o0, %g7
10126 + sra %g7, 0, %o0
10127 + retl
10128 + nop
10129 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10130 +ENDPROC(atomic_add_ret_unchecked)
10131 +
10132 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10133 BACKOFF_SETUP(%o2)
10134 1: lduw [%o1], %g1
10135 - sub %g1, %o0, %g7
10136 + subcc %g1, %o0, %g7
10137 +
10138 +#ifdef CONFIG_PAX_REFCOUNT
10139 + tvs %icc, 6
10140 +#endif
10141 +
10142 cas [%o1], %g1, %g7
10143 cmp %g1, %g7
10144 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10145 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10146 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10147 BACKOFF_SETUP(%o2)
10148 1: ldx [%o1], %g1
10149 - add %g1, %o0, %g7
10150 + addcc %g1, %o0, %g7
10151 +
10152 +#ifdef CONFIG_PAX_REFCOUNT
10153 + tvs %xcc, 6
10154 +#endif
10155 +
10156 casx [%o1], %g1, %g7
10157 cmp %g1, %g7
10158 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10159 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10160 2: BACKOFF_SPIN(%o2, %o3, 1b)
10161 ENDPROC(atomic64_add)
10162
10163 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10164 + BACKOFF_SETUP(%o2)
10165 +1: ldx [%o1], %g1
10166 + addcc %g1, %o0, %g7
10167 + casx [%o1], %g1, %g7
10168 + cmp %g1, %g7
10169 + bne,pn %xcc, 2f
10170 + nop
10171 + retl
10172 + nop
10173 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10174 +ENDPROC(atomic64_add_unchecked)
10175 +
10176 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10177 BACKOFF_SETUP(%o2)
10178 1: ldx [%o1], %g1
10179 - sub %g1, %o0, %g7
10180 + subcc %g1, %o0, %g7
10181 +
10182 +#ifdef CONFIG_PAX_REFCOUNT
10183 + tvs %xcc, 6
10184 +#endif
10185 +
10186 casx [%o1], %g1, %g7
10187 cmp %g1, %g7
10188 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10189 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10190 2: BACKOFF_SPIN(%o2, %o3, 1b)
10191 ENDPROC(atomic64_sub)
10192
10193 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10194 + BACKOFF_SETUP(%o2)
10195 +1: ldx [%o1], %g1
10196 + subcc %g1, %o0, %g7
10197 + casx [%o1], %g1, %g7
10198 + cmp %g1, %g7
10199 + bne,pn %xcc, 2f
10200 + nop
10201 + retl
10202 + nop
10203 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10204 +ENDPROC(atomic64_sub_unchecked)
10205 +
10206 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10207 BACKOFF_SETUP(%o2)
10208 1: ldx [%o1], %g1
10209 - add %g1, %o0, %g7
10210 + addcc %g1, %o0, %g7
10211 +
10212 +#ifdef CONFIG_PAX_REFCOUNT
10213 + tvs %xcc, 6
10214 +#endif
10215 +
10216 casx [%o1], %g1, %g7
10217 cmp %g1, %g7
10218 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10219 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10220 2: BACKOFF_SPIN(%o2, %o3, 1b)
10221 ENDPROC(atomic64_add_ret)
10222
10223 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10224 + BACKOFF_SETUP(%o2)
10225 +1: ldx [%o1], %g1
10226 + addcc %g1, %o0, %g7
10227 + casx [%o1], %g1, %g7
10228 + cmp %g1, %g7
10229 + bne,pn %xcc, 2f
10230 + add %g7, %o0, %g7
10231 + mov %g7, %o0
10232 + retl
10233 + nop
10234 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10235 +ENDPROC(atomic64_add_ret_unchecked)
10236 +
10237 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10238 BACKOFF_SETUP(%o2)
10239 1: ldx [%o1], %g1
10240 - sub %g1, %o0, %g7
10241 + subcc %g1, %o0, %g7
10242 +
10243 +#ifdef CONFIG_PAX_REFCOUNT
10244 + tvs %xcc, 6
10245 +#endif
10246 +
10247 casx [%o1], %g1, %g7
10248 cmp %g1, %g7
10249 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10250 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10251 index 0c4e35e..745d3e4 100644
10252 --- a/arch/sparc/lib/ksyms.c
10253 +++ b/arch/sparc/lib/ksyms.c
10254 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
10255
10256 /* Atomic counter implementation. */
10257 EXPORT_SYMBOL(atomic_add);
10258 +EXPORT_SYMBOL(atomic_add_unchecked);
10259 EXPORT_SYMBOL(atomic_add_ret);
10260 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10261 EXPORT_SYMBOL(atomic_sub);
10262 +EXPORT_SYMBOL(atomic_sub_unchecked);
10263 EXPORT_SYMBOL(atomic_sub_ret);
10264 EXPORT_SYMBOL(atomic64_add);
10265 +EXPORT_SYMBOL(atomic64_add_unchecked);
10266 EXPORT_SYMBOL(atomic64_add_ret);
10267 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10268 EXPORT_SYMBOL(atomic64_sub);
10269 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10270 EXPORT_SYMBOL(atomic64_sub_ret);
10271 EXPORT_SYMBOL(atomic64_dec_if_positive);
10272
10273 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10274 index 30c3ecc..736f015 100644
10275 --- a/arch/sparc/mm/Makefile
10276 +++ b/arch/sparc/mm/Makefile
10277 @@ -2,7 +2,7 @@
10278 #
10279
10280 asflags-y := -ansi
10281 -ccflags-y := -Werror
10282 +#ccflags-y := -Werror
10283
10284 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10285 obj-y += fault_$(BITS).o
10286 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10287 index e98bfda..ea8d221 100644
10288 --- a/arch/sparc/mm/fault_32.c
10289 +++ b/arch/sparc/mm/fault_32.c
10290 @@ -21,6 +21,9 @@
10291 #include <linux/perf_event.h>
10292 #include <linux/interrupt.h>
10293 #include <linux/kdebug.h>
10294 +#include <linux/slab.h>
10295 +#include <linux/pagemap.h>
10296 +#include <linux/compiler.h>
10297
10298 #include <asm/page.h>
10299 #include <asm/pgtable.h>
10300 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10301 return safe_compute_effective_address(regs, insn);
10302 }
10303
10304 +#ifdef CONFIG_PAX_PAGEEXEC
10305 +#ifdef CONFIG_PAX_DLRESOLVE
10306 +static void pax_emuplt_close(struct vm_area_struct *vma)
10307 +{
10308 + vma->vm_mm->call_dl_resolve = 0UL;
10309 +}
10310 +
10311 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10312 +{
10313 + unsigned int *kaddr;
10314 +
10315 + vmf->page = alloc_page(GFP_HIGHUSER);
10316 + if (!vmf->page)
10317 + return VM_FAULT_OOM;
10318 +
10319 + kaddr = kmap(vmf->page);
10320 + memset(kaddr, 0, PAGE_SIZE);
10321 + kaddr[0] = 0x9DE3BFA8U; /* save */
10322 + flush_dcache_page(vmf->page);
10323 + kunmap(vmf->page);
10324 + return VM_FAULT_MAJOR;
10325 +}
10326 +
10327 +static const struct vm_operations_struct pax_vm_ops = {
10328 + .close = pax_emuplt_close,
10329 + .fault = pax_emuplt_fault
10330 +};
10331 +
10332 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10333 +{
10334 + int ret;
10335 +
10336 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10337 + vma->vm_mm = current->mm;
10338 + vma->vm_start = addr;
10339 + vma->vm_end = addr + PAGE_SIZE;
10340 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10341 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10342 + vma->vm_ops = &pax_vm_ops;
10343 +
10344 + ret = insert_vm_struct(current->mm, vma);
10345 + if (ret)
10346 + return ret;
10347 +
10348 + ++current->mm->total_vm;
10349 + return 0;
10350 +}
10351 +#endif
10352 +
10353 +/*
10354 + * PaX: decide what to do with offenders (regs->pc = fault address)
10355 + *
10356 + * returns 1 when task should be killed
10357 + * 2 when patched PLT trampoline was detected
10358 + * 3 when unpatched PLT trampoline was detected
10359 + */
10360 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10361 +{
10362 +
10363 +#ifdef CONFIG_PAX_EMUPLT
10364 + int err;
10365 +
10366 + do { /* PaX: patched PLT emulation #1 */
10367 + unsigned int sethi1, sethi2, jmpl;
10368 +
10369 + err = get_user(sethi1, (unsigned int *)regs->pc);
10370 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10371 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10372 +
10373 + if (err)
10374 + break;
10375 +
10376 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10377 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10378 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10379 + {
10380 + unsigned int addr;
10381 +
10382 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10383 + addr = regs->u_regs[UREG_G1];
10384 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10385 + regs->pc = addr;
10386 + regs->npc = addr+4;
10387 + return 2;
10388 + }
10389 + } while (0);
10390 +
10391 + do { /* PaX: patched PLT emulation #2 */
10392 + unsigned int ba;
10393 +
10394 + err = get_user(ba, (unsigned int *)regs->pc);
10395 +
10396 + if (err)
10397 + break;
10398 +
10399 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10400 + unsigned int addr;
10401 +
10402 + if ((ba & 0xFFC00000U) == 0x30800000U)
10403 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10404 + else
10405 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10406 + regs->pc = addr;
10407 + regs->npc = addr+4;
10408 + return 2;
10409 + }
10410 + } while (0);
10411 +
10412 + do { /* PaX: patched PLT emulation #3 */
10413 + unsigned int sethi, bajmpl, nop;
10414 +
10415 + err = get_user(sethi, (unsigned int *)regs->pc);
10416 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10417 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10418 +
10419 + if (err)
10420 + break;
10421 +
10422 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10423 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10424 + nop == 0x01000000U)
10425 + {
10426 + unsigned int addr;
10427 +
10428 + addr = (sethi & 0x003FFFFFU) << 10;
10429 + regs->u_regs[UREG_G1] = addr;
10430 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10431 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10432 + else
10433 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10434 + regs->pc = addr;
10435 + regs->npc = addr+4;
10436 + return 2;
10437 + }
10438 + } while (0);
10439 +
10440 + do { /* PaX: unpatched PLT emulation step 1 */
10441 + unsigned int sethi, ba, nop;
10442 +
10443 + err = get_user(sethi, (unsigned int *)regs->pc);
10444 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10445 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10446 +
10447 + if (err)
10448 + break;
10449 +
10450 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10451 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10452 + nop == 0x01000000U)
10453 + {
10454 + unsigned int addr, save, call;
10455 +
10456 + if ((ba & 0xFFC00000U) == 0x30800000U)
10457 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10458 + else
10459 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10460 +
10461 + err = get_user(save, (unsigned int *)addr);
10462 + err |= get_user(call, (unsigned int *)(addr+4));
10463 + err |= get_user(nop, (unsigned int *)(addr+8));
10464 + if (err)
10465 + break;
10466 +
10467 +#ifdef CONFIG_PAX_DLRESOLVE
10468 + if (save == 0x9DE3BFA8U &&
10469 + (call & 0xC0000000U) == 0x40000000U &&
10470 + nop == 0x01000000U)
10471 + {
10472 + struct vm_area_struct *vma;
10473 + unsigned long call_dl_resolve;
10474 +
10475 + down_read(&current->mm->mmap_sem);
10476 + call_dl_resolve = current->mm->call_dl_resolve;
10477 + up_read(&current->mm->mmap_sem);
10478 + if (likely(call_dl_resolve))
10479 + goto emulate;
10480 +
10481 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10482 +
10483 + down_write(&current->mm->mmap_sem);
10484 + if (current->mm->call_dl_resolve) {
10485 + call_dl_resolve = current->mm->call_dl_resolve;
10486 + up_write(&current->mm->mmap_sem);
10487 + if (vma)
10488 + kmem_cache_free(vm_area_cachep, vma);
10489 + goto emulate;
10490 + }
10491 +
10492 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10493 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10494 + up_write(&current->mm->mmap_sem);
10495 + if (vma)
10496 + kmem_cache_free(vm_area_cachep, vma);
10497 + return 1;
10498 + }
10499 +
10500 + if (pax_insert_vma(vma, call_dl_resolve)) {
10501 + up_write(&current->mm->mmap_sem);
10502 + kmem_cache_free(vm_area_cachep, vma);
10503 + return 1;
10504 + }
10505 +
10506 + current->mm->call_dl_resolve = call_dl_resolve;
10507 + up_write(&current->mm->mmap_sem);
10508 +
10509 +emulate:
10510 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10511 + regs->pc = call_dl_resolve;
10512 + regs->npc = addr+4;
10513 + return 3;
10514 + }
10515 +#endif
10516 +
10517 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10518 + if ((save & 0xFFC00000U) == 0x05000000U &&
10519 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10520 + nop == 0x01000000U)
10521 + {
10522 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10523 + regs->u_regs[UREG_G2] = addr + 4;
10524 + addr = (save & 0x003FFFFFU) << 10;
10525 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10526 + regs->pc = addr;
10527 + regs->npc = addr+4;
10528 + return 3;
10529 + }
10530 + }
10531 + } while (0);
10532 +
10533 + do { /* PaX: unpatched PLT emulation step 2 */
10534 + unsigned int save, call, nop;
10535 +
10536 + err = get_user(save, (unsigned int *)(regs->pc-4));
10537 + err |= get_user(call, (unsigned int *)regs->pc);
10538 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10539 + if (err)
10540 + break;
10541 +
10542 + if (save == 0x9DE3BFA8U &&
10543 + (call & 0xC0000000U) == 0x40000000U &&
10544 + nop == 0x01000000U)
10545 + {
10546 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10547 +
10548 + regs->u_regs[UREG_RETPC] = regs->pc;
10549 + regs->pc = dl_resolve;
10550 + regs->npc = dl_resolve+4;
10551 + return 3;
10552 + }
10553 + } while (0);
10554 +#endif
10555 +
10556 + return 1;
10557 +}
10558 +
10559 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10560 +{
10561 + unsigned long i;
10562 +
10563 + printk(KERN_ERR "PAX: bytes at PC: ");
10564 + for (i = 0; i < 8; i++) {
10565 + unsigned int c;
10566 + if (get_user(c, (unsigned int *)pc+i))
10567 + printk(KERN_CONT "???????? ");
10568 + else
10569 + printk(KERN_CONT "%08x ", c);
10570 + }
10571 + printk("\n");
10572 +}
10573 +#endif
10574 +
10575 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10576 int text_fault)
10577 {
10578 @@ -230,6 +504,24 @@ good_area:
10579 if (!(vma->vm_flags & VM_WRITE))
10580 goto bad_area;
10581 } else {
10582 +
10583 +#ifdef CONFIG_PAX_PAGEEXEC
10584 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10585 + up_read(&mm->mmap_sem);
10586 + switch (pax_handle_fetch_fault(regs)) {
10587 +
10588 +#ifdef CONFIG_PAX_EMUPLT
10589 + case 2:
10590 + case 3:
10591 + return;
10592 +#endif
10593 +
10594 + }
10595 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10596 + do_group_exit(SIGKILL);
10597 + }
10598 +#endif
10599 +
10600 /* Allow reads even for write-only mappings */
10601 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10602 goto bad_area;
10603 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10604 index 5062ff3..e0b75f3 100644
10605 --- a/arch/sparc/mm/fault_64.c
10606 +++ b/arch/sparc/mm/fault_64.c
10607 @@ -21,6 +21,9 @@
10608 #include <linux/kprobes.h>
10609 #include <linux/kdebug.h>
10610 #include <linux/percpu.h>
10611 +#include <linux/slab.h>
10612 +#include <linux/pagemap.h>
10613 +#include <linux/compiler.h>
10614
10615 #include <asm/page.h>
10616 #include <asm/pgtable.h>
10617 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10618 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10619 regs->tpc);
10620 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10621 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10622 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10623 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10624 dump_stack();
10625 unhandled_fault(regs->tpc, current, regs);
10626 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10627 show_regs(regs);
10628 }
10629
10630 +#ifdef CONFIG_PAX_PAGEEXEC
10631 +#ifdef CONFIG_PAX_DLRESOLVE
10632 +static void pax_emuplt_close(struct vm_area_struct *vma)
10633 +{
10634 + vma->vm_mm->call_dl_resolve = 0UL;
10635 +}
10636 +
10637 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10638 +{
10639 + unsigned int *kaddr;
10640 +
10641 + vmf->page = alloc_page(GFP_HIGHUSER);
10642 + if (!vmf->page)
10643 + return VM_FAULT_OOM;
10644 +
10645 + kaddr = kmap(vmf->page);
10646 + memset(kaddr, 0, PAGE_SIZE);
10647 + kaddr[0] = 0x9DE3BFA8U; /* save */
10648 + flush_dcache_page(vmf->page);
10649 + kunmap(vmf->page);
10650 + return VM_FAULT_MAJOR;
10651 +}
10652 +
10653 +static const struct vm_operations_struct pax_vm_ops = {
10654 + .close = pax_emuplt_close,
10655 + .fault = pax_emuplt_fault
10656 +};
10657 +
10658 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10659 +{
10660 + int ret;
10661 +
10662 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10663 + vma->vm_mm = current->mm;
10664 + vma->vm_start = addr;
10665 + vma->vm_end = addr + PAGE_SIZE;
10666 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10667 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10668 + vma->vm_ops = &pax_vm_ops;
10669 +
10670 + ret = insert_vm_struct(current->mm, vma);
10671 + if (ret)
10672 + return ret;
10673 +
10674 + ++current->mm->total_vm;
10675 + return 0;
10676 +}
10677 +#endif
10678 +
10679 +/*
10680 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10681 + *
10682 + * returns 1 when task should be killed
10683 + * 2 when patched PLT trampoline was detected
10684 + * 3 when unpatched PLT trampoline was detected
10685 + */
10686 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10687 +{
10688 +
10689 +#ifdef CONFIG_PAX_EMUPLT
10690 + int err;
10691 +
10692 + do { /* PaX: patched PLT emulation #1 */
10693 + unsigned int sethi1, sethi2, jmpl;
10694 +
10695 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10696 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10697 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10698 +
10699 + if (err)
10700 + break;
10701 +
10702 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10703 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10704 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10705 + {
10706 + unsigned long addr;
10707 +
10708 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10709 + addr = regs->u_regs[UREG_G1];
10710 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10711 +
10712 + if (test_thread_flag(TIF_32BIT))
10713 + addr &= 0xFFFFFFFFUL;
10714 +
10715 + regs->tpc = addr;
10716 + regs->tnpc = addr+4;
10717 + return 2;
10718 + }
10719 + } while (0);
10720 +
10721 + do { /* PaX: patched PLT emulation #2 */
10722 + unsigned int ba;
10723 +
10724 + err = get_user(ba, (unsigned int *)regs->tpc);
10725 +
10726 + if (err)
10727 + break;
10728 +
10729 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10730 + unsigned long addr;
10731 +
10732 + if ((ba & 0xFFC00000U) == 0x30800000U)
10733 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10734 + else
10735 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10736 +
10737 + if (test_thread_flag(TIF_32BIT))
10738 + addr &= 0xFFFFFFFFUL;
10739 +
10740 + regs->tpc = addr;
10741 + regs->tnpc = addr+4;
10742 + return 2;
10743 + }
10744 + } while (0);
10745 +
10746 + do { /* PaX: patched PLT emulation #3 */
10747 + unsigned int sethi, bajmpl, nop;
10748 +
10749 + err = get_user(sethi, (unsigned int *)regs->tpc);
10750 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10751 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10752 +
10753 + if (err)
10754 + break;
10755 +
10756 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10757 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10758 + nop == 0x01000000U)
10759 + {
10760 + unsigned long addr;
10761 +
10762 + addr = (sethi & 0x003FFFFFU) << 10;
10763 + regs->u_regs[UREG_G1] = addr;
10764 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10765 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10766 + else
10767 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
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 #4 */
10779 + unsigned int sethi, mov1, call, mov2;
10780 +
10781 + err = get_user(sethi, (unsigned int *)regs->tpc);
10782 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10783 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10784 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10785 +
10786 + if (err)
10787 + break;
10788 +
10789 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10790 + mov1 == 0x8210000FU &&
10791 + (call & 0xC0000000U) == 0x40000000U &&
10792 + mov2 == 0x9E100001U)
10793 + {
10794 + unsigned long addr;
10795 +
10796 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10797 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10798 +
10799 + if (test_thread_flag(TIF_32BIT))
10800 + addr &= 0xFFFFFFFFUL;
10801 +
10802 + regs->tpc = addr;
10803 + regs->tnpc = addr+4;
10804 + return 2;
10805 + }
10806 + } while (0);
10807 +
10808 + do { /* PaX: patched PLT emulation #5 */
10809 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10810 +
10811 + err = get_user(sethi, (unsigned int *)regs->tpc);
10812 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10813 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10814 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10815 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10816 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10817 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10818 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10819 +
10820 + if (err)
10821 + break;
10822 +
10823 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10824 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10825 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10826 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10827 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10828 + sllx == 0x83287020U &&
10829 + jmpl == 0x81C04005U &&
10830 + nop == 0x01000000U)
10831 + {
10832 + unsigned long addr;
10833 +
10834 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10835 + regs->u_regs[UREG_G1] <<= 32;
10836 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10837 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10838 + regs->tpc = addr;
10839 + regs->tnpc = addr+4;
10840 + return 2;
10841 + }
10842 + } while (0);
10843 +
10844 + do { /* PaX: patched PLT emulation #6 */
10845 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10846 +
10847 + err = get_user(sethi, (unsigned int *)regs->tpc);
10848 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10849 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10850 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10851 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10852 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10853 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10854 +
10855 + if (err)
10856 + break;
10857 +
10858 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10859 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10860 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10861 + sllx == 0x83287020U &&
10862 + (or & 0xFFFFE000U) == 0x8A116000U &&
10863 + jmpl == 0x81C04005U &&
10864 + nop == 0x01000000U)
10865 + {
10866 + unsigned long addr;
10867 +
10868 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10869 + regs->u_regs[UREG_G1] <<= 32;
10870 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10871 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10872 + regs->tpc = addr;
10873 + regs->tnpc = addr+4;
10874 + return 2;
10875 + }
10876 + } while (0);
10877 +
10878 + do { /* PaX: unpatched PLT emulation step 1 */
10879 + unsigned int sethi, ba, nop;
10880 +
10881 + err = get_user(sethi, (unsigned int *)regs->tpc);
10882 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10883 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10884 +
10885 + if (err)
10886 + break;
10887 +
10888 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10889 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10890 + nop == 0x01000000U)
10891 + {
10892 + unsigned long addr;
10893 + unsigned int save, call;
10894 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10895 +
10896 + if ((ba & 0xFFC00000U) == 0x30800000U)
10897 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10898 + else
10899 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10900 +
10901 + if (test_thread_flag(TIF_32BIT))
10902 + addr &= 0xFFFFFFFFUL;
10903 +
10904 + err = get_user(save, (unsigned int *)addr);
10905 + err |= get_user(call, (unsigned int *)(addr+4));
10906 + err |= get_user(nop, (unsigned int *)(addr+8));
10907 + if (err)
10908 + break;
10909 +
10910 +#ifdef CONFIG_PAX_DLRESOLVE
10911 + if (save == 0x9DE3BFA8U &&
10912 + (call & 0xC0000000U) == 0x40000000U &&
10913 + nop == 0x01000000U)
10914 + {
10915 + struct vm_area_struct *vma;
10916 + unsigned long call_dl_resolve;
10917 +
10918 + down_read(&current->mm->mmap_sem);
10919 + call_dl_resolve = current->mm->call_dl_resolve;
10920 + up_read(&current->mm->mmap_sem);
10921 + if (likely(call_dl_resolve))
10922 + goto emulate;
10923 +
10924 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10925 +
10926 + down_write(&current->mm->mmap_sem);
10927 + if (current->mm->call_dl_resolve) {
10928 + call_dl_resolve = current->mm->call_dl_resolve;
10929 + up_write(&current->mm->mmap_sem);
10930 + if (vma)
10931 + kmem_cache_free(vm_area_cachep, vma);
10932 + goto emulate;
10933 + }
10934 +
10935 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10936 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10937 + up_write(&current->mm->mmap_sem);
10938 + if (vma)
10939 + kmem_cache_free(vm_area_cachep, vma);
10940 + return 1;
10941 + }
10942 +
10943 + if (pax_insert_vma(vma, call_dl_resolve)) {
10944 + up_write(&current->mm->mmap_sem);
10945 + kmem_cache_free(vm_area_cachep, vma);
10946 + return 1;
10947 + }
10948 +
10949 + current->mm->call_dl_resolve = call_dl_resolve;
10950 + up_write(&current->mm->mmap_sem);
10951 +
10952 +emulate:
10953 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10954 + regs->tpc = call_dl_resolve;
10955 + regs->tnpc = addr+4;
10956 + return 3;
10957 + }
10958 +#endif
10959 +
10960 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10961 + if ((save & 0xFFC00000U) == 0x05000000U &&
10962 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10963 + nop == 0x01000000U)
10964 + {
10965 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10966 + regs->u_regs[UREG_G2] = addr + 4;
10967 + addr = (save & 0x003FFFFFU) << 10;
10968 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10969 +
10970 + if (test_thread_flag(TIF_32BIT))
10971 + addr &= 0xFFFFFFFFUL;
10972 +
10973 + regs->tpc = addr;
10974 + regs->tnpc = addr+4;
10975 + return 3;
10976 + }
10977 +
10978 + /* PaX: 64-bit PLT stub */
10979 + err = get_user(sethi1, (unsigned int *)addr);
10980 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10981 + err |= get_user(or1, (unsigned int *)(addr+8));
10982 + err |= get_user(or2, (unsigned int *)(addr+12));
10983 + err |= get_user(sllx, (unsigned int *)(addr+16));
10984 + err |= get_user(add, (unsigned int *)(addr+20));
10985 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10986 + err |= get_user(nop, (unsigned int *)(addr+28));
10987 + if (err)
10988 + break;
10989 +
10990 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10991 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10992 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10993 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10994 + sllx == 0x89293020U &&
10995 + add == 0x8A010005U &&
10996 + jmpl == 0x89C14000U &&
10997 + nop == 0x01000000U)
10998 + {
10999 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11000 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11001 + regs->u_regs[UREG_G4] <<= 32;
11002 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11003 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11004 + regs->u_regs[UREG_G4] = addr + 24;
11005 + addr = regs->u_regs[UREG_G5];
11006 + regs->tpc = addr;
11007 + regs->tnpc = addr+4;
11008 + return 3;
11009 + }
11010 + }
11011 + } while (0);
11012 +
11013 +#ifdef CONFIG_PAX_DLRESOLVE
11014 + do { /* PaX: unpatched PLT emulation step 2 */
11015 + unsigned int save, call, nop;
11016 +
11017 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11018 + err |= get_user(call, (unsigned int *)regs->tpc);
11019 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11020 + if (err)
11021 + break;
11022 +
11023 + if (save == 0x9DE3BFA8U &&
11024 + (call & 0xC0000000U) == 0x40000000U &&
11025 + nop == 0x01000000U)
11026 + {
11027 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11028 +
11029 + if (test_thread_flag(TIF_32BIT))
11030 + dl_resolve &= 0xFFFFFFFFUL;
11031 +
11032 + regs->u_regs[UREG_RETPC] = regs->tpc;
11033 + regs->tpc = dl_resolve;
11034 + regs->tnpc = dl_resolve+4;
11035 + return 3;
11036 + }
11037 + } while (0);
11038 +#endif
11039 +
11040 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11041 + unsigned int sethi, ba, nop;
11042 +
11043 + err = get_user(sethi, (unsigned int *)regs->tpc);
11044 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11045 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11046 +
11047 + if (err)
11048 + break;
11049 +
11050 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11051 + (ba & 0xFFF00000U) == 0x30600000U &&
11052 + nop == 0x01000000U)
11053 + {
11054 + unsigned long addr;
11055 +
11056 + addr = (sethi & 0x003FFFFFU) << 10;
11057 + regs->u_regs[UREG_G1] = addr;
11058 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11059 +
11060 + if (test_thread_flag(TIF_32BIT))
11061 + addr &= 0xFFFFFFFFUL;
11062 +
11063 + regs->tpc = addr;
11064 + regs->tnpc = addr+4;
11065 + return 2;
11066 + }
11067 + } while (0);
11068 +
11069 +#endif
11070 +
11071 + return 1;
11072 +}
11073 +
11074 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11075 +{
11076 + unsigned long i;
11077 +
11078 + printk(KERN_ERR "PAX: bytes at PC: ");
11079 + for (i = 0; i < 8; i++) {
11080 + unsigned int c;
11081 + if (get_user(c, (unsigned int *)pc+i))
11082 + printk(KERN_CONT "???????? ");
11083 + else
11084 + printk(KERN_CONT "%08x ", c);
11085 + }
11086 + printk("\n");
11087 +}
11088 +#endif
11089 +
11090 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11091 {
11092 struct mm_struct *mm = current->mm;
11093 @@ -341,6 +804,29 @@ retry:
11094 if (!vma)
11095 goto bad_area;
11096
11097 +#ifdef CONFIG_PAX_PAGEEXEC
11098 + /* PaX: detect ITLB misses on non-exec pages */
11099 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11100 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11101 + {
11102 + if (address != regs->tpc)
11103 + goto good_area;
11104 +
11105 + up_read(&mm->mmap_sem);
11106 + switch (pax_handle_fetch_fault(regs)) {
11107 +
11108 +#ifdef CONFIG_PAX_EMUPLT
11109 + case 2:
11110 + case 3:
11111 + return;
11112 +#endif
11113 +
11114 + }
11115 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11116 + do_group_exit(SIGKILL);
11117 + }
11118 +#endif
11119 +
11120 /* Pure DTLB misses do not tell us whether the fault causing
11121 * load/store/atomic was a write or not, it only says that there
11122 * was no match. So in such a case we (carefully) read the
11123 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11124 index d2b5944..d878f3c 100644
11125 --- a/arch/sparc/mm/hugetlbpage.c
11126 +++ b/arch/sparc/mm/hugetlbpage.c
11127 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11128 unsigned long addr,
11129 unsigned long len,
11130 unsigned long pgoff,
11131 - unsigned long flags)
11132 + unsigned long flags,
11133 + unsigned long offset)
11134 {
11135 unsigned long task_size = TASK_SIZE;
11136 struct vm_unmapped_area_info info;
11137 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11138
11139 info.flags = 0;
11140 info.length = len;
11141 - info.low_limit = TASK_UNMAPPED_BASE;
11142 + info.low_limit = mm->mmap_base;
11143 info.high_limit = min(task_size, VA_EXCLUDE_START);
11144 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11145 info.align_offset = 0;
11146 + info.threadstack_offset = offset;
11147 addr = vm_unmapped_area(&info);
11148
11149 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11150 VM_BUG_ON(addr != -ENOMEM);
11151 info.low_limit = VA_EXCLUDE_END;
11152 +
11153 +#ifdef CONFIG_PAX_RANDMMAP
11154 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11155 + info.low_limit += mm->delta_mmap;
11156 +#endif
11157 +
11158 info.high_limit = task_size;
11159 addr = vm_unmapped_area(&info);
11160 }
11161 @@ -58,7 +66,8 @@ static unsigned long
11162 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11163 const unsigned long len,
11164 const unsigned long pgoff,
11165 - const unsigned long flags)
11166 + const unsigned long flags,
11167 + const unsigned long offset)
11168 {
11169 struct mm_struct *mm = current->mm;
11170 unsigned long addr = addr0;
11171 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11172 info.high_limit = mm->mmap_base;
11173 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11174 info.align_offset = 0;
11175 + info.threadstack_offset = offset;
11176 addr = vm_unmapped_area(&info);
11177
11178 /*
11179 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11180 VM_BUG_ON(addr != -ENOMEM);
11181 info.flags = 0;
11182 info.low_limit = TASK_UNMAPPED_BASE;
11183 +
11184 +#ifdef CONFIG_PAX_RANDMMAP
11185 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11186 + info.low_limit += mm->delta_mmap;
11187 +#endif
11188 +
11189 info.high_limit = STACK_TOP32;
11190 addr = vm_unmapped_area(&info);
11191 }
11192 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11193 struct mm_struct *mm = current->mm;
11194 struct vm_area_struct *vma;
11195 unsigned long task_size = TASK_SIZE;
11196 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11197
11198 if (test_thread_flag(TIF_32BIT))
11199 task_size = STACK_TOP32;
11200 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11201 return addr;
11202 }
11203
11204 +#ifdef CONFIG_PAX_RANDMMAP
11205 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11206 +#endif
11207 +
11208 if (addr) {
11209 addr = ALIGN(addr, HPAGE_SIZE);
11210 vma = find_vma(mm, addr);
11211 - if (task_size - len >= addr &&
11212 - (!vma || addr + len <= vma->vm_start))
11213 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11214 return addr;
11215 }
11216 if (mm->get_unmapped_area == arch_get_unmapped_area)
11217 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11218 - pgoff, flags);
11219 + pgoff, flags, offset);
11220 else
11221 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11222 - pgoff, flags);
11223 + pgoff, flags, offset);
11224 }
11225
11226 pte_t *huge_pte_alloc(struct mm_struct *mm,
11227 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11228 index ed82eda..0d80e77 100644
11229 --- a/arch/sparc/mm/init_64.c
11230 +++ b/arch/sparc/mm/init_64.c
11231 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11232 int num_kernel_image_mappings;
11233
11234 #ifdef CONFIG_DEBUG_DCFLUSH
11235 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11236 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11237 #ifdef CONFIG_SMP
11238 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11239 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11240 #endif
11241 #endif
11242
11243 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11244 {
11245 BUG_ON(tlb_type == hypervisor);
11246 #ifdef CONFIG_DEBUG_DCFLUSH
11247 - atomic_inc(&dcpage_flushes);
11248 + atomic_inc_unchecked(&dcpage_flushes);
11249 #endif
11250
11251 #ifdef DCACHE_ALIASING_POSSIBLE
11252 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11253
11254 #ifdef CONFIG_DEBUG_DCFLUSH
11255 seq_printf(m, "DCPageFlushes\t: %d\n",
11256 - atomic_read(&dcpage_flushes));
11257 + atomic_read_unchecked(&dcpage_flushes));
11258 #ifdef CONFIG_SMP
11259 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11260 - atomic_read(&dcpage_flushes_xcall));
11261 + atomic_read_unchecked(&dcpage_flushes_xcall));
11262 #endif /* CONFIG_SMP */
11263 #endif /* CONFIG_DEBUG_DCFLUSH */
11264 }
11265 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11266 index f4500c6..889656c 100644
11267 --- a/arch/tile/include/asm/atomic_64.h
11268 +++ b/arch/tile/include/asm/atomic_64.h
11269 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11270
11271 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11272
11273 +#define atomic64_read_unchecked(v) atomic64_read(v)
11274 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11275 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11276 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11277 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11278 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11279 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11280 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11281 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11282 +
11283 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11284 #define smp_mb__before_atomic_dec() smp_mb()
11285 #define smp_mb__after_atomic_dec() smp_mb()
11286 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11287 index a9a5299..0fce79e 100644
11288 --- a/arch/tile/include/asm/cache.h
11289 +++ b/arch/tile/include/asm/cache.h
11290 @@ -15,11 +15,12 @@
11291 #ifndef _ASM_TILE_CACHE_H
11292 #define _ASM_TILE_CACHE_H
11293
11294 +#include <linux/const.h>
11295 #include <arch/chip.h>
11296
11297 /* bytes per L1 data cache line */
11298 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11299 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11300 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11301
11302 /* bytes per L2 cache line */
11303 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11304 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11305 index e4d44bd..99927a3 100644
11306 --- a/arch/tile/include/asm/uaccess.h
11307 +++ b/arch/tile/include/asm/uaccess.h
11308 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11309 const void __user *from,
11310 unsigned long n)
11311 {
11312 - int sz = __compiletime_object_size(to);
11313 + size_t sz = __compiletime_object_size(to);
11314
11315 - if (likely(sz == -1 || sz >= n))
11316 + if (likely(sz == (size_t)-1 || sz >= n))
11317 n = _copy_from_user(to, from, n);
11318 else
11319 copy_from_user_overflow();
11320 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11321 index 650ccff..45fe2d6 100644
11322 --- a/arch/tile/mm/hugetlbpage.c
11323 +++ b/arch/tile/mm/hugetlbpage.c
11324 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11325 info.high_limit = TASK_SIZE;
11326 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11327 info.align_offset = 0;
11328 + info.threadstack_offset = 0;
11329 return vm_unmapped_area(&info);
11330 }
11331
11332 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11333 info.high_limit = current->mm->mmap_base;
11334 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11335 info.align_offset = 0;
11336 + info.threadstack_offset = 0;
11337 addr = vm_unmapped_area(&info);
11338
11339 /*
11340 diff --git a/arch/um/Makefile b/arch/um/Makefile
11341 index 133f7de..1d6f2f1 100644
11342 --- a/arch/um/Makefile
11343 +++ b/arch/um/Makefile
11344 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11345 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11346 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11347
11348 +ifdef CONSTIFY_PLUGIN
11349 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11350 +endif
11351 +
11352 #This will adjust *FLAGS accordingly to the platform.
11353 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11354
11355 diff --git a/arch/um/defconfig b/arch/um/defconfig
11356 index 08107a7..ab22afe 100644
11357 --- a/arch/um/defconfig
11358 +++ b/arch/um/defconfig
11359 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11360 CONFIG_X86_L1_CACHE_SHIFT=5
11361 CONFIG_X86_XADD=y
11362 CONFIG_X86_PPRO_FENCE=y
11363 -CONFIG_X86_WP_WORKS_OK=y
11364 CONFIG_X86_INVLPG=y
11365 CONFIG_X86_BSWAP=y
11366 CONFIG_X86_POPAD_OK=y
11367 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11368 index 19e1bdd..3665b77 100644
11369 --- a/arch/um/include/asm/cache.h
11370 +++ b/arch/um/include/asm/cache.h
11371 @@ -1,6 +1,7 @@
11372 #ifndef __UM_CACHE_H
11373 #define __UM_CACHE_H
11374
11375 +#include <linux/const.h>
11376
11377 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11378 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11379 @@ -12,6 +13,6 @@
11380 # define L1_CACHE_SHIFT 5
11381 #endif
11382
11383 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11384 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11385
11386 #endif
11387 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11388 index 2e0a6b1..a64d0f5 100644
11389 --- a/arch/um/include/asm/kmap_types.h
11390 +++ b/arch/um/include/asm/kmap_types.h
11391 @@ -8,6 +8,6 @@
11392
11393 /* No more #include "asm/arch/kmap_types.h" ! */
11394
11395 -#define KM_TYPE_NR 14
11396 +#define KM_TYPE_NR 15
11397
11398 #endif
11399 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11400 index 5ff53d9..5850cdf 100644
11401 --- a/arch/um/include/asm/page.h
11402 +++ b/arch/um/include/asm/page.h
11403 @@ -14,6 +14,9 @@
11404 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11405 #define PAGE_MASK (~(PAGE_SIZE-1))
11406
11407 +#define ktla_ktva(addr) (addr)
11408 +#define ktva_ktla(addr) (addr)
11409 +
11410 #ifndef __ASSEMBLY__
11411
11412 struct page;
11413 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11414 index 0032f92..cd151e0 100644
11415 --- a/arch/um/include/asm/pgtable-3level.h
11416 +++ b/arch/um/include/asm/pgtable-3level.h
11417 @@ -58,6 +58,7 @@
11418 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11419 #define pud_populate(mm, pud, pmd) \
11420 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11421 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11422
11423 #ifdef CONFIG_64BIT
11424 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11425 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11426 index bbcef52..6a2a483 100644
11427 --- a/arch/um/kernel/process.c
11428 +++ b/arch/um/kernel/process.c
11429 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11430 return 2;
11431 }
11432
11433 -/*
11434 - * Only x86 and x86_64 have an arch_align_stack().
11435 - * All other arches have "#define arch_align_stack(x) (x)"
11436 - * in their asm/system.h
11437 - * As this is included in UML from asm-um/system-generic.h,
11438 - * we can use it to behave as the subarch does.
11439 - */
11440 -#ifndef arch_align_stack
11441 -unsigned long arch_align_stack(unsigned long sp)
11442 -{
11443 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11444 - sp -= get_random_int() % 8192;
11445 - return sp & ~0xf;
11446 -}
11447 -#endif
11448 -
11449 unsigned long get_wchan(struct task_struct *p)
11450 {
11451 unsigned long stack_page, sp, ip;
11452 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11453 index ad8f795..2c7eec6 100644
11454 --- a/arch/unicore32/include/asm/cache.h
11455 +++ b/arch/unicore32/include/asm/cache.h
11456 @@ -12,8 +12,10 @@
11457 #ifndef __UNICORE_CACHE_H__
11458 #define __UNICORE_CACHE_H__
11459
11460 -#define L1_CACHE_SHIFT (5)
11461 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11462 +#include <linux/const.h>
11463 +
11464 +#define L1_CACHE_SHIFT 5
11465 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11466
11467 /*
11468 * Memory returned by kmalloc() may be used for DMA, so we must make
11469 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11470 index b32ebf9..5704f98 100644
11471 --- a/arch/x86/Kconfig
11472 +++ b/arch/x86/Kconfig
11473 @@ -248,7 +248,7 @@ config X86_HT
11474
11475 config X86_32_LAZY_GS
11476 def_bool y
11477 - depends on X86_32 && !CC_STACKPROTECTOR
11478 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11479
11480 config ARCH_HWEIGHT_CFLAGS
11481 string
11482 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11483
11484 config X86_MSR
11485 tristate "/dev/cpu/*/msr - Model-specific register support"
11486 + depends on !GRKERNSEC_KMEM
11487 ---help---
11488 This device gives privileged processes access to the x86
11489 Model-Specific Registers (MSRs). It is a character device with
11490 @@ -1111,7 +1112,7 @@ choice
11491
11492 config NOHIGHMEM
11493 bool "off"
11494 - depends on !X86_NUMAQ
11495 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11496 ---help---
11497 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11498 However, the address space of 32-bit x86 processors is only 4
11499 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11500
11501 config HIGHMEM4G
11502 bool "4GB"
11503 - depends on !X86_NUMAQ
11504 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11505 ---help---
11506 Select this if you have a 32-bit processor and between 1 and 4
11507 gigabytes of physical RAM.
11508 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11509 hex
11510 default 0xB0000000 if VMSPLIT_3G_OPT
11511 default 0x80000000 if VMSPLIT_2G
11512 - default 0x78000000 if VMSPLIT_2G_OPT
11513 + default 0x70000000 if VMSPLIT_2G_OPT
11514 default 0x40000000 if VMSPLIT_1G
11515 default 0xC0000000
11516 depends on X86_32
11517 @@ -1599,6 +1600,7 @@ config SECCOMP
11518
11519 config CC_STACKPROTECTOR
11520 bool "Enable -fstack-protector buffer overflow detection"
11521 + depends on X86_64 || !PAX_MEMORY_UDEREF
11522 ---help---
11523 This option turns on the -fstack-protector GCC feature. This
11524 feature puts, at the beginning of functions, a canary value on
11525 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11526 config PHYSICAL_ALIGN
11527 hex "Alignment value to which kernel should be aligned" if X86_32
11528 default "0x1000000"
11529 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11530 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11531 range 0x2000 0x1000000
11532 ---help---
11533 This value puts the alignment restrictions on physical address
11534 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11535 If unsure, say N.
11536
11537 config COMPAT_VDSO
11538 - def_bool y
11539 + def_bool n
11540 prompt "Compat VDSO support"
11541 depends on X86_32 || IA32_EMULATION
11542 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11543 ---help---
11544 Map the 32-bit VDSO to the predictable old-style address too.
11545
11546 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11547 index c026cca..14657ae 100644
11548 --- a/arch/x86/Kconfig.cpu
11549 +++ b/arch/x86/Kconfig.cpu
11550 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11551
11552 config X86_F00F_BUG
11553 def_bool y
11554 - depends on M586MMX || M586TSC || M586 || M486
11555 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11556
11557 config X86_INVD_BUG
11558 def_bool y
11559 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11560
11561 config X86_ALIGNMENT_16
11562 def_bool y
11563 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11564 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11565
11566 config X86_INTEL_USERCOPY
11567 def_bool y
11568 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11569 # generates cmov.
11570 config X86_CMOV
11571 def_bool y
11572 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11573 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11574
11575 config X86_MINIMUM_CPU_FAMILY
11576 int
11577 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11578 index 78d91af..8ceb94b 100644
11579 --- a/arch/x86/Kconfig.debug
11580 +++ b/arch/x86/Kconfig.debug
11581 @@ -74,7 +74,7 @@ config X86_PTDUMP
11582 config DEBUG_RODATA
11583 bool "Write protect kernel read-only data structures"
11584 default y
11585 - depends on DEBUG_KERNEL
11586 + depends on DEBUG_KERNEL && BROKEN
11587 ---help---
11588 Mark the kernel read-only data as write-protected in the pagetables,
11589 in order to catch accidental (and incorrect) writes to such const
11590 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11591
11592 config DEBUG_SET_MODULE_RONX
11593 bool "Set loadable kernel module data as NX and text as RO"
11594 - depends on MODULES
11595 + depends on MODULES && BROKEN
11596 ---help---
11597 This option helps catch unintended modifications to loadable
11598 kernel module's text and read-only data. It also prevents execution
11599 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11600 index 07639c6..6f2c901 100644
11601 --- a/arch/x86/Makefile
11602 +++ b/arch/x86/Makefile
11603 @@ -54,6 +54,7 @@ else
11604 UTS_MACHINE := x86_64
11605 CHECKFLAGS += -D__x86_64__ -m64
11606
11607 + biarch := $(call cc-option,-m64)
11608 KBUILD_AFLAGS += -m64
11609 KBUILD_CFLAGS += -m64
11610
11611 @@ -241,3 +242,12 @@ define archhelp
11612 echo ' FDINITRD=file initrd for the booted kernel'
11613 echo ' kvmconfig - Enable additional options for guest kernel support'
11614 endef
11615 +
11616 +define OLD_LD
11617 +
11618 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11619 +*** Please upgrade your binutils to 2.18 or newer
11620 +endef
11621 +
11622 +archprepare:
11623 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11624 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11625 index 379814b..add62ce 100644
11626 --- a/arch/x86/boot/Makefile
11627 +++ b/arch/x86/boot/Makefile
11628 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11629 $(call cc-option, -fno-stack-protector) \
11630 $(call cc-option, -mpreferred-stack-boundary=2)
11631 KBUILD_CFLAGS += $(call cc-option, -m32)
11632 +ifdef CONSTIFY_PLUGIN
11633 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11634 +endif
11635 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11636 GCOV_PROFILE := n
11637
11638 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11639 index 878e4b9..20537ab 100644
11640 --- a/arch/x86/boot/bitops.h
11641 +++ b/arch/x86/boot/bitops.h
11642 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11643 u8 v;
11644 const u32 *p = (const u32 *)addr;
11645
11646 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11647 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11648 return v;
11649 }
11650
11651 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11652
11653 static inline void set_bit(int nr, void *addr)
11654 {
11655 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11656 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11657 }
11658
11659 #endif /* BOOT_BITOPS_H */
11660 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11661 index 5b75319..331a4ca 100644
11662 --- a/arch/x86/boot/boot.h
11663 +++ b/arch/x86/boot/boot.h
11664 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11665 static inline u16 ds(void)
11666 {
11667 u16 seg;
11668 - asm("movw %%ds,%0" : "=rm" (seg));
11669 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11670 return seg;
11671 }
11672
11673 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11674 static inline int memcmp(const void *s1, const void *s2, size_t len)
11675 {
11676 u8 diff;
11677 - asm("repe; cmpsb; setnz %0"
11678 + asm volatile("repe; cmpsb; setnz %0"
11679 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11680 return diff;
11681 }
11682 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11683 index dcd90df..c830d7d 100644
11684 --- a/arch/x86/boot/compressed/Makefile
11685 +++ b/arch/x86/boot/compressed/Makefile
11686 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11687 KBUILD_CFLAGS += $(cflags-y)
11688 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11689 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11690 +ifdef CONSTIFY_PLUGIN
11691 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11692 +endif
11693
11694 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11695 GCOV_PROFILE := n
11696 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11697 index b7388a4..03844ec 100644
11698 --- a/arch/x86/boot/compressed/eboot.c
11699 +++ b/arch/x86/boot/compressed/eboot.c
11700 @@ -150,7 +150,6 @@ again:
11701 *addr = max_addr;
11702 }
11703
11704 -free_pool:
11705 efi_call_phys1(sys_table->boottime->free_pool, map);
11706
11707 fail:
11708 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11709 if (i == map_size / desc_size)
11710 status = EFI_NOT_FOUND;
11711
11712 -free_pool:
11713 efi_call_phys1(sys_table->boottime->free_pool, map);
11714 fail:
11715 return status;
11716 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11717 index a53440e..c3dbf1e 100644
11718 --- a/arch/x86/boot/compressed/efi_stub_32.S
11719 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11720 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11721 * parameter 2, ..., param n. To make things easy, we save the return
11722 * address of efi_call_phys in a global variable.
11723 */
11724 - popl %ecx
11725 - movl %ecx, saved_return_addr(%edx)
11726 - /* get the function pointer into ECX*/
11727 - popl %ecx
11728 - movl %ecx, efi_rt_function_ptr(%edx)
11729 + popl saved_return_addr(%edx)
11730 + popl efi_rt_function_ptr(%edx)
11731
11732 /*
11733 * 3. Call the physical function.
11734 */
11735 - call *%ecx
11736 + call *efi_rt_function_ptr(%edx)
11737
11738 /*
11739 * 4. Balance the stack. And because EAX contain the return value,
11740 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11741 1: popl %edx
11742 subl $1b, %edx
11743
11744 - movl efi_rt_function_ptr(%edx), %ecx
11745 - pushl %ecx
11746 + pushl efi_rt_function_ptr(%edx)
11747
11748 /*
11749 * 10. Push the saved return address onto the stack and return.
11750 */
11751 - movl saved_return_addr(%edx), %ecx
11752 - pushl %ecx
11753 - ret
11754 + jmpl *saved_return_addr(%edx)
11755 ENDPROC(efi_call_phys)
11756 .previous
11757
11758 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11759 index 1e3184f..0d11e2e 100644
11760 --- a/arch/x86/boot/compressed/head_32.S
11761 +++ b/arch/x86/boot/compressed/head_32.S
11762 @@ -118,7 +118,7 @@ preferred_addr:
11763 notl %eax
11764 andl %eax, %ebx
11765 #else
11766 - movl $LOAD_PHYSICAL_ADDR, %ebx
11767 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11768 #endif
11769
11770 /* Target address to relocate to for decompression */
11771 @@ -204,7 +204,7 @@ relocated:
11772 * and where it was actually loaded.
11773 */
11774 movl %ebp, %ebx
11775 - subl $LOAD_PHYSICAL_ADDR, %ebx
11776 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11777 jz 2f /* Nothing to be done if loaded at compiled addr. */
11778 /*
11779 * Process relocations.
11780 @@ -212,8 +212,7 @@ relocated:
11781
11782 1: subl $4, %edi
11783 movl (%edi), %ecx
11784 - testl %ecx, %ecx
11785 - jz 2f
11786 + jecxz 2f
11787 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11788 jmp 1b
11789 2:
11790 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11791 index 06e71c2..88a98264 100644
11792 --- a/arch/x86/boot/compressed/head_64.S
11793 +++ b/arch/x86/boot/compressed/head_64.S
11794 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11795 notl %eax
11796 andl %eax, %ebx
11797 #else
11798 - movl $LOAD_PHYSICAL_ADDR, %ebx
11799 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11800 #endif
11801
11802 /* Target address to relocate to for decompression */
11803 @@ -270,7 +270,7 @@ preferred_addr:
11804 notq %rax
11805 andq %rax, %rbp
11806 #else
11807 - movq $LOAD_PHYSICAL_ADDR, %rbp
11808 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11809 #endif
11810
11811 /* Target address to relocate to for decompression */
11812 @@ -361,8 +361,8 @@ gdt:
11813 .long gdt
11814 .word 0
11815 .quad 0x0000000000000000 /* NULL descriptor */
11816 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11817 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11818 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11819 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11820 .quad 0x0080890000000000 /* TS descriptor */
11821 .quad 0x0000000000000000 /* TS continued */
11822 gdt_end:
11823 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11824 index 0319c88..7c1931f 100644
11825 --- a/arch/x86/boot/compressed/misc.c
11826 +++ b/arch/x86/boot/compressed/misc.c
11827 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11828 case PT_LOAD:
11829 #ifdef CONFIG_RELOCATABLE
11830 dest = output;
11831 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11832 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11833 #else
11834 dest = (void *)(phdr->p_paddr);
11835 #endif
11836 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11837 error("Destination address too large");
11838 #endif
11839 #ifndef CONFIG_RELOCATABLE
11840 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11841 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11842 error("Wrong destination address");
11843 #endif
11844
11845 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11846 index 4d3ff03..e4972ff 100644
11847 --- a/arch/x86/boot/cpucheck.c
11848 +++ b/arch/x86/boot/cpucheck.c
11849 @@ -74,7 +74,7 @@ static int has_fpu(void)
11850 u16 fcw = -1, fsw = -1;
11851 u32 cr0;
11852
11853 - asm("movl %%cr0,%0" : "=r" (cr0));
11854 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11855 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11856 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11857 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11858 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11859 {
11860 u32 f0, f1;
11861
11862 - asm("pushfl ; "
11863 + asm volatile("pushfl ; "
11864 "pushfl ; "
11865 "popl %0 ; "
11866 "movl %0,%1 ; "
11867 @@ -115,7 +115,7 @@ static void get_flags(void)
11868 set_bit(X86_FEATURE_FPU, cpu.flags);
11869
11870 if (has_eflag(X86_EFLAGS_ID)) {
11871 - asm("cpuid"
11872 + asm volatile("cpuid"
11873 : "=a" (max_intel_level),
11874 "=b" (cpu_vendor[0]),
11875 "=d" (cpu_vendor[1]),
11876 @@ -124,7 +124,7 @@ static void get_flags(void)
11877
11878 if (max_intel_level >= 0x00000001 &&
11879 max_intel_level <= 0x0000ffff) {
11880 - asm("cpuid"
11881 + asm volatile("cpuid"
11882 : "=a" (tfms),
11883 "=c" (cpu.flags[4]),
11884 "=d" (cpu.flags[0])
11885 @@ -136,7 +136,7 @@ static void get_flags(void)
11886 cpu.model += ((tfms >> 16) & 0xf) << 4;
11887 }
11888
11889 - asm("cpuid"
11890 + asm volatile("cpuid"
11891 : "=a" (max_amd_level)
11892 : "a" (0x80000000)
11893 : "ebx", "ecx", "edx");
11894 @@ -144,7 +144,7 @@ static void get_flags(void)
11895 if (max_amd_level >= 0x80000001 &&
11896 max_amd_level <= 0x8000ffff) {
11897 u32 eax = 0x80000001;
11898 - asm("cpuid"
11899 + asm volatile("cpuid"
11900 : "+a" (eax),
11901 "=c" (cpu.flags[6]),
11902 "=d" (cpu.flags[1])
11903 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11904 u32 ecx = MSR_K7_HWCR;
11905 u32 eax, edx;
11906
11907 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11908 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11909 eax &= ~(1 << 15);
11910 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11911 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11912
11913 get_flags(); /* Make sure it really did something */
11914 err = check_flags();
11915 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11916 u32 ecx = MSR_VIA_FCR;
11917 u32 eax, edx;
11918
11919 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11920 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11921 eax |= (1<<1)|(1<<7);
11922 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11923 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11924
11925 set_bit(X86_FEATURE_CX8, cpu.flags);
11926 err = check_flags();
11927 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11928 u32 eax, edx;
11929 u32 level = 1;
11930
11931 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11932 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11933 - asm("cpuid"
11934 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11935 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11936 + asm volatile("cpuid"
11937 : "+a" (level), "=d" (cpu.flags[0])
11938 : : "ecx", "ebx");
11939 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11940 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11941
11942 err = check_flags();
11943 }
11944 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
11945 index 9ec06a1..2c25e79 100644
11946 --- a/arch/x86/boot/header.S
11947 +++ b/arch/x86/boot/header.S
11948 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
11949 # single linked list of
11950 # struct setup_data
11951
11952 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
11953 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
11954
11955 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
11956 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
11957 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
11958 +#else
11959 #define VO_INIT_SIZE (VO__end - VO__text)
11960 +#endif
11961 #if ZO_INIT_SIZE > VO_INIT_SIZE
11962 #define INIT_SIZE ZO_INIT_SIZE
11963 #else
11964 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
11965 index db75d07..8e6d0af 100644
11966 --- a/arch/x86/boot/memory.c
11967 +++ b/arch/x86/boot/memory.c
11968 @@ -19,7 +19,7 @@
11969
11970 static int detect_memory_e820(void)
11971 {
11972 - int count = 0;
11973 + unsigned int count = 0;
11974 struct biosregs ireg, oreg;
11975 struct e820entry *desc = boot_params.e820_map;
11976 static struct e820entry buf; /* static so it is zeroed */
11977 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
11978 index 11e8c6e..fdbb1ed 100644
11979 --- a/arch/x86/boot/video-vesa.c
11980 +++ b/arch/x86/boot/video-vesa.c
11981 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
11982
11983 boot_params.screen_info.vesapm_seg = oreg.es;
11984 boot_params.screen_info.vesapm_off = oreg.di;
11985 + boot_params.screen_info.vesapm_size = oreg.cx;
11986 }
11987
11988 /*
11989 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
11990 index 43eda28..5ab5fdb 100644
11991 --- a/arch/x86/boot/video.c
11992 +++ b/arch/x86/boot/video.c
11993 @@ -96,7 +96,7 @@ static void store_mode_params(void)
11994 static unsigned int get_entry(void)
11995 {
11996 char entry_buf[4];
11997 - int i, len = 0;
11998 + unsigned int i, len = 0;
11999 int key;
12000 unsigned int v;
12001
12002 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12003 index 9105655..5e37f27 100644
12004 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12005 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12006 @@ -8,6 +8,8 @@
12007 * including this sentence is retained in full.
12008 */
12009
12010 +#include <asm/alternative-asm.h>
12011 +
12012 .extern crypto_ft_tab
12013 .extern crypto_it_tab
12014 .extern crypto_fl_tab
12015 @@ -70,6 +72,8 @@
12016 je B192; \
12017 leaq 32(r9),r9;
12018
12019 +#define ret pax_force_retaddr 0, 1; ret
12020 +
12021 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12022 movq r1,r2; \
12023 movq r3,r4; \
12024 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12025 index 477e9d7..3ab339f 100644
12026 --- a/arch/x86/crypto/aesni-intel_asm.S
12027 +++ b/arch/x86/crypto/aesni-intel_asm.S
12028 @@ -31,6 +31,7 @@
12029
12030 #include <linux/linkage.h>
12031 #include <asm/inst.h>
12032 +#include <asm/alternative-asm.h>
12033
12034 #ifdef __x86_64__
12035 .data
12036 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12037 pop %r14
12038 pop %r13
12039 pop %r12
12040 + pax_force_retaddr 0, 1
12041 ret
12042 ENDPROC(aesni_gcm_dec)
12043
12044 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12045 pop %r14
12046 pop %r13
12047 pop %r12
12048 + pax_force_retaddr 0, 1
12049 ret
12050 ENDPROC(aesni_gcm_enc)
12051
12052 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12053 pxor %xmm1, %xmm0
12054 movaps %xmm0, (TKEYP)
12055 add $0x10, TKEYP
12056 + pax_force_retaddr_bts
12057 ret
12058 ENDPROC(_key_expansion_128)
12059 ENDPROC(_key_expansion_256a)
12060 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12061 shufps $0b01001110, %xmm2, %xmm1
12062 movaps %xmm1, 0x10(TKEYP)
12063 add $0x20, TKEYP
12064 + pax_force_retaddr_bts
12065 ret
12066 ENDPROC(_key_expansion_192a)
12067
12068 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12069
12070 movaps %xmm0, (TKEYP)
12071 add $0x10, TKEYP
12072 + pax_force_retaddr_bts
12073 ret
12074 ENDPROC(_key_expansion_192b)
12075
12076 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12077 pxor %xmm1, %xmm2
12078 movaps %xmm2, (TKEYP)
12079 add $0x10, TKEYP
12080 + pax_force_retaddr_bts
12081 ret
12082 ENDPROC(_key_expansion_256b)
12083
12084 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12085 #ifndef __x86_64__
12086 popl KEYP
12087 #endif
12088 + pax_force_retaddr 0, 1
12089 ret
12090 ENDPROC(aesni_set_key)
12091
12092 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12093 popl KLEN
12094 popl KEYP
12095 #endif
12096 + pax_force_retaddr 0, 1
12097 ret
12098 ENDPROC(aesni_enc)
12099
12100 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12101 AESENC KEY STATE
12102 movaps 0x70(TKEYP), KEY
12103 AESENCLAST KEY STATE
12104 + pax_force_retaddr_bts
12105 ret
12106 ENDPROC(_aesni_enc1)
12107
12108 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12109 AESENCLAST KEY STATE2
12110 AESENCLAST KEY STATE3
12111 AESENCLAST KEY STATE4
12112 + pax_force_retaddr_bts
12113 ret
12114 ENDPROC(_aesni_enc4)
12115
12116 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12117 popl KLEN
12118 popl KEYP
12119 #endif
12120 + pax_force_retaddr 0, 1
12121 ret
12122 ENDPROC(aesni_dec)
12123
12124 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12125 AESDEC KEY STATE
12126 movaps 0x70(TKEYP), KEY
12127 AESDECLAST KEY STATE
12128 + pax_force_retaddr_bts
12129 ret
12130 ENDPROC(_aesni_dec1)
12131
12132 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12133 AESDECLAST KEY STATE2
12134 AESDECLAST KEY STATE3
12135 AESDECLAST KEY STATE4
12136 + pax_force_retaddr_bts
12137 ret
12138 ENDPROC(_aesni_dec4)
12139
12140 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12141 popl KEYP
12142 popl LEN
12143 #endif
12144 + pax_force_retaddr 0, 1
12145 ret
12146 ENDPROC(aesni_ecb_enc)
12147
12148 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12149 popl KEYP
12150 popl LEN
12151 #endif
12152 + pax_force_retaddr 0, 1
12153 ret
12154 ENDPROC(aesni_ecb_dec)
12155
12156 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12157 popl LEN
12158 popl IVP
12159 #endif
12160 + pax_force_retaddr 0, 1
12161 ret
12162 ENDPROC(aesni_cbc_enc)
12163
12164 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12165 popl LEN
12166 popl IVP
12167 #endif
12168 + pax_force_retaddr 0, 1
12169 ret
12170 ENDPROC(aesni_cbc_dec)
12171
12172 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12173 mov $1, TCTR_LOW
12174 MOVQ_R64_XMM TCTR_LOW INC
12175 MOVQ_R64_XMM CTR TCTR_LOW
12176 + pax_force_retaddr_bts
12177 ret
12178 ENDPROC(_aesni_inc_init)
12179
12180 @@ -2579,6 +2598,7 @@ _aesni_inc:
12181 .Linc_low:
12182 movaps CTR, IV
12183 PSHUFB_XMM BSWAP_MASK IV
12184 + pax_force_retaddr_bts
12185 ret
12186 ENDPROC(_aesni_inc)
12187
12188 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12189 .Lctr_enc_ret:
12190 movups IV, (IVP)
12191 .Lctr_enc_just_ret:
12192 + pax_force_retaddr 0, 1
12193 ret
12194 ENDPROC(aesni_ctr_enc)
12195
12196 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12197 pxor INC, STATE4
12198 movdqu STATE4, 0x70(OUTP)
12199
12200 + pax_force_retaddr 0, 1
12201 ret
12202 ENDPROC(aesni_xts_crypt8)
12203
12204 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12205 index 246c670..4d1ed00 100644
12206 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12207 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12208 @@ -21,6 +21,7 @@
12209 */
12210
12211 #include <linux/linkage.h>
12212 +#include <asm/alternative-asm.h>
12213
12214 .file "blowfish-x86_64-asm.S"
12215 .text
12216 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12217 jnz .L__enc_xor;
12218
12219 write_block();
12220 + pax_force_retaddr 0, 1
12221 ret;
12222 .L__enc_xor:
12223 xor_block();
12224 + pax_force_retaddr 0, 1
12225 ret;
12226 ENDPROC(__blowfish_enc_blk)
12227
12228 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12229
12230 movq %r11, %rbp;
12231
12232 + pax_force_retaddr 0, 1
12233 ret;
12234 ENDPROC(blowfish_dec_blk)
12235
12236 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12237
12238 popq %rbx;
12239 popq %rbp;
12240 + pax_force_retaddr 0, 1
12241 ret;
12242
12243 .L__enc_xor4:
12244 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12245
12246 popq %rbx;
12247 popq %rbp;
12248 + pax_force_retaddr 0, 1
12249 ret;
12250 ENDPROC(__blowfish_enc_blk_4way)
12251
12252 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12253 popq %rbx;
12254 popq %rbp;
12255
12256 + pax_force_retaddr 0, 1
12257 ret;
12258 ENDPROC(blowfish_dec_blk_4way)
12259 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12260 index ce71f92..2dd5b1e 100644
12261 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12262 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12263 @@ -16,6 +16,7 @@
12264 */
12265
12266 #include <linux/linkage.h>
12267 +#include <asm/alternative-asm.h>
12268
12269 #define CAMELLIA_TABLE_BYTE_LEN 272
12270
12271 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12272 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12273 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12274 %rcx, (%r9));
12275 + pax_force_retaddr_bts
12276 ret;
12277 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12278
12279 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12280 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12281 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12282 %rax, (%r9));
12283 + pax_force_retaddr_bts
12284 ret;
12285 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12286
12287 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12288 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12289 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12290
12291 + pax_force_retaddr_bts
12292 ret;
12293
12294 .align 8
12295 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12296 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12297 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12298
12299 + pax_force_retaddr_bts
12300 ret;
12301
12302 .align 8
12303 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12304 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12305 %xmm8, %rsi);
12306
12307 + pax_force_retaddr 0, 1
12308 ret;
12309 ENDPROC(camellia_ecb_enc_16way)
12310
12311 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12312 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12313 %xmm8, %rsi);
12314
12315 + pax_force_retaddr 0, 1
12316 ret;
12317 ENDPROC(camellia_ecb_dec_16way)
12318
12319 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12320 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12321 %xmm8, %rsi);
12322
12323 + pax_force_retaddr 0, 1
12324 ret;
12325 ENDPROC(camellia_cbc_dec_16way)
12326
12327 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12328 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12329 %xmm8, %rsi);
12330
12331 + pax_force_retaddr 0, 1
12332 ret;
12333 ENDPROC(camellia_ctr_16way)
12334
12335 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12336 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12337 %xmm8, %rsi);
12338
12339 + pax_force_retaddr 0, 1
12340 ret;
12341 ENDPROC(camellia_xts_crypt_16way)
12342
12343 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12344 index 0e0b886..8fc756a 100644
12345 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12346 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12347 @@ -11,6 +11,7 @@
12348 */
12349
12350 #include <linux/linkage.h>
12351 +#include <asm/alternative-asm.h>
12352
12353 #define CAMELLIA_TABLE_BYTE_LEN 272
12354
12355 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12356 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12357 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12358 %rcx, (%r9));
12359 + pax_force_retaddr_bts
12360 ret;
12361 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12362
12363 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12364 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12365 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12366 %rax, (%r9));
12367 + pax_force_retaddr_bts
12368 ret;
12369 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12370
12371 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12372 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12373 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12374
12375 + pax_force_retaddr_bts
12376 ret;
12377
12378 .align 8
12379 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12380 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12381 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12382
12383 + pax_force_retaddr_bts
12384 ret;
12385
12386 .align 8
12387 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12388
12389 vzeroupper;
12390
12391 + pax_force_retaddr 0, 1
12392 ret;
12393 ENDPROC(camellia_ecb_enc_32way)
12394
12395 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12396
12397 vzeroupper;
12398
12399 + pax_force_retaddr 0, 1
12400 ret;
12401 ENDPROC(camellia_ecb_dec_32way)
12402
12403 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12404
12405 vzeroupper;
12406
12407 + pax_force_retaddr 0, 1
12408 ret;
12409 ENDPROC(camellia_cbc_dec_32way)
12410
12411 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12412
12413 vzeroupper;
12414
12415 + pax_force_retaddr 0, 1
12416 ret;
12417 ENDPROC(camellia_ctr_32way)
12418
12419 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12420
12421 vzeroupper;
12422
12423 + pax_force_retaddr 0, 1
12424 ret;
12425 ENDPROC(camellia_xts_crypt_32way)
12426
12427 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12428 index 310319c..ce174a4 100644
12429 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12430 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12431 @@ -21,6 +21,7 @@
12432 */
12433
12434 #include <linux/linkage.h>
12435 +#include <asm/alternative-asm.h>
12436
12437 .file "camellia-x86_64-asm_64.S"
12438 .text
12439 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12440 enc_outunpack(mov, RT1);
12441
12442 movq RRBP, %rbp;
12443 + pax_force_retaddr 0, 1
12444 ret;
12445
12446 .L__enc_xor:
12447 enc_outunpack(xor, RT1);
12448
12449 movq RRBP, %rbp;
12450 + pax_force_retaddr 0, 1
12451 ret;
12452 ENDPROC(__camellia_enc_blk)
12453
12454 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12455 dec_outunpack();
12456
12457 movq RRBP, %rbp;
12458 + pax_force_retaddr 0, 1
12459 ret;
12460 ENDPROC(camellia_dec_blk)
12461
12462 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12463
12464 movq RRBP, %rbp;
12465 popq %rbx;
12466 + pax_force_retaddr 0, 1
12467 ret;
12468
12469 .L__enc2_xor:
12470 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12471
12472 movq RRBP, %rbp;
12473 popq %rbx;
12474 + pax_force_retaddr 0, 1
12475 ret;
12476 ENDPROC(__camellia_enc_blk_2way)
12477
12478 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12479
12480 movq RRBP, %rbp;
12481 movq RXOR, %rbx;
12482 + pax_force_retaddr 0, 1
12483 ret;
12484 ENDPROC(camellia_dec_blk_2way)
12485 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12486 index c35fd5d..c1ee236 100644
12487 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12488 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12489 @@ -24,6 +24,7 @@
12490 */
12491
12492 #include <linux/linkage.h>
12493 +#include <asm/alternative-asm.h>
12494
12495 .file "cast5-avx-x86_64-asm_64.S"
12496
12497 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12498 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12499 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12500
12501 + pax_force_retaddr 0, 1
12502 ret;
12503 ENDPROC(__cast5_enc_blk16)
12504
12505 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12506 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12507 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12508
12509 + pax_force_retaddr 0, 1
12510 ret;
12511
12512 .L__skip_dec:
12513 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12514 vmovdqu RR4, (6*4*4)(%r11);
12515 vmovdqu RL4, (7*4*4)(%r11);
12516
12517 + pax_force_retaddr
12518 ret;
12519 ENDPROC(cast5_ecb_enc_16way)
12520
12521 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12522 vmovdqu RR4, (6*4*4)(%r11);
12523 vmovdqu RL4, (7*4*4)(%r11);
12524
12525 + pax_force_retaddr
12526 ret;
12527 ENDPROC(cast5_ecb_dec_16way)
12528
12529 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12530
12531 popq %r12;
12532
12533 + pax_force_retaddr
12534 ret;
12535 ENDPROC(cast5_cbc_dec_16way)
12536
12537 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12538
12539 popq %r12;
12540
12541 + pax_force_retaddr
12542 ret;
12543 ENDPROC(cast5_ctr_16way)
12544 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12545 index e3531f8..18ded3a 100644
12546 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12547 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12548 @@ -24,6 +24,7 @@
12549 */
12550
12551 #include <linux/linkage.h>
12552 +#include <asm/alternative-asm.h>
12553 #include "glue_helper-asm-avx.S"
12554
12555 .file "cast6-avx-x86_64-asm_64.S"
12556 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12557 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12558 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12559
12560 + pax_force_retaddr 0, 1
12561 ret;
12562 ENDPROC(__cast6_enc_blk8)
12563
12564 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12565 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12566 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12567
12568 + pax_force_retaddr 0, 1
12569 ret;
12570 ENDPROC(__cast6_dec_blk8)
12571
12572 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12573
12574 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12575
12576 + pax_force_retaddr
12577 ret;
12578 ENDPROC(cast6_ecb_enc_8way)
12579
12580 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12581
12582 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12583
12584 + pax_force_retaddr
12585 ret;
12586 ENDPROC(cast6_ecb_dec_8way)
12587
12588 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12589
12590 popq %r12;
12591
12592 + pax_force_retaddr
12593 ret;
12594 ENDPROC(cast6_cbc_dec_8way)
12595
12596 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12597
12598 popq %r12;
12599
12600 + pax_force_retaddr
12601 ret;
12602 ENDPROC(cast6_ctr_8way)
12603
12604 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12605 /* dst <= regs xor IVs(in dst) */
12606 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12607
12608 + pax_force_retaddr
12609 ret;
12610 ENDPROC(cast6_xts_enc_8way)
12611
12612 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12613 /* dst <= regs xor IVs(in dst) */
12614 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12615
12616 + pax_force_retaddr
12617 ret;
12618 ENDPROC(cast6_xts_dec_8way)
12619 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12620 index dbc4339..3d868c5 100644
12621 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12622 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12623 @@ -45,6 +45,7 @@
12624
12625 #include <asm/inst.h>
12626 #include <linux/linkage.h>
12627 +#include <asm/alternative-asm.h>
12628
12629 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12630
12631 @@ -312,6 +313,7 @@ do_return:
12632 popq %rsi
12633 popq %rdi
12634 popq %rbx
12635 + pax_force_retaddr 0, 1
12636 ret
12637
12638 ################################################################
12639 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12640 index 586f41a..d02851e 100644
12641 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12642 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12643 @@ -18,6 +18,7 @@
12644
12645 #include <linux/linkage.h>
12646 #include <asm/inst.h>
12647 +#include <asm/alternative-asm.h>
12648
12649 .data
12650
12651 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12652 psrlq $1, T2
12653 pxor T2, T1
12654 pxor T1, DATA
12655 + pax_force_retaddr
12656 ret
12657 ENDPROC(__clmul_gf128mul_ble)
12658
12659 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12660 call __clmul_gf128mul_ble
12661 PSHUFB_XMM BSWAP DATA
12662 movups DATA, (%rdi)
12663 + pax_force_retaddr
12664 ret
12665 ENDPROC(clmul_ghash_mul)
12666
12667 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12668 PSHUFB_XMM BSWAP DATA
12669 movups DATA, (%rdi)
12670 .Lupdate_just_ret:
12671 + pax_force_retaddr
12672 ret
12673 ENDPROC(clmul_ghash_update)
12674
12675 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12676 pand .Lpoly, %xmm1
12677 pxor %xmm1, %xmm0
12678 movups %xmm0, (%rdi)
12679 + pax_force_retaddr
12680 ret
12681 ENDPROC(clmul_ghash_setkey)
12682 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12683 index 9279e0b..9270820 100644
12684 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12685 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12686 @@ -1,4 +1,5 @@
12687 #include <linux/linkage.h>
12688 +#include <asm/alternative-asm.h>
12689
12690 # enter salsa20_encrypt_bytes
12691 ENTRY(salsa20_encrypt_bytes)
12692 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12693 add %r11,%rsp
12694 mov %rdi,%rax
12695 mov %rsi,%rdx
12696 + pax_force_retaddr 0, 1
12697 ret
12698 # bytesatleast65:
12699 ._bytesatleast65:
12700 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12701 add %r11,%rsp
12702 mov %rdi,%rax
12703 mov %rsi,%rdx
12704 + pax_force_retaddr
12705 ret
12706 ENDPROC(salsa20_keysetup)
12707
12708 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12709 add %r11,%rsp
12710 mov %rdi,%rax
12711 mov %rsi,%rdx
12712 + pax_force_retaddr
12713 ret
12714 ENDPROC(salsa20_ivsetup)
12715 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12716 index 2f202f4..d9164d6 100644
12717 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12718 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12719 @@ -24,6 +24,7 @@
12720 */
12721
12722 #include <linux/linkage.h>
12723 +#include <asm/alternative-asm.h>
12724 #include "glue_helper-asm-avx.S"
12725
12726 .file "serpent-avx-x86_64-asm_64.S"
12727 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12728 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12729 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12730
12731 + pax_force_retaddr
12732 ret;
12733 ENDPROC(__serpent_enc_blk8_avx)
12734
12735 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12736 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12737 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12738
12739 + pax_force_retaddr
12740 ret;
12741 ENDPROC(__serpent_dec_blk8_avx)
12742
12743 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12744
12745 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12746
12747 + pax_force_retaddr
12748 ret;
12749 ENDPROC(serpent_ecb_enc_8way_avx)
12750
12751 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12752
12753 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12754
12755 + pax_force_retaddr
12756 ret;
12757 ENDPROC(serpent_ecb_dec_8way_avx)
12758
12759 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12760
12761 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12762
12763 + pax_force_retaddr
12764 ret;
12765 ENDPROC(serpent_cbc_dec_8way_avx)
12766
12767 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12768
12769 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12770
12771 + pax_force_retaddr
12772 ret;
12773 ENDPROC(serpent_ctr_8way_avx)
12774
12775 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12776 /* dst <= regs xor IVs(in dst) */
12777 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12778
12779 + pax_force_retaddr
12780 ret;
12781 ENDPROC(serpent_xts_enc_8way_avx)
12782
12783 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12784 /* dst <= regs xor IVs(in dst) */
12785 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12786
12787 + pax_force_retaddr
12788 ret;
12789 ENDPROC(serpent_xts_dec_8way_avx)
12790 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12791 index b222085..abd483c 100644
12792 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12793 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12794 @@ -15,6 +15,7 @@
12795 */
12796
12797 #include <linux/linkage.h>
12798 +#include <asm/alternative-asm.h>
12799 #include "glue_helper-asm-avx2.S"
12800
12801 .file "serpent-avx2-asm_64.S"
12802 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12803 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12804 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12805
12806 + pax_force_retaddr
12807 ret;
12808 ENDPROC(__serpent_enc_blk16)
12809
12810 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12811 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12812 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12813
12814 + pax_force_retaddr
12815 ret;
12816 ENDPROC(__serpent_dec_blk16)
12817
12818 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12819
12820 vzeroupper;
12821
12822 + pax_force_retaddr
12823 ret;
12824 ENDPROC(serpent_ecb_enc_16way)
12825
12826 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12827
12828 vzeroupper;
12829
12830 + pax_force_retaddr
12831 ret;
12832 ENDPROC(serpent_ecb_dec_16way)
12833
12834 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12835
12836 vzeroupper;
12837
12838 + pax_force_retaddr
12839 ret;
12840 ENDPROC(serpent_cbc_dec_16way)
12841
12842 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12843
12844 vzeroupper;
12845
12846 + pax_force_retaddr
12847 ret;
12848 ENDPROC(serpent_ctr_16way)
12849
12850 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12851
12852 vzeroupper;
12853
12854 + pax_force_retaddr
12855 ret;
12856 ENDPROC(serpent_xts_enc_16way)
12857
12858 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12859
12860 vzeroupper;
12861
12862 + pax_force_retaddr
12863 ret;
12864 ENDPROC(serpent_xts_dec_16way)
12865 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12866 index acc066c..1559cc4 100644
12867 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12868 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12869 @@ -25,6 +25,7 @@
12870 */
12871
12872 #include <linux/linkage.h>
12873 +#include <asm/alternative-asm.h>
12874
12875 .file "serpent-sse2-x86_64-asm_64.S"
12876 .text
12877 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12878 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12879 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12880
12881 + pax_force_retaddr
12882 ret;
12883
12884 .L__enc_xor8:
12885 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12886 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12887
12888 + pax_force_retaddr
12889 ret;
12890 ENDPROC(__serpent_enc_blk_8way)
12891
12892 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12893 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12894 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12895
12896 + pax_force_retaddr
12897 ret;
12898 ENDPROC(serpent_dec_blk_8way)
12899 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12900 index a410950..3356d42 100644
12901 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12902 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12903 @@ -29,6 +29,7 @@
12904 */
12905
12906 #include <linux/linkage.h>
12907 +#include <asm/alternative-asm.h>
12908
12909 #define CTX %rdi // arg1
12910 #define BUF %rsi // arg2
12911 @@ -104,6 +105,7 @@
12912 pop %r12
12913 pop %rbp
12914 pop %rbx
12915 + pax_force_retaddr 0, 1
12916 ret
12917
12918 ENDPROC(\name)
12919 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
12920 index 642f156..4ab07b9 100644
12921 --- a/arch/x86/crypto/sha256-avx-asm.S
12922 +++ b/arch/x86/crypto/sha256-avx-asm.S
12923 @@ -49,6 +49,7 @@
12924
12925 #ifdef CONFIG_AS_AVX
12926 #include <linux/linkage.h>
12927 +#include <asm/alternative-asm.h>
12928
12929 ## assume buffers not aligned
12930 #define VMOVDQ vmovdqu
12931 @@ -460,6 +461,7 @@ done_hash:
12932 popq %r13
12933 popq %rbp
12934 popq %rbx
12935 + pax_force_retaddr 0, 1
12936 ret
12937 ENDPROC(sha256_transform_avx)
12938
12939 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
12940 index 9e86944..2e7f95a 100644
12941 --- a/arch/x86/crypto/sha256-avx2-asm.S
12942 +++ b/arch/x86/crypto/sha256-avx2-asm.S
12943 @@ -50,6 +50,7 @@
12944
12945 #ifdef CONFIG_AS_AVX2
12946 #include <linux/linkage.h>
12947 +#include <asm/alternative-asm.h>
12948
12949 ## assume buffers not aligned
12950 #define VMOVDQ vmovdqu
12951 @@ -720,6 +721,7 @@ done_hash:
12952 popq %r12
12953 popq %rbp
12954 popq %rbx
12955 + pax_force_retaddr 0, 1
12956 ret
12957 ENDPROC(sha256_transform_rorx)
12958
12959 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
12960 index f833b74..c36ed14 100644
12961 --- a/arch/x86/crypto/sha256-ssse3-asm.S
12962 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
12963 @@ -47,6 +47,7 @@
12964 ########################################################################
12965
12966 #include <linux/linkage.h>
12967 +#include <asm/alternative-asm.h>
12968
12969 ## assume buffers not aligned
12970 #define MOVDQ movdqu
12971 @@ -471,6 +472,7 @@ done_hash:
12972 popq %rbp
12973 popq %rbx
12974
12975 + pax_force_retaddr 0, 1
12976 ret
12977 ENDPROC(sha256_transform_ssse3)
12978
12979 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
12980 index 974dde9..4533d34 100644
12981 --- a/arch/x86/crypto/sha512-avx-asm.S
12982 +++ b/arch/x86/crypto/sha512-avx-asm.S
12983 @@ -49,6 +49,7 @@
12984
12985 #ifdef CONFIG_AS_AVX
12986 #include <linux/linkage.h>
12987 +#include <asm/alternative-asm.h>
12988
12989 .text
12990
12991 @@ -364,6 +365,7 @@ updateblock:
12992 mov frame_RSPSAVE(%rsp), %rsp
12993
12994 nowork:
12995 + pax_force_retaddr 0, 1
12996 ret
12997 ENDPROC(sha512_transform_avx)
12998
12999 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13000 index 568b961..061ef1d 100644
13001 --- a/arch/x86/crypto/sha512-avx2-asm.S
13002 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13003 @@ -51,6 +51,7 @@
13004
13005 #ifdef CONFIG_AS_AVX2
13006 #include <linux/linkage.h>
13007 +#include <asm/alternative-asm.h>
13008
13009 .text
13010
13011 @@ -678,6 +679,7 @@ done_hash:
13012
13013 # Restore Stack Pointer
13014 mov frame_RSPSAVE(%rsp), %rsp
13015 + pax_force_retaddr 0, 1
13016 ret
13017 ENDPROC(sha512_transform_rorx)
13018
13019 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13020 index fb56855..e23914f 100644
13021 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13022 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13023 @@ -48,6 +48,7 @@
13024 ########################################################################
13025
13026 #include <linux/linkage.h>
13027 +#include <asm/alternative-asm.h>
13028
13029 .text
13030
13031 @@ -363,6 +364,7 @@ updateblock:
13032 mov frame_RSPSAVE(%rsp), %rsp
13033
13034 nowork:
13035 + pax_force_retaddr 0, 1
13036 ret
13037 ENDPROC(sha512_transform_ssse3)
13038
13039 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13040 index 0505813..63b1d00 100644
13041 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13042 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13043 @@ -24,6 +24,7 @@
13044 */
13045
13046 #include <linux/linkage.h>
13047 +#include <asm/alternative-asm.h>
13048 #include "glue_helper-asm-avx.S"
13049
13050 .file "twofish-avx-x86_64-asm_64.S"
13051 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13052 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13053 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13054
13055 + pax_force_retaddr 0, 1
13056 ret;
13057 ENDPROC(__twofish_enc_blk8)
13058
13059 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13060 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13061 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13062
13063 + pax_force_retaddr 0, 1
13064 ret;
13065 ENDPROC(__twofish_dec_blk8)
13066
13067 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13068
13069 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13070
13071 + pax_force_retaddr 0, 1
13072 ret;
13073 ENDPROC(twofish_ecb_enc_8way)
13074
13075 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13076
13077 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13078
13079 + pax_force_retaddr 0, 1
13080 ret;
13081 ENDPROC(twofish_ecb_dec_8way)
13082
13083 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13084
13085 popq %r12;
13086
13087 + pax_force_retaddr 0, 1
13088 ret;
13089 ENDPROC(twofish_cbc_dec_8way)
13090
13091 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13092
13093 popq %r12;
13094
13095 + pax_force_retaddr 0, 1
13096 ret;
13097 ENDPROC(twofish_ctr_8way)
13098
13099 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13100 /* dst <= regs xor IVs(in dst) */
13101 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13102
13103 + pax_force_retaddr 0, 1
13104 ret;
13105 ENDPROC(twofish_xts_enc_8way)
13106
13107 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13108 /* dst <= regs xor IVs(in dst) */
13109 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13110
13111 + pax_force_retaddr 0, 1
13112 ret;
13113 ENDPROC(twofish_xts_dec_8way)
13114 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13115 index 1c3b7ce..b365c5e 100644
13116 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13117 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13118 @@ -21,6 +21,7 @@
13119 */
13120
13121 #include <linux/linkage.h>
13122 +#include <asm/alternative-asm.h>
13123
13124 .file "twofish-x86_64-asm-3way.S"
13125 .text
13126 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13127 popq %r13;
13128 popq %r14;
13129 popq %r15;
13130 + pax_force_retaddr 0, 1
13131 ret;
13132
13133 .L__enc_xor3:
13134 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13135 popq %r13;
13136 popq %r14;
13137 popq %r15;
13138 + pax_force_retaddr 0, 1
13139 ret;
13140 ENDPROC(__twofish_enc_blk_3way)
13141
13142 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13143 popq %r13;
13144 popq %r14;
13145 popq %r15;
13146 + pax_force_retaddr 0, 1
13147 ret;
13148 ENDPROC(twofish_dec_blk_3way)
13149 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13150 index a039d21..29e7615 100644
13151 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13152 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13153 @@ -22,6 +22,7 @@
13154
13155 #include <linux/linkage.h>
13156 #include <asm/asm-offsets.h>
13157 +#include <asm/alternative-asm.h>
13158
13159 #define a_offset 0
13160 #define b_offset 4
13161 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13162
13163 popq R1
13164 movq $1,%rax
13165 + pax_force_retaddr 0, 1
13166 ret
13167 ENDPROC(twofish_enc_blk)
13168
13169 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13170
13171 popq R1
13172 movq $1,%rax
13173 + pax_force_retaddr 0, 1
13174 ret
13175 ENDPROC(twofish_dec_blk)
13176 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13177 index bae3aba..c1788c1 100644
13178 --- a/arch/x86/ia32/ia32_aout.c
13179 +++ b/arch/x86/ia32/ia32_aout.c
13180 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13181 unsigned long dump_start, dump_size;
13182 struct user32 dump;
13183
13184 + memset(&dump, 0, sizeof(dump));
13185 +
13186 fs = get_fs();
13187 set_fs(KERNEL_DS);
13188 has_dumped = 1;
13189 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13190 index bccfca6..a312009 100644
13191 --- a/arch/x86/ia32/ia32_signal.c
13192 +++ b/arch/x86/ia32/ia32_signal.c
13193 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13194 sp -= frame_size;
13195 /* Align the stack pointer according to the i386 ABI,
13196 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13197 - sp = ((sp + 4) & -16ul) - 4;
13198 + sp = ((sp - 12) & -16ul) - 4;
13199 return (void __user *) sp;
13200 }
13201
13202 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13203 * These are actually not used anymore, but left because some
13204 * gdb versions depend on them as a marker.
13205 */
13206 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13207 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13208 } put_user_catch(err);
13209
13210 if (err)
13211 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13212 0xb8,
13213 __NR_ia32_rt_sigreturn,
13214 0x80cd,
13215 - 0,
13216 + 0
13217 };
13218
13219 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13220 @@ -457,20 +457,22 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13221 else
13222 put_user_ex(0, &frame->uc.uc_flags);
13223 put_user_ex(0, &frame->uc.uc_link);
13224 - err |= __compat_save_altstack(&frame->uc.uc_stack, regs->sp);
13225 + __compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
13226
13227 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13228 restorer = ksig->ka.sa.sa_restorer;
13229 + else if (current->mm->context.vdso)
13230 + /* Return stub is in 32bit vsyscall page */
13231 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13232 else
13233 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13234 - rt_sigreturn);
13235 + restorer = &frame->retcode;
13236 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13237
13238 /*
13239 * Not actually used anymore, but left because some gdb
13240 * versions need it.
13241 */
13242 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13243 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13244 } put_user_catch(err);
13245
13246 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13247 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13248 index 474dc1b..9297c58 100644
13249 --- a/arch/x86/ia32/ia32entry.S
13250 +++ b/arch/x86/ia32/ia32entry.S
13251 @@ -15,8 +15,10 @@
13252 #include <asm/irqflags.h>
13253 #include <asm/asm.h>
13254 #include <asm/smap.h>
13255 +#include <asm/pgtable.h>
13256 #include <linux/linkage.h>
13257 #include <linux/err.h>
13258 +#include <asm/alternative-asm.h>
13259
13260 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13261 #include <linux/elf-em.h>
13262 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13263 ENDPROC(native_irq_enable_sysexit)
13264 #endif
13265
13266 + .macro pax_enter_kernel_user
13267 + pax_set_fptr_mask
13268 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13269 + call pax_enter_kernel_user
13270 +#endif
13271 + .endm
13272 +
13273 + .macro pax_exit_kernel_user
13274 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13275 + call pax_exit_kernel_user
13276 +#endif
13277 +#ifdef CONFIG_PAX_RANDKSTACK
13278 + pushq %rax
13279 + pushq %r11
13280 + call pax_randomize_kstack
13281 + popq %r11
13282 + popq %rax
13283 +#endif
13284 + .endm
13285 +
13286 + .macro pax_erase_kstack
13287 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13288 + call pax_erase_kstack
13289 +#endif
13290 + .endm
13291 +
13292 /*
13293 * 32bit SYSENTER instruction entry.
13294 *
13295 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13296 CFI_REGISTER rsp,rbp
13297 SWAPGS_UNSAFE_STACK
13298 movq PER_CPU_VAR(kernel_stack), %rsp
13299 - addq $(KERNEL_STACK_OFFSET),%rsp
13300 - /*
13301 - * No need to follow this irqs on/off section: the syscall
13302 - * disabled irqs, here we enable it straight after entry:
13303 - */
13304 - ENABLE_INTERRUPTS(CLBR_NONE)
13305 movl %ebp,%ebp /* zero extension */
13306 pushq_cfi $__USER32_DS
13307 /*CFI_REL_OFFSET ss,0*/
13308 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13309 CFI_REL_OFFSET rsp,0
13310 pushfq_cfi
13311 /*CFI_REL_OFFSET rflags,0*/
13312 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13313 - CFI_REGISTER rip,r10
13314 + orl $X86_EFLAGS_IF,(%rsp)
13315 + GET_THREAD_INFO(%r11)
13316 + movl TI_sysenter_return(%r11), %r11d
13317 + CFI_REGISTER rip,r11
13318 pushq_cfi $__USER32_CS
13319 /*CFI_REL_OFFSET cs,0*/
13320 movl %eax, %eax
13321 - pushq_cfi %r10
13322 + pushq_cfi %r11
13323 CFI_REL_OFFSET rip,0
13324 pushq_cfi %rax
13325 cld
13326 SAVE_ARGS 0,1,0
13327 + pax_enter_kernel_user
13328 +
13329 +#ifdef CONFIG_PAX_RANDKSTACK
13330 + pax_erase_kstack
13331 +#endif
13332 +
13333 + /*
13334 + * No need to follow this irqs on/off section: the syscall
13335 + * disabled irqs, here we enable it straight after entry:
13336 + */
13337 + ENABLE_INTERRUPTS(CLBR_NONE)
13338 /* no need to do an access_ok check here because rbp has been
13339 32bit zero extended */
13340 +
13341 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13342 + addq pax_user_shadow_base,%rbp
13343 + ASM_PAX_OPEN_USERLAND
13344 +#endif
13345 +
13346 ASM_STAC
13347 1: movl (%rbp),%ebp
13348 _ASM_EXTABLE(1b,ia32_badarg)
13349 ASM_CLAC
13350 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13351 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13352 +
13353 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13354 + ASM_PAX_CLOSE_USERLAND
13355 +#endif
13356 +
13357 + GET_THREAD_INFO(%r11)
13358 + orl $TS_COMPAT,TI_status(%r11)
13359 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13360 CFI_REMEMBER_STATE
13361 jnz sysenter_tracesys
13362 cmpq $(IA32_NR_syscalls-1),%rax
13363 @@ -162,12 +209,15 @@ sysenter_do_call:
13364 sysenter_dispatch:
13365 call *ia32_sys_call_table(,%rax,8)
13366 movq %rax,RAX-ARGOFFSET(%rsp)
13367 + GET_THREAD_INFO(%r11)
13368 DISABLE_INTERRUPTS(CLBR_NONE)
13369 TRACE_IRQS_OFF
13370 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13371 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13372 jnz sysexit_audit
13373 sysexit_from_sys_call:
13374 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13375 + pax_exit_kernel_user
13376 + pax_erase_kstack
13377 + andl $~TS_COMPAT,TI_status(%r11)
13378 /* clear IF, that popfq doesn't enable interrupts early */
13379 andl $~0x200,EFLAGS-R11(%rsp)
13380 movl RIP-R11(%rsp),%edx /* User %eip */
13381 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13382 movl %eax,%esi /* 2nd arg: syscall number */
13383 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13384 call __audit_syscall_entry
13385 +
13386 + pax_erase_kstack
13387 +
13388 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13389 cmpq $(IA32_NR_syscalls-1),%rax
13390 ja ia32_badsys
13391 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13392 .endm
13393
13394 .macro auditsys_exit exit
13395 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13396 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13397 jnz ia32_ret_from_sys_call
13398 TRACE_IRQS_ON
13399 ENABLE_INTERRUPTS(CLBR_NONE)
13400 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13401 1: setbe %al /* 1 if error, 0 if not */
13402 movzbl %al,%edi /* zero-extend that into %edi */
13403 call __audit_syscall_exit
13404 + GET_THREAD_INFO(%r11)
13405 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13406 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13407 DISABLE_INTERRUPTS(CLBR_NONE)
13408 TRACE_IRQS_OFF
13409 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13410 + testl %edi,TI_flags(%r11)
13411 jz \exit
13412 CLEAR_RREGS -ARGOFFSET
13413 jmp int_with_check
13414 @@ -237,7 +291,7 @@ sysexit_audit:
13415
13416 sysenter_tracesys:
13417 #ifdef CONFIG_AUDITSYSCALL
13418 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13419 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13420 jz sysenter_auditsys
13421 #endif
13422 SAVE_REST
13423 @@ -249,6 +303,9 @@ sysenter_tracesys:
13424 RESTORE_REST
13425 cmpq $(IA32_NR_syscalls-1),%rax
13426 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13427 +
13428 + pax_erase_kstack
13429 +
13430 jmp sysenter_do_call
13431 CFI_ENDPROC
13432 ENDPROC(ia32_sysenter_target)
13433 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13434 ENTRY(ia32_cstar_target)
13435 CFI_STARTPROC32 simple
13436 CFI_SIGNAL_FRAME
13437 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13438 + CFI_DEF_CFA rsp,0
13439 CFI_REGISTER rip,rcx
13440 /*CFI_REGISTER rflags,r11*/
13441 SWAPGS_UNSAFE_STACK
13442 movl %esp,%r8d
13443 CFI_REGISTER rsp,r8
13444 movq PER_CPU_VAR(kernel_stack),%rsp
13445 + SAVE_ARGS 8*6,0,0
13446 + pax_enter_kernel_user
13447 +
13448 +#ifdef CONFIG_PAX_RANDKSTACK
13449 + pax_erase_kstack
13450 +#endif
13451 +
13452 /*
13453 * No need to follow this irqs on/off section: the syscall
13454 * disabled irqs and here we enable it straight after entry:
13455 */
13456 ENABLE_INTERRUPTS(CLBR_NONE)
13457 - SAVE_ARGS 8,0,0
13458 movl %eax,%eax /* zero extension */
13459 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13460 movq %rcx,RIP-ARGOFFSET(%rsp)
13461 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13462 /* no need to do an access_ok check here because r8 has been
13463 32bit zero extended */
13464 /* hardware stack frame is complete now */
13465 +
13466 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13467 + ASM_PAX_OPEN_USERLAND
13468 + movq pax_user_shadow_base,%r8
13469 + addq RSP-ARGOFFSET(%rsp),%r8
13470 +#endif
13471 +
13472 ASM_STAC
13473 1: movl (%r8),%r9d
13474 _ASM_EXTABLE(1b,ia32_badarg)
13475 ASM_CLAC
13476 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13477 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13478 +
13479 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13480 + ASM_PAX_CLOSE_USERLAND
13481 +#endif
13482 +
13483 + GET_THREAD_INFO(%r11)
13484 + orl $TS_COMPAT,TI_status(%r11)
13485 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13486 CFI_REMEMBER_STATE
13487 jnz cstar_tracesys
13488 cmpq $IA32_NR_syscalls-1,%rax
13489 @@ -319,12 +395,15 @@ cstar_do_call:
13490 cstar_dispatch:
13491 call *ia32_sys_call_table(,%rax,8)
13492 movq %rax,RAX-ARGOFFSET(%rsp)
13493 + GET_THREAD_INFO(%r11)
13494 DISABLE_INTERRUPTS(CLBR_NONE)
13495 TRACE_IRQS_OFF
13496 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13497 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13498 jnz sysretl_audit
13499 sysretl_from_sys_call:
13500 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13501 + pax_exit_kernel_user
13502 + pax_erase_kstack
13503 + andl $~TS_COMPAT,TI_status(%r11)
13504 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13505 movl RIP-ARGOFFSET(%rsp),%ecx
13506 CFI_REGISTER rip,rcx
13507 @@ -352,7 +431,7 @@ sysretl_audit:
13508
13509 cstar_tracesys:
13510 #ifdef CONFIG_AUDITSYSCALL
13511 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13512 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13513 jz cstar_auditsys
13514 #endif
13515 xchgl %r9d,%ebp
13516 @@ -366,11 +445,19 @@ cstar_tracesys:
13517 xchgl %ebp,%r9d
13518 cmpq $(IA32_NR_syscalls-1),%rax
13519 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13520 +
13521 + pax_erase_kstack
13522 +
13523 jmp cstar_do_call
13524 END(ia32_cstar_target)
13525
13526 ia32_badarg:
13527 ASM_CLAC
13528 +
13529 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13530 + ASM_PAX_CLOSE_USERLAND
13531 +#endif
13532 +
13533 movq $-EFAULT,%rax
13534 jmp ia32_sysret
13535 CFI_ENDPROC
13536 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13537 CFI_REL_OFFSET rip,RIP-RIP
13538 PARAVIRT_ADJUST_EXCEPTION_FRAME
13539 SWAPGS
13540 - /*
13541 - * No need to follow this irqs on/off section: the syscall
13542 - * disabled irqs and here we enable it straight after entry:
13543 - */
13544 - ENABLE_INTERRUPTS(CLBR_NONE)
13545 movl %eax,%eax
13546 pushq_cfi %rax
13547 cld
13548 /* note the registers are not zero extended to the sf.
13549 this could be a problem. */
13550 SAVE_ARGS 0,1,0
13551 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13552 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13553 + pax_enter_kernel_user
13554 +
13555 +#ifdef CONFIG_PAX_RANDKSTACK
13556 + pax_erase_kstack
13557 +#endif
13558 +
13559 + /*
13560 + * No need to follow this irqs on/off section: the syscall
13561 + * disabled irqs and here we enable it straight after entry:
13562 + */
13563 + ENABLE_INTERRUPTS(CLBR_NONE)
13564 + GET_THREAD_INFO(%r11)
13565 + orl $TS_COMPAT,TI_status(%r11)
13566 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13567 jnz ia32_tracesys
13568 cmpq $(IA32_NR_syscalls-1),%rax
13569 ja ia32_badsys
13570 @@ -442,6 +536,9 @@ ia32_tracesys:
13571 RESTORE_REST
13572 cmpq $(IA32_NR_syscalls-1),%rax
13573 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13574 +
13575 + pax_erase_kstack
13576 +
13577 jmp ia32_do_call
13578 END(ia32_syscall)
13579
13580 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13581 index 8e0ceec..af13504 100644
13582 --- a/arch/x86/ia32/sys_ia32.c
13583 +++ b/arch/x86/ia32/sys_ia32.c
13584 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13585 */
13586 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13587 {
13588 - typeof(ubuf->st_uid) uid = 0;
13589 - typeof(ubuf->st_gid) gid = 0;
13590 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13591 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13592 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13593 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13594 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13595 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13596 index 372231c..a5aa1a1 100644
13597 --- a/arch/x86/include/asm/alternative-asm.h
13598 +++ b/arch/x86/include/asm/alternative-asm.h
13599 @@ -18,6 +18,45 @@
13600 .endm
13601 #endif
13602
13603 +#ifdef KERNEXEC_PLUGIN
13604 + .macro pax_force_retaddr_bts rip=0
13605 + btsq $63,\rip(%rsp)
13606 + .endm
13607 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13608 + .macro pax_force_retaddr rip=0, reload=0
13609 + btsq $63,\rip(%rsp)
13610 + .endm
13611 + .macro pax_force_fptr ptr
13612 + btsq $63,\ptr
13613 + .endm
13614 + .macro pax_set_fptr_mask
13615 + .endm
13616 +#endif
13617 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13618 + .macro pax_force_retaddr rip=0, reload=0
13619 + .if \reload
13620 + pax_set_fptr_mask
13621 + .endif
13622 + orq %r10,\rip(%rsp)
13623 + .endm
13624 + .macro pax_force_fptr ptr
13625 + orq %r10,\ptr
13626 + .endm
13627 + .macro pax_set_fptr_mask
13628 + movabs $0x8000000000000000,%r10
13629 + .endm
13630 +#endif
13631 +#else
13632 + .macro pax_force_retaddr rip=0, reload=0
13633 + .endm
13634 + .macro pax_force_fptr ptr
13635 + .endm
13636 + .macro pax_force_retaddr_bts rip=0
13637 + .endm
13638 + .macro pax_set_fptr_mask
13639 + .endm
13640 +#endif
13641 +
13642 .macro altinstruction_entry orig alt feature orig_len alt_len
13643 .long \orig - .
13644 .long \alt - .
13645 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13646 index 58ed6d9..f1cbe58 100644
13647 --- a/arch/x86/include/asm/alternative.h
13648 +++ b/arch/x86/include/asm/alternative.h
13649 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13650 ".pushsection .discard,\"aw\",@progbits\n" \
13651 DISCARD_ENTRY(1) \
13652 ".popsection\n" \
13653 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13654 + ".pushsection .altinstr_replacement, \"a\"\n" \
13655 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13656 ".popsection"
13657
13658 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13659 DISCARD_ENTRY(1) \
13660 DISCARD_ENTRY(2) \
13661 ".popsection\n" \
13662 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13663 + ".pushsection .altinstr_replacement, \"a\"\n" \
13664 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13665 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13666 ".popsection"
13667 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13668 index f8119b5..7209d5b 100644
13669 --- a/arch/x86/include/asm/apic.h
13670 +++ b/arch/x86/include/asm/apic.h
13671 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13672
13673 #ifdef CONFIG_X86_LOCAL_APIC
13674
13675 -extern unsigned int apic_verbosity;
13676 +extern int apic_verbosity;
13677 extern int local_apic_timer_c2_ok;
13678
13679 extern int disable_apic;
13680 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13681 index 20370c6..a2eb9b0 100644
13682 --- a/arch/x86/include/asm/apm.h
13683 +++ b/arch/x86/include/asm/apm.h
13684 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13685 __asm__ __volatile__(APM_DO_ZERO_SEGS
13686 "pushl %%edi\n\t"
13687 "pushl %%ebp\n\t"
13688 - "lcall *%%cs:apm_bios_entry\n\t"
13689 + "lcall *%%ss:apm_bios_entry\n\t"
13690 "setc %%al\n\t"
13691 "popl %%ebp\n\t"
13692 "popl %%edi\n\t"
13693 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13694 __asm__ __volatile__(APM_DO_ZERO_SEGS
13695 "pushl %%edi\n\t"
13696 "pushl %%ebp\n\t"
13697 - "lcall *%%cs:apm_bios_entry\n\t"
13698 + "lcall *%%ss:apm_bios_entry\n\t"
13699 "setc %%bl\n\t"
13700 "popl %%ebp\n\t"
13701 "popl %%edi\n\t"
13702 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13703 index 722aa3b..3a0bb27 100644
13704 --- a/arch/x86/include/asm/atomic.h
13705 +++ b/arch/x86/include/asm/atomic.h
13706 @@ -22,7 +22,18 @@
13707 */
13708 static inline int atomic_read(const atomic_t *v)
13709 {
13710 - return (*(volatile int *)&(v)->counter);
13711 + return (*(volatile const int *)&(v)->counter);
13712 +}
13713 +
13714 +/**
13715 + * atomic_read_unchecked - read atomic variable
13716 + * @v: pointer of type atomic_unchecked_t
13717 + *
13718 + * Atomically reads the value of @v.
13719 + */
13720 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13721 +{
13722 + return (*(volatile const int *)&(v)->counter);
13723 }
13724
13725 /**
13726 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13727 }
13728
13729 /**
13730 + * atomic_set_unchecked - set atomic variable
13731 + * @v: pointer of type atomic_unchecked_t
13732 + * @i: required value
13733 + *
13734 + * Atomically sets the value of @v to @i.
13735 + */
13736 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13737 +{
13738 + v->counter = i;
13739 +}
13740 +
13741 +/**
13742 * atomic_add - add integer to atomic variable
13743 * @i: integer value to add
13744 * @v: pointer of type atomic_t
13745 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13746 */
13747 static inline void atomic_add(int i, atomic_t *v)
13748 {
13749 - asm volatile(LOCK_PREFIX "addl %1,%0"
13750 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13751 +
13752 +#ifdef CONFIG_PAX_REFCOUNT
13753 + "jno 0f\n"
13754 + LOCK_PREFIX "subl %1,%0\n"
13755 + "int $4\n0:\n"
13756 + _ASM_EXTABLE(0b, 0b)
13757 +#endif
13758 +
13759 + : "+m" (v->counter)
13760 + : "ir" (i));
13761 +}
13762 +
13763 +/**
13764 + * atomic_add_unchecked - add integer to atomic variable
13765 + * @i: integer value to add
13766 + * @v: pointer of type atomic_unchecked_t
13767 + *
13768 + * Atomically adds @i to @v.
13769 + */
13770 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13771 +{
13772 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13773 : "+m" (v->counter)
13774 : "ir" (i));
13775 }
13776 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13777 */
13778 static inline void atomic_sub(int i, atomic_t *v)
13779 {
13780 - asm volatile(LOCK_PREFIX "subl %1,%0"
13781 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13782 +
13783 +#ifdef CONFIG_PAX_REFCOUNT
13784 + "jno 0f\n"
13785 + LOCK_PREFIX "addl %1,%0\n"
13786 + "int $4\n0:\n"
13787 + _ASM_EXTABLE(0b, 0b)
13788 +#endif
13789 +
13790 + : "+m" (v->counter)
13791 + : "ir" (i));
13792 +}
13793 +
13794 +/**
13795 + * atomic_sub_unchecked - subtract integer from atomic variable
13796 + * @i: integer value to subtract
13797 + * @v: pointer of type atomic_unchecked_t
13798 + *
13799 + * Atomically subtracts @i from @v.
13800 + */
13801 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13802 +{
13803 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13804 : "+m" (v->counter)
13805 : "ir" (i));
13806 }
13807 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13808 {
13809 unsigned char c;
13810
13811 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13812 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13813 +
13814 +#ifdef CONFIG_PAX_REFCOUNT
13815 + "jno 0f\n"
13816 + LOCK_PREFIX "addl %2,%0\n"
13817 + "int $4\n0:\n"
13818 + _ASM_EXTABLE(0b, 0b)
13819 +#endif
13820 +
13821 + "sete %1\n"
13822 : "+m" (v->counter), "=qm" (c)
13823 : "ir" (i) : "memory");
13824 return c;
13825 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13826 */
13827 static inline void atomic_inc(atomic_t *v)
13828 {
13829 - asm volatile(LOCK_PREFIX "incl %0"
13830 + asm volatile(LOCK_PREFIX "incl %0\n"
13831 +
13832 +#ifdef CONFIG_PAX_REFCOUNT
13833 + "jno 0f\n"
13834 + LOCK_PREFIX "decl %0\n"
13835 + "int $4\n0:\n"
13836 + _ASM_EXTABLE(0b, 0b)
13837 +#endif
13838 +
13839 + : "+m" (v->counter));
13840 +}
13841 +
13842 +/**
13843 + * atomic_inc_unchecked - increment atomic variable
13844 + * @v: pointer of type atomic_unchecked_t
13845 + *
13846 + * Atomically increments @v by 1.
13847 + */
13848 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13849 +{
13850 + asm volatile(LOCK_PREFIX "incl %0\n"
13851 : "+m" (v->counter));
13852 }
13853
13854 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13855 */
13856 static inline void atomic_dec(atomic_t *v)
13857 {
13858 - asm volatile(LOCK_PREFIX "decl %0"
13859 + asm volatile(LOCK_PREFIX "decl %0\n"
13860 +
13861 +#ifdef CONFIG_PAX_REFCOUNT
13862 + "jno 0f\n"
13863 + LOCK_PREFIX "incl %0\n"
13864 + "int $4\n0:\n"
13865 + _ASM_EXTABLE(0b, 0b)
13866 +#endif
13867 +
13868 + : "+m" (v->counter));
13869 +}
13870 +
13871 +/**
13872 + * atomic_dec_unchecked - decrement atomic variable
13873 + * @v: pointer of type atomic_unchecked_t
13874 + *
13875 + * Atomically decrements @v by 1.
13876 + */
13877 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13878 +{
13879 + asm volatile(LOCK_PREFIX "decl %0\n"
13880 : "+m" (v->counter));
13881 }
13882
13883 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13884 {
13885 unsigned char c;
13886
13887 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13888 + asm volatile(LOCK_PREFIX "decl %0\n"
13889 +
13890 +#ifdef CONFIG_PAX_REFCOUNT
13891 + "jno 0f\n"
13892 + LOCK_PREFIX "incl %0\n"
13893 + "int $4\n0:\n"
13894 + _ASM_EXTABLE(0b, 0b)
13895 +#endif
13896 +
13897 + "sete %1\n"
13898 : "+m" (v->counter), "=qm" (c)
13899 : : "memory");
13900 return c != 0;
13901 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13902 {
13903 unsigned char c;
13904
13905 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13906 + asm volatile(LOCK_PREFIX "incl %0\n"
13907 +
13908 +#ifdef CONFIG_PAX_REFCOUNT
13909 + "jno 0f\n"
13910 + LOCK_PREFIX "decl %0\n"
13911 + "int $4\n0:\n"
13912 + _ASM_EXTABLE(0b, 0b)
13913 +#endif
13914 +
13915 + "sete %1\n"
13916 + : "+m" (v->counter), "=qm" (c)
13917 + : : "memory");
13918 + return c != 0;
13919 +}
13920 +
13921 +/**
13922 + * atomic_inc_and_test_unchecked - increment and test
13923 + * @v: pointer of type atomic_unchecked_t
13924 + *
13925 + * Atomically increments @v by 1
13926 + * and returns true if the result is zero, or false for all
13927 + * other cases.
13928 + */
13929 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13930 +{
13931 + unsigned char c;
13932 +
13933 + asm volatile(LOCK_PREFIX "incl %0\n"
13934 + "sete %1\n"
13935 : "+m" (v->counter), "=qm" (c)
13936 : : "memory");
13937 return c != 0;
13938 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13939 {
13940 unsigned char c;
13941
13942 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
13943 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
13944 +
13945 +#ifdef CONFIG_PAX_REFCOUNT
13946 + "jno 0f\n"
13947 + LOCK_PREFIX "subl %2,%0\n"
13948 + "int $4\n0:\n"
13949 + _ASM_EXTABLE(0b, 0b)
13950 +#endif
13951 +
13952 + "sets %1\n"
13953 : "+m" (v->counter), "=qm" (c)
13954 : "ir" (i) : "memory");
13955 return c;
13956 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13957 */
13958 static inline int atomic_add_return(int i, atomic_t *v)
13959 {
13960 + return i + xadd_check_overflow(&v->counter, i);
13961 +}
13962 +
13963 +/**
13964 + * atomic_add_return_unchecked - add integer and return
13965 + * @i: integer value to add
13966 + * @v: pointer of type atomic_unchecked_t
13967 + *
13968 + * Atomically adds @i to @v and returns @i + @v
13969 + */
13970 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
13971 +{
13972 return i + xadd(&v->counter, i);
13973 }
13974
13975 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
13976 }
13977
13978 #define atomic_inc_return(v) (atomic_add_return(1, v))
13979 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
13980 +{
13981 + return atomic_add_return_unchecked(1, v);
13982 +}
13983 #define atomic_dec_return(v) (atomic_sub_return(1, v))
13984
13985 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
13986 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
13987 return cmpxchg(&v->counter, old, new);
13988 }
13989
13990 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
13991 +{
13992 + return cmpxchg(&v->counter, old, new);
13993 +}
13994 +
13995 static inline int atomic_xchg(atomic_t *v, int new)
13996 {
13997 return xchg(&v->counter, new);
13998 }
13999
14000 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14001 +{
14002 + return xchg(&v->counter, new);
14003 +}
14004 +
14005 /**
14006 * __atomic_add_unless - add unless the number is already a given value
14007 * @v: pointer of type atomic_t
14008 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14009 */
14010 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14011 {
14012 - int c, old;
14013 + int c, old, new;
14014 c = atomic_read(v);
14015 for (;;) {
14016 - if (unlikely(c == (u)))
14017 + if (unlikely(c == u))
14018 break;
14019 - old = atomic_cmpxchg((v), c, c + (a));
14020 +
14021 + asm volatile("addl %2,%0\n"
14022 +
14023 +#ifdef CONFIG_PAX_REFCOUNT
14024 + "jno 0f\n"
14025 + "subl %2,%0\n"
14026 + "int $4\n0:\n"
14027 + _ASM_EXTABLE(0b, 0b)
14028 +#endif
14029 +
14030 + : "=r" (new)
14031 + : "0" (c), "ir" (a));
14032 +
14033 + old = atomic_cmpxchg(v, c, new);
14034 if (likely(old == c))
14035 break;
14036 c = old;
14037 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14038 }
14039
14040 /**
14041 + * atomic_inc_not_zero_hint - increment if not null
14042 + * @v: pointer of type atomic_t
14043 + * @hint: probable value of the atomic before the increment
14044 + *
14045 + * This version of atomic_inc_not_zero() gives a hint of probable
14046 + * value of the atomic. This helps processor to not read the memory
14047 + * before doing the atomic read/modify/write cycle, lowering
14048 + * number of bus transactions on some arches.
14049 + *
14050 + * Returns: 0 if increment was not done, 1 otherwise.
14051 + */
14052 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14053 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14054 +{
14055 + int val, c = hint, new;
14056 +
14057 + /* sanity test, should be removed by compiler if hint is a constant */
14058 + if (!hint)
14059 + return __atomic_add_unless(v, 1, 0);
14060 +
14061 + do {
14062 + asm volatile("incl %0\n"
14063 +
14064 +#ifdef CONFIG_PAX_REFCOUNT
14065 + "jno 0f\n"
14066 + "decl %0\n"
14067 + "int $4\n0:\n"
14068 + _ASM_EXTABLE(0b, 0b)
14069 +#endif
14070 +
14071 + : "=r" (new)
14072 + : "0" (c));
14073 +
14074 + val = atomic_cmpxchg(v, c, new);
14075 + if (val == c)
14076 + return 1;
14077 + c = val;
14078 + } while (c);
14079 +
14080 + return 0;
14081 +}
14082 +
14083 +/**
14084 * atomic_inc_short - increment of a short integer
14085 * @v: pointer to type int
14086 *
14087 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14088 #endif
14089
14090 /* These are x86-specific, used by some header files */
14091 -#define atomic_clear_mask(mask, addr) \
14092 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14093 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14094 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14095 +{
14096 + asm volatile(LOCK_PREFIX "andl %1,%0"
14097 + : "+m" (v->counter)
14098 + : "r" (~(mask))
14099 + : "memory");
14100 +}
14101
14102 -#define atomic_set_mask(mask, addr) \
14103 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14104 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14105 - : "memory")
14106 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14107 +{
14108 + asm volatile(LOCK_PREFIX "andl %1,%0"
14109 + : "+m" (v->counter)
14110 + : "r" (~(mask))
14111 + : "memory");
14112 +}
14113 +
14114 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14115 +{
14116 + asm volatile(LOCK_PREFIX "orl %1,%0"
14117 + : "+m" (v->counter)
14118 + : "r" (mask)
14119 + : "memory");
14120 +}
14121 +
14122 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14123 +{
14124 + asm volatile(LOCK_PREFIX "orl %1,%0"
14125 + : "+m" (v->counter)
14126 + : "r" (mask)
14127 + : "memory");
14128 +}
14129
14130 /* Atomic operations are already serializing on x86 */
14131 #define smp_mb__before_atomic_dec() barrier()
14132 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14133 index b154de7..aadebd8 100644
14134 --- a/arch/x86/include/asm/atomic64_32.h
14135 +++ b/arch/x86/include/asm/atomic64_32.h
14136 @@ -12,6 +12,14 @@ typedef struct {
14137 u64 __aligned(8) counter;
14138 } atomic64_t;
14139
14140 +#ifdef CONFIG_PAX_REFCOUNT
14141 +typedef struct {
14142 + u64 __aligned(8) counter;
14143 +} atomic64_unchecked_t;
14144 +#else
14145 +typedef atomic64_t atomic64_unchecked_t;
14146 +#endif
14147 +
14148 #define ATOMIC64_INIT(val) { (val) }
14149
14150 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14151 @@ -37,21 +45,31 @@ typedef struct {
14152 ATOMIC64_DECL_ONE(sym##_386)
14153
14154 ATOMIC64_DECL_ONE(add_386);
14155 +ATOMIC64_DECL_ONE(add_unchecked_386);
14156 ATOMIC64_DECL_ONE(sub_386);
14157 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14158 ATOMIC64_DECL_ONE(inc_386);
14159 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14160 ATOMIC64_DECL_ONE(dec_386);
14161 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14162 #endif
14163
14164 #define alternative_atomic64(f, out, in...) \
14165 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14166
14167 ATOMIC64_DECL(read);
14168 +ATOMIC64_DECL(read_unchecked);
14169 ATOMIC64_DECL(set);
14170 +ATOMIC64_DECL(set_unchecked);
14171 ATOMIC64_DECL(xchg);
14172 ATOMIC64_DECL(add_return);
14173 +ATOMIC64_DECL(add_return_unchecked);
14174 ATOMIC64_DECL(sub_return);
14175 +ATOMIC64_DECL(sub_return_unchecked);
14176 ATOMIC64_DECL(inc_return);
14177 +ATOMIC64_DECL(inc_return_unchecked);
14178 ATOMIC64_DECL(dec_return);
14179 +ATOMIC64_DECL(dec_return_unchecked);
14180 ATOMIC64_DECL(dec_if_positive);
14181 ATOMIC64_DECL(inc_not_zero);
14182 ATOMIC64_DECL(add_unless);
14183 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14184 }
14185
14186 /**
14187 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14188 + * @p: pointer to type atomic64_unchecked_t
14189 + * @o: expected value
14190 + * @n: new value
14191 + *
14192 + * Atomically sets @v to @n if it was equal to @o and returns
14193 + * the old value.
14194 + */
14195 +
14196 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14197 +{
14198 + return cmpxchg64(&v->counter, o, n);
14199 +}
14200 +
14201 +/**
14202 * atomic64_xchg - xchg atomic64 variable
14203 * @v: pointer to type atomic64_t
14204 * @n: value to assign
14205 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14206 }
14207
14208 /**
14209 + * atomic64_set_unchecked - set atomic64 variable
14210 + * @v: pointer to type atomic64_unchecked_t
14211 + * @n: value to assign
14212 + *
14213 + * Atomically sets the value of @v to @n.
14214 + */
14215 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14216 +{
14217 + unsigned high = (unsigned)(i >> 32);
14218 + unsigned low = (unsigned)i;
14219 + alternative_atomic64(set, /* no output */,
14220 + "S" (v), "b" (low), "c" (high)
14221 + : "eax", "edx", "memory");
14222 +}
14223 +
14224 +/**
14225 * atomic64_read - read atomic64 variable
14226 * @v: pointer to type atomic64_t
14227 *
14228 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14229 }
14230
14231 /**
14232 + * atomic64_read_unchecked - read atomic64 variable
14233 + * @v: pointer to type atomic64_unchecked_t
14234 + *
14235 + * Atomically reads the value of @v and returns it.
14236 + */
14237 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14238 +{
14239 + long long r;
14240 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14241 + return r;
14242 + }
14243 +
14244 +/**
14245 * atomic64_add_return - add and return
14246 * @i: integer value to add
14247 * @v: pointer to type atomic64_t
14248 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14249 return i;
14250 }
14251
14252 +/**
14253 + * atomic64_add_return_unchecked - add and return
14254 + * @i: integer value to add
14255 + * @v: pointer to type atomic64_unchecked_t
14256 + *
14257 + * Atomically adds @i to @v and returns @i + *@v
14258 + */
14259 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14260 +{
14261 + alternative_atomic64(add_return_unchecked,
14262 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14263 + ASM_NO_INPUT_CLOBBER("memory"));
14264 + return i;
14265 +}
14266 +
14267 /*
14268 * Other variants with different arithmetic operators:
14269 */
14270 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14271 return a;
14272 }
14273
14274 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14275 +{
14276 + long long a;
14277 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14278 + "S" (v) : "memory", "ecx");
14279 + return a;
14280 +}
14281 +
14282 static inline long long atomic64_dec_return(atomic64_t *v)
14283 {
14284 long long a;
14285 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14286 }
14287
14288 /**
14289 + * atomic64_add_unchecked - add integer to atomic64 variable
14290 + * @i: integer value to add
14291 + * @v: pointer to type atomic64_unchecked_t
14292 + *
14293 + * Atomically adds @i to @v.
14294 + */
14295 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14296 +{
14297 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14298 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14299 + ASM_NO_INPUT_CLOBBER("memory"));
14300 + return i;
14301 +}
14302 +
14303 +/**
14304 * atomic64_sub - subtract the atomic64 variable
14305 * @i: integer value to subtract
14306 * @v: pointer to type atomic64_t
14307 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14308 index 0e1cbfc..5623683 100644
14309 --- a/arch/x86/include/asm/atomic64_64.h
14310 +++ b/arch/x86/include/asm/atomic64_64.h
14311 @@ -18,7 +18,19 @@
14312 */
14313 static inline long atomic64_read(const atomic64_t *v)
14314 {
14315 - return (*(volatile long *)&(v)->counter);
14316 + return (*(volatile const long *)&(v)->counter);
14317 +}
14318 +
14319 +/**
14320 + * atomic64_read_unchecked - read atomic64 variable
14321 + * @v: pointer of type atomic64_unchecked_t
14322 + *
14323 + * Atomically reads the value of @v.
14324 + * Doesn't imply a read memory barrier.
14325 + */
14326 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14327 +{
14328 + return (*(volatile const long *)&(v)->counter);
14329 }
14330
14331 /**
14332 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14333 }
14334
14335 /**
14336 + * atomic64_set_unchecked - set atomic64 variable
14337 + * @v: pointer to type atomic64_unchecked_t
14338 + * @i: required value
14339 + *
14340 + * Atomically sets the value of @v to @i.
14341 + */
14342 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14343 +{
14344 + v->counter = i;
14345 +}
14346 +
14347 +/**
14348 * atomic64_add - add integer to atomic64 variable
14349 * @i: integer value to add
14350 * @v: pointer to type atomic64_t
14351 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14352 */
14353 static inline void atomic64_add(long i, atomic64_t *v)
14354 {
14355 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14356 +
14357 +#ifdef CONFIG_PAX_REFCOUNT
14358 + "jno 0f\n"
14359 + LOCK_PREFIX "subq %1,%0\n"
14360 + "int $4\n0:\n"
14361 + _ASM_EXTABLE(0b, 0b)
14362 +#endif
14363 +
14364 + : "=m" (v->counter)
14365 + : "er" (i), "m" (v->counter));
14366 +}
14367 +
14368 +/**
14369 + * atomic64_add_unchecked - add integer to atomic64 variable
14370 + * @i: integer value to add
14371 + * @v: pointer to type atomic64_unchecked_t
14372 + *
14373 + * Atomically adds @i to @v.
14374 + */
14375 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14376 +{
14377 asm volatile(LOCK_PREFIX "addq %1,%0"
14378 : "=m" (v->counter)
14379 : "er" (i), "m" (v->counter));
14380 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14381 */
14382 static inline void atomic64_sub(long i, atomic64_t *v)
14383 {
14384 - asm volatile(LOCK_PREFIX "subq %1,%0"
14385 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14386 +
14387 +#ifdef CONFIG_PAX_REFCOUNT
14388 + "jno 0f\n"
14389 + LOCK_PREFIX "addq %1,%0\n"
14390 + "int $4\n0:\n"
14391 + _ASM_EXTABLE(0b, 0b)
14392 +#endif
14393 +
14394 + : "=m" (v->counter)
14395 + : "er" (i), "m" (v->counter));
14396 +}
14397 +
14398 +/**
14399 + * atomic64_sub_unchecked - subtract the atomic64 variable
14400 + * @i: integer value to subtract
14401 + * @v: pointer to type atomic64_unchecked_t
14402 + *
14403 + * Atomically subtracts @i from @v.
14404 + */
14405 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14406 +{
14407 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14408 : "=m" (v->counter)
14409 : "er" (i), "m" (v->counter));
14410 }
14411 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14412 {
14413 unsigned char c;
14414
14415 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14416 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14417 +
14418 +#ifdef CONFIG_PAX_REFCOUNT
14419 + "jno 0f\n"
14420 + LOCK_PREFIX "addq %2,%0\n"
14421 + "int $4\n0:\n"
14422 + _ASM_EXTABLE(0b, 0b)
14423 +#endif
14424 +
14425 + "sete %1\n"
14426 : "=m" (v->counter), "=qm" (c)
14427 : "er" (i), "m" (v->counter) : "memory");
14428 return c;
14429 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14430 */
14431 static inline void atomic64_inc(atomic64_t *v)
14432 {
14433 + asm volatile(LOCK_PREFIX "incq %0\n"
14434 +
14435 +#ifdef CONFIG_PAX_REFCOUNT
14436 + "jno 0f\n"
14437 + LOCK_PREFIX "decq %0\n"
14438 + "int $4\n0:\n"
14439 + _ASM_EXTABLE(0b, 0b)
14440 +#endif
14441 +
14442 + : "=m" (v->counter)
14443 + : "m" (v->counter));
14444 +}
14445 +
14446 +/**
14447 + * atomic64_inc_unchecked - increment atomic64 variable
14448 + * @v: pointer to type atomic64_unchecked_t
14449 + *
14450 + * Atomically increments @v by 1.
14451 + */
14452 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14453 +{
14454 asm volatile(LOCK_PREFIX "incq %0"
14455 : "=m" (v->counter)
14456 : "m" (v->counter));
14457 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14458 */
14459 static inline void atomic64_dec(atomic64_t *v)
14460 {
14461 - asm volatile(LOCK_PREFIX "decq %0"
14462 + asm volatile(LOCK_PREFIX "decq %0\n"
14463 +
14464 +#ifdef CONFIG_PAX_REFCOUNT
14465 + "jno 0f\n"
14466 + LOCK_PREFIX "incq %0\n"
14467 + "int $4\n0:\n"
14468 + _ASM_EXTABLE(0b, 0b)
14469 +#endif
14470 +
14471 + : "=m" (v->counter)
14472 + : "m" (v->counter));
14473 +}
14474 +
14475 +/**
14476 + * atomic64_dec_unchecked - decrement atomic64 variable
14477 + * @v: pointer to type atomic64_t
14478 + *
14479 + * Atomically decrements @v by 1.
14480 + */
14481 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14482 +{
14483 + asm volatile(LOCK_PREFIX "decq %0\n"
14484 : "=m" (v->counter)
14485 : "m" (v->counter));
14486 }
14487 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14488 {
14489 unsigned char c;
14490
14491 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14492 + asm volatile(LOCK_PREFIX "decq %0\n"
14493 +
14494 +#ifdef CONFIG_PAX_REFCOUNT
14495 + "jno 0f\n"
14496 + LOCK_PREFIX "incq %0\n"
14497 + "int $4\n0:\n"
14498 + _ASM_EXTABLE(0b, 0b)
14499 +#endif
14500 +
14501 + "sete %1\n"
14502 : "=m" (v->counter), "=qm" (c)
14503 : "m" (v->counter) : "memory");
14504 return c != 0;
14505 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14506 {
14507 unsigned char c;
14508
14509 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14510 + asm volatile(LOCK_PREFIX "incq %0\n"
14511 +
14512 +#ifdef CONFIG_PAX_REFCOUNT
14513 + "jno 0f\n"
14514 + LOCK_PREFIX "decq %0\n"
14515 + "int $4\n0:\n"
14516 + _ASM_EXTABLE(0b, 0b)
14517 +#endif
14518 +
14519 + "sete %1\n"
14520 : "=m" (v->counter), "=qm" (c)
14521 : "m" (v->counter) : "memory");
14522 return c != 0;
14523 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14524 {
14525 unsigned char c;
14526
14527 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14528 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14529 +
14530 +#ifdef CONFIG_PAX_REFCOUNT
14531 + "jno 0f\n"
14532 + LOCK_PREFIX "subq %2,%0\n"
14533 + "int $4\n0:\n"
14534 + _ASM_EXTABLE(0b, 0b)
14535 +#endif
14536 +
14537 + "sets %1\n"
14538 : "=m" (v->counter), "=qm" (c)
14539 : "er" (i), "m" (v->counter) : "memory");
14540 return c;
14541 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14542 */
14543 static inline long atomic64_add_return(long i, atomic64_t *v)
14544 {
14545 + return i + xadd_check_overflow(&v->counter, i);
14546 +}
14547 +
14548 +/**
14549 + * atomic64_add_return_unchecked - add and return
14550 + * @i: integer value to add
14551 + * @v: pointer to type atomic64_unchecked_t
14552 + *
14553 + * Atomically adds @i to @v and returns @i + @v
14554 + */
14555 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14556 +{
14557 return i + xadd(&v->counter, i);
14558 }
14559
14560 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14561 }
14562
14563 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14564 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14565 +{
14566 + return atomic64_add_return_unchecked(1, v);
14567 +}
14568 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14569
14570 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14571 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14572 return cmpxchg(&v->counter, old, new);
14573 }
14574
14575 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14576 +{
14577 + return cmpxchg(&v->counter, old, new);
14578 +}
14579 +
14580 static inline long atomic64_xchg(atomic64_t *v, long new)
14581 {
14582 return xchg(&v->counter, new);
14583 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14584 */
14585 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14586 {
14587 - long c, old;
14588 + long c, old, new;
14589 c = atomic64_read(v);
14590 for (;;) {
14591 - if (unlikely(c == (u)))
14592 + if (unlikely(c == u))
14593 break;
14594 - old = atomic64_cmpxchg((v), c, c + (a));
14595 +
14596 + asm volatile("add %2,%0\n"
14597 +
14598 +#ifdef CONFIG_PAX_REFCOUNT
14599 + "jno 0f\n"
14600 + "sub %2,%0\n"
14601 + "int $4\n0:\n"
14602 + _ASM_EXTABLE(0b, 0b)
14603 +#endif
14604 +
14605 + : "=r" (new)
14606 + : "0" (c), "ir" (a));
14607 +
14608 + old = atomic64_cmpxchg(v, c, new);
14609 if (likely(old == c))
14610 break;
14611 c = old;
14612 }
14613 - return c != (u);
14614 + return c != u;
14615 }
14616
14617 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14618 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14619 index 6dfd019..28e188d 100644
14620 --- a/arch/x86/include/asm/bitops.h
14621 +++ b/arch/x86/include/asm/bitops.h
14622 @@ -40,7 +40,7 @@
14623 * a mask operation on a byte.
14624 */
14625 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14626 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14627 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14628 #define CONST_MASK(nr) (1 << ((nr) & 7))
14629
14630 /**
14631 @@ -486,7 +486,7 @@ static inline int fls(int x)
14632 * at position 64.
14633 */
14634 #ifdef CONFIG_X86_64
14635 -static __always_inline int fls64(__u64 x)
14636 +static __always_inline long fls64(__u64 x)
14637 {
14638 int bitpos = -1;
14639 /*
14640 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14641 index 4fa687a..60f2d39 100644
14642 --- a/arch/x86/include/asm/boot.h
14643 +++ b/arch/x86/include/asm/boot.h
14644 @@ -6,10 +6,15 @@
14645 #include <uapi/asm/boot.h>
14646
14647 /* Physical address where kernel should be loaded. */
14648 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14649 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14650 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14651 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14652
14653 +#ifndef __ASSEMBLY__
14654 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14655 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14656 +#endif
14657 +
14658 /* Minimum kernel alignment, as a power of two */
14659 #ifdef CONFIG_X86_64
14660 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14661 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14662 index 48f99f1..d4765f9 100644
14663 --- a/arch/x86/include/asm/cache.h
14664 +++ b/arch/x86/include/asm/cache.h
14665 @@ -5,12 +5,17 @@
14666
14667 /* L1 cache line size */
14668 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14669 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14670 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14671
14672 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14673 +#ifdef MODULE
14674 +#define __read_only __attribute__((__section__(".rodata")))
14675 +#else
14676 +#define __read_only __attribute__((__section__(".data..read_only")))
14677 +#endif
14678
14679 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14680 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14681 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14682
14683 #ifdef CONFIG_X86_VSMP
14684 #ifdef CONFIG_SMP
14685 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14686 index 9863ee3..4a1f8e1 100644
14687 --- a/arch/x86/include/asm/cacheflush.h
14688 +++ b/arch/x86/include/asm/cacheflush.h
14689 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14690 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14691
14692 if (pg_flags == _PGMT_DEFAULT)
14693 - return -1;
14694 + return ~0UL;
14695 else if (pg_flags == _PGMT_WC)
14696 return _PAGE_CACHE_WC;
14697 else if (pg_flags == _PGMT_UC_MINUS)
14698 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14699 index 46fc474..b02b0f9 100644
14700 --- a/arch/x86/include/asm/checksum_32.h
14701 +++ b/arch/x86/include/asm/checksum_32.h
14702 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14703 int len, __wsum sum,
14704 int *src_err_ptr, int *dst_err_ptr);
14705
14706 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14707 + int len, __wsum sum,
14708 + int *src_err_ptr, int *dst_err_ptr);
14709 +
14710 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14711 + int len, __wsum sum,
14712 + int *src_err_ptr, int *dst_err_ptr);
14713 +
14714 /*
14715 * Note: when you get a NULL pointer exception here this means someone
14716 * passed in an incorrect kernel address to one of these functions.
14717 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14718 int *err_ptr)
14719 {
14720 might_sleep();
14721 - return csum_partial_copy_generic((__force void *)src, dst,
14722 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
14723 len, sum, err_ptr, NULL);
14724 }
14725
14726 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14727 {
14728 might_sleep();
14729 if (access_ok(VERIFY_WRITE, dst, len))
14730 - return csum_partial_copy_generic(src, (__force void *)dst,
14731 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
14732 len, sum, NULL, err_ptr);
14733
14734 if (len)
14735 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14736 index d47786a..ce1b05d 100644
14737 --- a/arch/x86/include/asm/cmpxchg.h
14738 +++ b/arch/x86/include/asm/cmpxchg.h
14739 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14740 __compiletime_error("Bad argument size for cmpxchg");
14741 extern void __xadd_wrong_size(void)
14742 __compiletime_error("Bad argument size for xadd");
14743 +extern void __xadd_check_overflow_wrong_size(void)
14744 + __compiletime_error("Bad argument size for xadd_check_overflow");
14745 extern void __add_wrong_size(void)
14746 __compiletime_error("Bad argument size for add");
14747 +extern void __add_check_overflow_wrong_size(void)
14748 + __compiletime_error("Bad argument size for add_check_overflow");
14749
14750 /*
14751 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14752 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14753 __ret; \
14754 })
14755
14756 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14757 + ({ \
14758 + __typeof__ (*(ptr)) __ret = (arg); \
14759 + switch (sizeof(*(ptr))) { \
14760 + case __X86_CASE_L: \
14761 + asm volatile (lock #op "l %0, %1\n" \
14762 + "jno 0f\n" \
14763 + "mov %0,%1\n" \
14764 + "int $4\n0:\n" \
14765 + _ASM_EXTABLE(0b, 0b) \
14766 + : "+r" (__ret), "+m" (*(ptr)) \
14767 + : : "memory", "cc"); \
14768 + break; \
14769 + case __X86_CASE_Q: \
14770 + asm volatile (lock #op "q %q0, %1\n" \
14771 + "jno 0f\n" \
14772 + "mov %0,%1\n" \
14773 + "int $4\n0:\n" \
14774 + _ASM_EXTABLE(0b, 0b) \
14775 + : "+r" (__ret), "+m" (*(ptr)) \
14776 + : : "memory", "cc"); \
14777 + break; \
14778 + default: \
14779 + __ ## op ## _check_overflow_wrong_size(); \
14780 + } \
14781 + __ret; \
14782 + })
14783 +
14784 /*
14785 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14786 * Since this is generally used to protect other memory information, we
14787 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14788 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14789 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14790
14791 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14792 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14793 +
14794 #define __add(ptr, inc, lock) \
14795 ({ \
14796 __typeof__ (*(ptr)) __ret = (inc); \
14797 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14798 index 59c6c40..5e0b22c 100644
14799 --- a/arch/x86/include/asm/compat.h
14800 +++ b/arch/x86/include/asm/compat.h
14801 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14802 typedef u32 compat_uint_t;
14803 typedef u32 compat_ulong_t;
14804 typedef u64 __attribute__((aligned(4))) compat_u64;
14805 -typedef u32 compat_uptr_t;
14806 +typedef u32 __user compat_uptr_t;
14807
14808 struct compat_timespec {
14809 compat_time_t tv_sec;
14810 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14811 index 47538a6..44902d1 100644
14812 --- a/arch/x86/include/asm/cpufeature.h
14813 +++ b/arch/x86/include/asm/cpufeature.h
14814 @@ -203,7 +203,7 @@
14815 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14816 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14817 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14818 -
14819 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14820
14821 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14822 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14823 @@ -211,7 +211,7 @@
14824 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14825 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14826 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14827 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14828 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14829 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14830 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14831 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14832 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14833 #undef cpu_has_centaur_mcr
14834 #define cpu_has_centaur_mcr 0
14835
14836 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14837 #endif /* CONFIG_X86_64 */
14838
14839 #if __GNUC__ >= 4
14840 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14841
14842 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14843 t_warn:
14844 - warn_pre_alternatives();
14845 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14846 + warn_pre_alternatives();
14847 return false;
14848 #endif
14849 #else /* GCC_VERSION >= 40500 */
14850 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14851 ".section .discard,\"aw\",@progbits\n"
14852 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14853 ".previous\n"
14854 - ".section .altinstr_replacement,\"ax\"\n"
14855 + ".section .altinstr_replacement,\"a\"\n"
14856 "3: movb $1,%0\n"
14857 "4:\n"
14858 ".previous\n"
14859 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14860 " .byte 2b - 1b\n" /* src len */
14861 " .byte 4f - 3f\n" /* repl len */
14862 ".previous\n"
14863 - ".section .altinstr_replacement,\"ax\"\n"
14864 + ".section .altinstr_replacement,\"a\"\n"
14865 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14866 "4:\n"
14867 ".previous\n"
14868 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14869 ".section .discard,\"aw\",@progbits\n"
14870 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14871 ".previous\n"
14872 - ".section .altinstr_replacement,\"ax\"\n"
14873 + ".section .altinstr_replacement,\"a\"\n"
14874 "3: movb $0,%0\n"
14875 "4:\n"
14876 ".previous\n"
14877 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14878 ".section .discard,\"aw\",@progbits\n"
14879 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14880 ".previous\n"
14881 - ".section .altinstr_replacement,\"ax\"\n"
14882 + ".section .altinstr_replacement,\"a\"\n"
14883 "5: movb $1,%0\n"
14884 "6:\n"
14885 ".previous\n"
14886 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14887 index b90e5df..b462c91 100644
14888 --- a/arch/x86/include/asm/desc.h
14889 +++ b/arch/x86/include/asm/desc.h
14890 @@ -4,6 +4,7 @@
14891 #include <asm/desc_defs.h>
14892 #include <asm/ldt.h>
14893 #include <asm/mmu.h>
14894 +#include <asm/pgtable.h>
14895
14896 #include <linux/smp.h>
14897 #include <linux/percpu.h>
14898 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14899
14900 desc->type = (info->read_exec_only ^ 1) << 1;
14901 desc->type |= info->contents << 2;
14902 + desc->type |= info->seg_not_present ^ 1;
14903
14904 desc->s = 1;
14905 desc->dpl = 0x3;
14906 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14907 }
14908
14909 extern struct desc_ptr idt_descr;
14910 -extern gate_desc idt_table[];
14911 -extern struct desc_ptr debug_idt_descr;
14912 -extern gate_desc debug_idt_table[];
14913 -
14914 -struct gdt_page {
14915 - struct desc_struct gdt[GDT_ENTRIES];
14916 -} __attribute__((aligned(PAGE_SIZE)));
14917 -
14918 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14919 +extern gate_desc idt_table[IDT_ENTRIES];
14920 +extern const struct desc_ptr debug_idt_descr;
14921 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14922
14923 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14924 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14925 {
14926 - return per_cpu(gdt_page, cpu).gdt;
14927 + return cpu_gdt_table[cpu];
14928 }
14929
14930 #ifdef CONFIG_X86_64
14931 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14932 unsigned long base, unsigned dpl, unsigned flags,
14933 unsigned short seg)
14934 {
14935 - gate->a = (seg << 16) | (base & 0xffff);
14936 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14937 + gate->gate.offset_low = base;
14938 + gate->gate.seg = seg;
14939 + gate->gate.reserved = 0;
14940 + gate->gate.type = type;
14941 + gate->gate.s = 0;
14942 + gate->gate.dpl = dpl;
14943 + gate->gate.p = 1;
14944 + gate->gate.offset_high = base >> 16;
14945 }
14946
14947 #endif
14948 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
14949
14950 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
14951 {
14952 + pax_open_kernel();
14953 memcpy(&idt[entry], gate, sizeof(*gate));
14954 + pax_close_kernel();
14955 }
14956
14957 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
14958 {
14959 + pax_open_kernel();
14960 memcpy(&ldt[entry], desc, 8);
14961 + pax_close_kernel();
14962 }
14963
14964 static inline void
14965 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
14966 default: size = sizeof(*gdt); break;
14967 }
14968
14969 + pax_open_kernel();
14970 memcpy(&gdt[entry], desc, size);
14971 + pax_close_kernel();
14972 }
14973
14974 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
14975 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
14976
14977 static inline void native_load_tr_desc(void)
14978 {
14979 + pax_open_kernel();
14980 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
14981 + pax_close_kernel();
14982 }
14983
14984 static inline void native_load_gdt(const struct desc_ptr *dtr)
14985 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
14986 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
14987 unsigned int i;
14988
14989 + pax_open_kernel();
14990 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
14991 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
14992 + pax_close_kernel();
14993 }
14994
14995 #define _LDT_empty(info) \
14996 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
14997 preempt_enable();
14998 }
14999
15000 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15001 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15002 {
15003 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15004 }
15005 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15006 }
15007
15008 #ifdef CONFIG_X86_64
15009 -static inline void set_nmi_gate(int gate, void *addr)
15010 +static inline void set_nmi_gate(int gate, const void *addr)
15011 {
15012 gate_desc s;
15013
15014 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15015 #endif
15016
15017 #ifdef CONFIG_TRACING
15018 -extern struct desc_ptr trace_idt_descr;
15019 -extern gate_desc trace_idt_table[];
15020 +extern const struct desc_ptr trace_idt_descr;
15021 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15022 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15023 {
15024 write_idt_entry(trace_idt_table, entry, gate);
15025 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15026 }
15027 #endif
15028
15029 -static inline void _set_gate(int gate, unsigned type, void *addr,
15030 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15031 unsigned dpl, unsigned ist, unsigned seg)
15032 {
15033 gate_desc s;
15034 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15035 * Pentium F0 0F bugfix can have resulted in the mapped
15036 * IDT being write-protected.
15037 */
15038 -static inline void set_intr_gate(unsigned int n, void *addr)
15039 +static inline void set_intr_gate(unsigned int n, const void *addr)
15040 {
15041 BUG_ON((unsigned)n > 0xFF);
15042 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15043 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15044 /*
15045 * This routine sets up an interrupt gate at directory privilege level 3.
15046 */
15047 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15048 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15049 {
15050 BUG_ON((unsigned)n > 0xFF);
15051 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15052 }
15053
15054 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15055 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15056 {
15057 BUG_ON((unsigned)n > 0xFF);
15058 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15059 }
15060
15061 -static inline void set_trap_gate(unsigned int n, void *addr)
15062 +static inline void set_trap_gate(unsigned int n, const void *addr)
15063 {
15064 BUG_ON((unsigned)n > 0xFF);
15065 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15066 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15067 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15068 {
15069 BUG_ON((unsigned)n > 0xFF);
15070 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15071 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15072 }
15073
15074 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15075 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15076 {
15077 BUG_ON((unsigned)n > 0xFF);
15078 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15079 }
15080
15081 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15082 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15083 {
15084 BUG_ON((unsigned)n > 0xFF);
15085 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15086 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15087 else
15088 load_idt((const struct desc_ptr *)&idt_descr);
15089 }
15090 +
15091 +#ifdef CONFIG_X86_32
15092 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15093 +{
15094 + struct desc_struct d;
15095 +
15096 + if (likely(limit))
15097 + limit = (limit - 1UL) >> PAGE_SHIFT;
15098 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15099 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15100 +}
15101 +#endif
15102 +
15103 #endif /* _ASM_X86_DESC_H */
15104 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15105 index 278441f..b95a174 100644
15106 --- a/arch/x86/include/asm/desc_defs.h
15107 +++ b/arch/x86/include/asm/desc_defs.h
15108 @@ -31,6 +31,12 @@ struct desc_struct {
15109 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15110 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15111 };
15112 + struct {
15113 + u16 offset_low;
15114 + u16 seg;
15115 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15116 + unsigned offset_high: 16;
15117 + } gate;
15118 };
15119 } __attribute__((packed));
15120
15121 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15122 index ced283a..ffe04cc 100644
15123 --- a/arch/x86/include/asm/div64.h
15124 +++ b/arch/x86/include/asm/div64.h
15125 @@ -39,7 +39,7 @@
15126 __mod; \
15127 })
15128
15129 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15130 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15131 {
15132 union {
15133 u64 v64;
15134 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15135 index 9c999c1..3860cb8 100644
15136 --- a/arch/x86/include/asm/elf.h
15137 +++ b/arch/x86/include/asm/elf.h
15138 @@ -243,7 +243,25 @@ extern int force_personality32;
15139 the loader. We need to make sure that it is out of the way of the program
15140 that it will "exec", and that there is sufficient room for the brk. */
15141
15142 +#ifdef CONFIG_PAX_SEGMEXEC
15143 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15144 +#else
15145 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15146 +#endif
15147 +
15148 +#ifdef CONFIG_PAX_ASLR
15149 +#ifdef CONFIG_X86_32
15150 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15151 +
15152 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15153 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15154 +#else
15155 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15156 +
15157 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15158 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15159 +#endif
15160 +#endif
15161
15162 /* This yields a mask that user programs can use to figure out what
15163 instruction set this CPU supports. This could be done in user space,
15164 @@ -296,16 +314,12 @@ do { \
15165
15166 #define ARCH_DLINFO \
15167 do { \
15168 - if (vdso_enabled) \
15169 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15170 - (unsigned long)current->mm->context.vdso); \
15171 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15172 } while (0)
15173
15174 #define ARCH_DLINFO_X32 \
15175 do { \
15176 - if (vdso_enabled) \
15177 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15178 - (unsigned long)current->mm->context.vdso); \
15179 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15180 } while (0)
15181
15182 #define AT_SYSINFO 32
15183 @@ -320,7 +334,7 @@ else \
15184
15185 #endif /* !CONFIG_X86_32 */
15186
15187 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15188 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15189
15190 #define VDSO_ENTRY \
15191 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15192 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15193 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15194 #define compat_arch_setup_additional_pages syscall32_setup_pages
15195
15196 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15197 -#define arch_randomize_brk arch_randomize_brk
15198 -
15199 /*
15200 * True on X86_32 or when emulating IA32 on X86_64
15201 */
15202 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15203 index 77a99ac..39ff7f5 100644
15204 --- a/arch/x86/include/asm/emergency-restart.h
15205 +++ b/arch/x86/include/asm/emergency-restart.h
15206 @@ -1,6 +1,6 @@
15207 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15208 #define _ASM_X86_EMERGENCY_RESTART_H
15209
15210 -extern void machine_emergency_restart(void);
15211 +extern void machine_emergency_restart(void) __noreturn;
15212
15213 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15214 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15215 index 4d0bda7..221da4d 100644
15216 --- a/arch/x86/include/asm/fpu-internal.h
15217 +++ b/arch/x86/include/asm/fpu-internal.h
15218 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15219 #define user_insn(insn, output, input...) \
15220 ({ \
15221 int err; \
15222 + pax_open_userland(); \
15223 asm volatile(ASM_STAC "\n" \
15224 - "1:" #insn "\n\t" \
15225 + "1:" \
15226 + __copyuser_seg \
15227 + #insn "\n\t" \
15228 "2: " ASM_CLAC "\n" \
15229 ".section .fixup,\"ax\"\n" \
15230 "3: movl $-1,%[err]\n" \
15231 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15232 _ASM_EXTABLE(1b, 3b) \
15233 : [err] "=r" (err), output \
15234 : "0"(0), input); \
15235 + pax_close_userland(); \
15236 err; \
15237 })
15238
15239 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15240 "emms\n\t" /* clear stack tags */
15241 "fildl %P[addr]", /* set F?P to defined value */
15242 X86_FEATURE_FXSAVE_LEAK,
15243 - [addr] "m" (tsk->thread.fpu.has_fpu));
15244 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15245
15246 return fpu_restore_checking(&tsk->thread.fpu);
15247 }
15248 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15249 index be27ba1..04a8801 100644
15250 --- a/arch/x86/include/asm/futex.h
15251 +++ b/arch/x86/include/asm/futex.h
15252 @@ -12,6 +12,7 @@
15253 #include <asm/smap.h>
15254
15255 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15256 + typecheck(u32 __user *, uaddr); \
15257 asm volatile("\t" ASM_STAC "\n" \
15258 "1:\t" insn "\n" \
15259 "2:\t" ASM_CLAC "\n" \
15260 @@ -20,15 +21,16 @@
15261 "\tjmp\t2b\n" \
15262 "\t.previous\n" \
15263 _ASM_EXTABLE(1b, 3b) \
15264 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15265 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15266 : "i" (-EFAULT), "0" (oparg), "1" (0))
15267
15268 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15269 + typecheck(u32 __user *, uaddr); \
15270 asm volatile("\t" ASM_STAC "\n" \
15271 "1:\tmovl %2, %0\n" \
15272 "\tmovl\t%0, %3\n" \
15273 "\t" insn "\n" \
15274 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15275 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15276 "\tjnz\t1b\n" \
15277 "3:\t" ASM_CLAC "\n" \
15278 "\t.section .fixup,\"ax\"\n" \
15279 @@ -38,7 +40,7 @@
15280 _ASM_EXTABLE(1b, 4b) \
15281 _ASM_EXTABLE(2b, 4b) \
15282 : "=&a" (oldval), "=&r" (ret), \
15283 - "+m" (*uaddr), "=&r" (tem) \
15284 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15285 : "r" (oparg), "i" (-EFAULT), "1" (0))
15286
15287 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15288 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15289
15290 pagefault_disable();
15291
15292 + pax_open_userland();
15293 switch (op) {
15294 case FUTEX_OP_SET:
15295 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15296 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15297 break;
15298 case FUTEX_OP_ADD:
15299 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15300 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15301 uaddr, oparg);
15302 break;
15303 case FUTEX_OP_OR:
15304 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15305 default:
15306 ret = -ENOSYS;
15307 }
15308 + pax_close_userland();
15309
15310 pagefault_enable();
15311
15312 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15313 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15314 return -EFAULT;
15315
15316 + pax_open_userland();
15317 asm volatile("\t" ASM_STAC "\n"
15318 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15319 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15320 "2:\t" ASM_CLAC "\n"
15321 "\t.section .fixup, \"ax\"\n"
15322 "3:\tmov %3, %0\n"
15323 "\tjmp 2b\n"
15324 "\t.previous\n"
15325 _ASM_EXTABLE(1b, 3b)
15326 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15327 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15328 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15329 : "memory"
15330 );
15331 + pax_close_userland();
15332
15333 *uval = oldval;
15334 return ret;
15335 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15336 index e4ac559..c1c0c87 100644
15337 --- a/arch/x86/include/asm/hw_irq.h
15338 +++ b/arch/x86/include/asm/hw_irq.h
15339 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15340 extern void enable_IO_APIC(void);
15341
15342 /* Statistics */
15343 -extern atomic_t irq_err_count;
15344 -extern atomic_t irq_mis_count;
15345 +extern atomic_unchecked_t irq_err_count;
15346 +extern atomic_unchecked_t irq_mis_count;
15347
15348 /* EISA */
15349 extern void eisa_set_level_irq(unsigned int irq);
15350 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15351 index a203659..9889f1c 100644
15352 --- a/arch/x86/include/asm/i8259.h
15353 +++ b/arch/x86/include/asm/i8259.h
15354 @@ -62,7 +62,7 @@ struct legacy_pic {
15355 void (*init)(int auto_eoi);
15356 int (*irq_pending)(unsigned int irq);
15357 void (*make_irq)(unsigned int irq);
15358 -};
15359 +} __do_const;
15360
15361 extern struct legacy_pic *legacy_pic;
15362 extern struct legacy_pic null_legacy_pic;
15363 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15364 index 34f69cb..6d95446 100644
15365 --- a/arch/x86/include/asm/io.h
15366 +++ b/arch/x86/include/asm/io.h
15367 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15368 "m" (*(volatile type __force *)addr) barrier); }
15369
15370 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15371 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15372 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15373 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15374 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15375
15376 build_mmio_read(__readb, "b", unsigned char, "=q", )
15377 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15378 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15379 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15380 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15381
15382 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15383 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15384 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15385 return ioremap_nocache(offset, size);
15386 }
15387
15388 -extern void iounmap(volatile void __iomem *addr);
15389 +extern void iounmap(const volatile void __iomem *addr);
15390
15391 extern void set_iounmap_nonlazy(void);
15392
15393 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15394
15395 #include <linux/vmalloc.h>
15396
15397 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15398 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15399 +{
15400 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15401 +}
15402 +
15403 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15404 +{
15405 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15406 +}
15407 +
15408 /*
15409 * Convert a virtual cached pointer to an uncached pointer
15410 */
15411 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15412 index bba3cf8..06bc8da 100644
15413 --- a/arch/x86/include/asm/irqflags.h
15414 +++ b/arch/x86/include/asm/irqflags.h
15415 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15416 sti; \
15417 sysexit
15418
15419 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15420 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15421 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15422 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15423 +
15424 #else
15425 #define INTERRUPT_RETURN iret
15426 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15427 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15428 index 5a6d287..f815789 100644
15429 --- a/arch/x86/include/asm/kprobes.h
15430 +++ b/arch/x86/include/asm/kprobes.h
15431 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15432 #define RELATIVEJUMP_SIZE 5
15433 #define RELATIVECALL_OPCODE 0xe8
15434 #define RELATIVE_ADDR_SIZE 4
15435 -#define MAX_STACK_SIZE 64
15436 -#define MIN_STACK_SIZE(ADDR) \
15437 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15438 - THREAD_SIZE - (unsigned long)(ADDR))) \
15439 - ? (MAX_STACK_SIZE) \
15440 - : (((unsigned long)current_thread_info()) + \
15441 - THREAD_SIZE - (unsigned long)(ADDR)))
15442 +#define MAX_STACK_SIZE 64UL
15443 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15444
15445 #define flush_insn_slot(p) do { } while (0)
15446
15447 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15448 index 2d89e39..baee879 100644
15449 --- a/arch/x86/include/asm/local.h
15450 +++ b/arch/x86/include/asm/local.h
15451 @@ -10,33 +10,97 @@ typedef struct {
15452 atomic_long_t a;
15453 } local_t;
15454
15455 +typedef struct {
15456 + atomic_long_unchecked_t a;
15457 +} local_unchecked_t;
15458 +
15459 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15460
15461 #define local_read(l) atomic_long_read(&(l)->a)
15462 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15463 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15464 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15465
15466 static inline void local_inc(local_t *l)
15467 {
15468 - asm volatile(_ASM_INC "%0"
15469 + asm volatile(_ASM_INC "%0\n"
15470 +
15471 +#ifdef CONFIG_PAX_REFCOUNT
15472 + "jno 0f\n"
15473 + _ASM_DEC "%0\n"
15474 + "int $4\n0:\n"
15475 + _ASM_EXTABLE(0b, 0b)
15476 +#endif
15477 +
15478 + : "+m" (l->a.counter));
15479 +}
15480 +
15481 +static inline void local_inc_unchecked(local_unchecked_t *l)
15482 +{
15483 + asm volatile(_ASM_INC "%0\n"
15484 : "+m" (l->a.counter));
15485 }
15486
15487 static inline void local_dec(local_t *l)
15488 {
15489 - asm volatile(_ASM_DEC "%0"
15490 + asm volatile(_ASM_DEC "%0\n"
15491 +
15492 +#ifdef CONFIG_PAX_REFCOUNT
15493 + "jno 0f\n"
15494 + _ASM_INC "%0\n"
15495 + "int $4\n0:\n"
15496 + _ASM_EXTABLE(0b, 0b)
15497 +#endif
15498 +
15499 + : "+m" (l->a.counter));
15500 +}
15501 +
15502 +static inline void local_dec_unchecked(local_unchecked_t *l)
15503 +{
15504 + asm volatile(_ASM_DEC "%0\n"
15505 : "+m" (l->a.counter));
15506 }
15507
15508 static inline void local_add(long i, local_t *l)
15509 {
15510 - asm volatile(_ASM_ADD "%1,%0"
15511 + asm volatile(_ASM_ADD "%1,%0\n"
15512 +
15513 +#ifdef CONFIG_PAX_REFCOUNT
15514 + "jno 0f\n"
15515 + _ASM_SUB "%1,%0\n"
15516 + "int $4\n0:\n"
15517 + _ASM_EXTABLE(0b, 0b)
15518 +#endif
15519 +
15520 + : "+m" (l->a.counter)
15521 + : "ir" (i));
15522 +}
15523 +
15524 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15525 +{
15526 + asm volatile(_ASM_ADD "%1,%0\n"
15527 : "+m" (l->a.counter)
15528 : "ir" (i));
15529 }
15530
15531 static inline void local_sub(long i, local_t *l)
15532 {
15533 - asm volatile(_ASM_SUB "%1,%0"
15534 + asm volatile(_ASM_SUB "%1,%0\n"
15535 +
15536 +#ifdef CONFIG_PAX_REFCOUNT
15537 + "jno 0f\n"
15538 + _ASM_ADD "%1,%0\n"
15539 + "int $4\n0:\n"
15540 + _ASM_EXTABLE(0b, 0b)
15541 +#endif
15542 +
15543 + : "+m" (l->a.counter)
15544 + : "ir" (i));
15545 +}
15546 +
15547 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15548 +{
15549 + asm volatile(_ASM_SUB "%1,%0\n"
15550 : "+m" (l->a.counter)
15551 : "ir" (i));
15552 }
15553 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15554 {
15555 unsigned char c;
15556
15557 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15558 + asm volatile(_ASM_SUB "%2,%0\n"
15559 +
15560 +#ifdef CONFIG_PAX_REFCOUNT
15561 + "jno 0f\n"
15562 + _ASM_ADD "%2,%0\n"
15563 + "int $4\n0:\n"
15564 + _ASM_EXTABLE(0b, 0b)
15565 +#endif
15566 +
15567 + "sete %1\n"
15568 : "+m" (l->a.counter), "=qm" (c)
15569 : "ir" (i) : "memory");
15570 return c;
15571 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15572 {
15573 unsigned char c;
15574
15575 - asm volatile(_ASM_DEC "%0; sete %1"
15576 + asm volatile(_ASM_DEC "%0\n"
15577 +
15578 +#ifdef CONFIG_PAX_REFCOUNT
15579 + "jno 0f\n"
15580 + _ASM_INC "%0\n"
15581 + "int $4\n0:\n"
15582 + _ASM_EXTABLE(0b, 0b)
15583 +#endif
15584 +
15585 + "sete %1\n"
15586 : "+m" (l->a.counter), "=qm" (c)
15587 : : "memory");
15588 return c != 0;
15589 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15590 {
15591 unsigned char c;
15592
15593 - asm volatile(_ASM_INC "%0; sete %1"
15594 + asm volatile(_ASM_INC "%0\n"
15595 +
15596 +#ifdef CONFIG_PAX_REFCOUNT
15597 + "jno 0f\n"
15598 + _ASM_DEC "%0\n"
15599 + "int $4\n0:\n"
15600 + _ASM_EXTABLE(0b, 0b)
15601 +#endif
15602 +
15603 + "sete %1\n"
15604 : "+m" (l->a.counter), "=qm" (c)
15605 : : "memory");
15606 return c != 0;
15607 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15608 {
15609 unsigned char c;
15610
15611 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15612 + asm volatile(_ASM_ADD "%2,%0\n"
15613 +
15614 +#ifdef CONFIG_PAX_REFCOUNT
15615 + "jno 0f\n"
15616 + _ASM_SUB "%2,%0\n"
15617 + "int $4\n0:\n"
15618 + _ASM_EXTABLE(0b, 0b)
15619 +#endif
15620 +
15621 + "sets %1\n"
15622 : "+m" (l->a.counter), "=qm" (c)
15623 : "ir" (i) : "memory");
15624 return c;
15625 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15626 static inline long local_add_return(long i, local_t *l)
15627 {
15628 long __i = i;
15629 + asm volatile(_ASM_XADD "%0, %1\n"
15630 +
15631 +#ifdef CONFIG_PAX_REFCOUNT
15632 + "jno 0f\n"
15633 + _ASM_MOV "%0,%1\n"
15634 + "int $4\n0:\n"
15635 + _ASM_EXTABLE(0b, 0b)
15636 +#endif
15637 +
15638 + : "+r" (i), "+m" (l->a.counter)
15639 + : : "memory");
15640 + return i + __i;
15641 +}
15642 +
15643 +/**
15644 + * local_add_return_unchecked - add and return
15645 + * @i: integer value to add
15646 + * @l: pointer to type local_unchecked_t
15647 + *
15648 + * Atomically adds @i to @l and returns @i + @l
15649 + */
15650 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15651 +{
15652 + long __i = i;
15653 asm volatile(_ASM_XADD "%0, %1;"
15654 : "+r" (i), "+m" (l->a.counter)
15655 : : "memory");
15656 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15657
15658 #define local_cmpxchg(l, o, n) \
15659 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15660 +#define local_cmpxchg_unchecked(l, o, n) \
15661 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15662 /* Always has a lock prefix */
15663 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15664
15665 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15666 new file mode 100644
15667 index 0000000..2bfd3ba
15668 --- /dev/null
15669 +++ b/arch/x86/include/asm/mman.h
15670 @@ -0,0 +1,15 @@
15671 +#ifndef _X86_MMAN_H
15672 +#define _X86_MMAN_H
15673 +
15674 +#include <uapi/asm/mman.h>
15675 +
15676 +#ifdef __KERNEL__
15677 +#ifndef __ASSEMBLY__
15678 +#ifdef CONFIG_X86_32
15679 +#define arch_mmap_check i386_mmap_check
15680 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15681 +#endif
15682 +#endif
15683 +#endif
15684 +
15685 +#endif /* X86_MMAN_H */
15686 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15687 index 5f55e69..e20bfb1 100644
15688 --- a/arch/x86/include/asm/mmu.h
15689 +++ b/arch/x86/include/asm/mmu.h
15690 @@ -9,7 +9,7 @@
15691 * we put the segment information here.
15692 */
15693 typedef struct {
15694 - void *ldt;
15695 + struct desc_struct *ldt;
15696 int size;
15697
15698 #ifdef CONFIG_X86_64
15699 @@ -18,7 +18,19 @@ typedef struct {
15700 #endif
15701
15702 struct mutex lock;
15703 - void *vdso;
15704 + unsigned long vdso;
15705 +
15706 +#ifdef CONFIG_X86_32
15707 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15708 + unsigned long user_cs_base;
15709 + unsigned long user_cs_limit;
15710 +
15711 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15712 + cpumask_t cpu_user_cs_mask;
15713 +#endif
15714 +
15715 +#endif
15716 +#endif
15717 } mm_context_t;
15718
15719 #ifdef CONFIG_SMP
15720 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15721 index cdbf367..ce8f82b 100644
15722 --- a/arch/x86/include/asm/mmu_context.h
15723 +++ b/arch/x86/include/asm/mmu_context.h
15724 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15725
15726 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15727 {
15728 +
15729 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15730 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15731 + unsigned int i;
15732 + pgd_t *pgd;
15733 +
15734 + pax_open_kernel();
15735 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15736 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15737 + set_pgd_batched(pgd+i, native_make_pgd(0));
15738 + pax_close_kernel();
15739 + }
15740 +#endif
15741 +
15742 #ifdef CONFIG_SMP
15743 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15744 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15745 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15746 struct task_struct *tsk)
15747 {
15748 unsigned cpu = smp_processor_id();
15749 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15750 + int tlbstate = TLBSTATE_OK;
15751 +#endif
15752
15753 if (likely(prev != next)) {
15754 #ifdef CONFIG_SMP
15755 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15756 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15757 +#endif
15758 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15759 this_cpu_write(cpu_tlbstate.active_mm, next);
15760 #endif
15761 cpumask_set_cpu(cpu, mm_cpumask(next));
15762
15763 /* Re-load page tables */
15764 +#ifdef CONFIG_PAX_PER_CPU_PGD
15765 + pax_open_kernel();
15766 +
15767 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15768 + if (static_cpu_has(X86_FEATURE_PCID))
15769 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15770 + else
15771 +#endif
15772 +
15773 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15774 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15775 + pax_close_kernel();
15776 + 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));
15777 +
15778 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15779 + if (static_cpu_has(X86_FEATURE_PCID)) {
15780 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15781 + u64 descriptor[2];
15782 + descriptor[0] = PCID_USER;
15783 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15784 + } else {
15785 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15786 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15787 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15788 + else
15789 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15790 + }
15791 + } else
15792 +#endif
15793 +
15794 + load_cr3(get_cpu_pgd(cpu, kernel));
15795 +#else
15796 load_cr3(next->pgd);
15797 +#endif
15798
15799 /* stop flush ipis for the previous mm */
15800 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15801 @@ -53,9 +106,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15802 */
15803 if (unlikely(prev->context.ldt != next->context.ldt))
15804 load_LDT_nolock(&next->context);
15805 - }
15806 +
15807 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15808 + if (!(__supported_pte_mask & _PAGE_NX)) {
15809 + smp_mb__before_clear_bit();
15810 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15811 + smp_mb__after_clear_bit();
15812 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15813 + }
15814 +#endif
15815 +
15816 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15817 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15818 + prev->context.user_cs_limit != next->context.user_cs_limit))
15819 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15820 #ifdef CONFIG_SMP
15821 + else if (unlikely(tlbstate != TLBSTATE_OK))
15822 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15823 +#endif
15824 +#endif
15825 +
15826 + }
15827 else {
15828 +
15829 +#ifdef CONFIG_PAX_PER_CPU_PGD
15830 + pax_open_kernel();
15831 +
15832 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15833 + if (static_cpu_has(X86_FEATURE_PCID))
15834 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15835 + else
15836 +#endif
15837 +
15838 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15839 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15840 + pax_close_kernel();
15841 + 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));
15842 +
15843 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15844 + if (static_cpu_has(X86_FEATURE_PCID)) {
15845 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15846 + u64 descriptor[2];
15847 + descriptor[0] = PCID_USER;
15848 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15849 + } else {
15850 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15851 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15852 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15853 + else
15854 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15855 + }
15856 + } else
15857 +#endif
15858 +
15859 + load_cr3(get_cpu_pgd(cpu, kernel));
15860 +#endif
15861 +
15862 +#ifdef CONFIG_SMP
15863 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15864 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15865
15866 @@ -64,11 +171,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15867 * tlb flush IPI delivery. We must reload CR3
15868 * to make sure to use no freed page tables.
15869 */
15870 +
15871 +#ifndef CONFIG_PAX_PER_CPU_PGD
15872 load_cr3(next->pgd);
15873 +#endif
15874 +
15875 load_LDT_nolock(&next->context);
15876 +
15877 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15878 + if (!(__supported_pte_mask & _PAGE_NX))
15879 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15880 +#endif
15881 +
15882 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15883 +#ifdef CONFIG_PAX_PAGEEXEC
15884 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15885 +#endif
15886 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15887 +#endif
15888 +
15889 }
15890 +#endif
15891 }
15892 -#endif
15893 }
15894
15895 #define activate_mm(prev, next) \
15896 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15897 index e3b7819..b257c64 100644
15898 --- a/arch/x86/include/asm/module.h
15899 +++ b/arch/x86/include/asm/module.h
15900 @@ -5,6 +5,7 @@
15901
15902 #ifdef CONFIG_X86_64
15903 /* X86_64 does not define MODULE_PROC_FAMILY */
15904 +#define MODULE_PROC_FAMILY ""
15905 #elif defined CONFIG_M486
15906 #define MODULE_PROC_FAMILY "486 "
15907 #elif defined CONFIG_M586
15908 @@ -57,8 +58,20 @@
15909 #error unknown processor family
15910 #endif
15911
15912 -#ifdef CONFIG_X86_32
15913 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15914 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15915 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15916 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15917 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15918 +#else
15919 +#define MODULE_PAX_KERNEXEC ""
15920 #endif
15921
15922 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15923 +#define MODULE_PAX_UDEREF "UDEREF "
15924 +#else
15925 +#define MODULE_PAX_UDEREF ""
15926 +#endif
15927 +
15928 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
15929 +
15930 #endif /* _ASM_X86_MODULE_H */
15931 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15932 index 86f9301..b365cda 100644
15933 --- a/arch/x86/include/asm/nmi.h
15934 +++ b/arch/x86/include/asm/nmi.h
15935 @@ -40,11 +40,11 @@ struct nmiaction {
15936 nmi_handler_t handler;
15937 unsigned long flags;
15938 const char *name;
15939 -};
15940 +} __do_const;
15941
15942 #define register_nmi_handler(t, fn, fg, n, init...) \
15943 ({ \
15944 - static struct nmiaction init fn##_na = { \
15945 + static const struct nmiaction init fn##_na = { \
15946 .handler = (fn), \
15947 .name = (n), \
15948 .flags = (fg), \
15949 @@ -52,7 +52,7 @@ struct nmiaction {
15950 __register_nmi_handler((t), &fn##_na); \
15951 })
15952
15953 -int __register_nmi_handler(unsigned int, struct nmiaction *);
15954 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
15955
15956 void unregister_nmi_handler(unsigned int, const char *);
15957
15958 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
15959 index c878924..21f4889 100644
15960 --- a/arch/x86/include/asm/page.h
15961 +++ b/arch/x86/include/asm/page.h
15962 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
15963 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
15964
15965 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
15966 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
15967
15968 #define __boot_va(x) __va(x)
15969 #define __boot_pa(x) __pa(x)
15970 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
15971 index 0f1ddee..e2fc3d1 100644
15972 --- a/arch/x86/include/asm/page_64.h
15973 +++ b/arch/x86/include/asm/page_64.h
15974 @@ -7,9 +7,9 @@
15975
15976 /* duplicated to the one in bootmem.h */
15977 extern unsigned long max_pfn;
15978 -extern unsigned long phys_base;
15979 +extern const unsigned long phys_base;
15980
15981 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
15982 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
15983 {
15984 unsigned long y = x - __START_KERNEL_map;
15985
15986 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
15987 index cfdc9ee..3f7b5d6 100644
15988 --- a/arch/x86/include/asm/paravirt.h
15989 +++ b/arch/x86/include/asm/paravirt.h
15990 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
15991 return (pmd_t) { ret };
15992 }
15993
15994 -static inline pmdval_t pmd_val(pmd_t pmd)
15995 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
15996 {
15997 pmdval_t ret;
15998
15999 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16000 val);
16001 }
16002
16003 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16004 +{
16005 + pgdval_t val = native_pgd_val(pgd);
16006 +
16007 + if (sizeof(pgdval_t) > sizeof(long))
16008 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16009 + val, (u64)val >> 32);
16010 + else
16011 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16012 + val);
16013 +}
16014 +
16015 static inline void pgd_clear(pgd_t *pgdp)
16016 {
16017 set_pgd(pgdp, __pgd(0));
16018 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16019 pv_mmu_ops.set_fixmap(idx, phys, flags);
16020 }
16021
16022 +#ifdef CONFIG_PAX_KERNEXEC
16023 +static inline unsigned long pax_open_kernel(void)
16024 +{
16025 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16026 +}
16027 +
16028 +static inline unsigned long pax_close_kernel(void)
16029 +{
16030 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16031 +}
16032 +#else
16033 +static inline unsigned long pax_open_kernel(void) { return 0; }
16034 +static inline unsigned long pax_close_kernel(void) { return 0; }
16035 +#endif
16036 +
16037 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16038
16039 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16040 @@ -926,7 +953,7 @@ extern void default_banner(void);
16041
16042 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16043 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16044 -#define PARA_INDIRECT(addr) *%cs:addr
16045 +#define PARA_INDIRECT(addr) *%ss:addr
16046 #endif
16047
16048 #define INTERRUPT_RETURN \
16049 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16050 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16051 CLBR_NONE, \
16052 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16053 +
16054 +#define GET_CR0_INTO_RDI \
16055 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16056 + mov %rax,%rdi
16057 +
16058 +#define SET_RDI_INTO_CR0 \
16059 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16060 +
16061 +#define GET_CR3_INTO_RDI \
16062 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16063 + mov %rax,%rdi
16064 +
16065 +#define SET_RDI_INTO_CR3 \
16066 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16067 +
16068 #endif /* CONFIG_X86_32 */
16069
16070 #endif /* __ASSEMBLY__ */
16071 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16072 index 0db1fca..52310cc 100644
16073 --- a/arch/x86/include/asm/paravirt_types.h
16074 +++ b/arch/x86/include/asm/paravirt_types.h
16075 @@ -84,7 +84,7 @@ struct pv_init_ops {
16076 */
16077 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16078 unsigned long addr, unsigned len);
16079 -};
16080 +} __no_const;
16081
16082
16083 struct pv_lazy_ops {
16084 @@ -98,7 +98,7 @@ struct pv_time_ops {
16085 unsigned long long (*sched_clock)(void);
16086 unsigned long long (*steal_clock)(int cpu);
16087 unsigned long (*get_tsc_khz)(void);
16088 -};
16089 +} __no_const;
16090
16091 struct pv_cpu_ops {
16092 /* hooks for various privileged instructions */
16093 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16094
16095 void (*start_context_switch)(struct task_struct *prev);
16096 void (*end_context_switch)(struct task_struct *next);
16097 -};
16098 +} __no_const;
16099
16100 struct pv_irq_ops {
16101 /*
16102 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16103 unsigned long start_eip,
16104 unsigned long start_esp);
16105 #endif
16106 -};
16107 +} __no_const;
16108
16109 struct pv_mmu_ops {
16110 unsigned long (*read_cr2)(void);
16111 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16112 struct paravirt_callee_save make_pud;
16113
16114 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16115 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16116 #endif /* PAGETABLE_LEVELS == 4 */
16117 #endif /* PAGETABLE_LEVELS >= 3 */
16118
16119 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16120 an mfn. We can tell which is which from the index. */
16121 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16122 phys_addr_t phys, pgprot_t flags);
16123 +
16124 +#ifdef CONFIG_PAX_KERNEXEC
16125 + unsigned long (*pax_open_kernel)(void);
16126 + unsigned long (*pax_close_kernel)(void);
16127 +#endif
16128 +
16129 };
16130
16131 struct arch_spinlock;
16132 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16133 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16134 int (*spin_trylock)(struct arch_spinlock *lock);
16135 void (*spin_unlock)(struct arch_spinlock *lock);
16136 -};
16137 +} __no_const;
16138
16139 /* This contains all the paravirt structures: we get a convenient
16140 * number for each function using the offset which we use to indicate
16141 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16142 index b4389a4..7024269 100644
16143 --- a/arch/x86/include/asm/pgalloc.h
16144 +++ b/arch/x86/include/asm/pgalloc.h
16145 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16146 pmd_t *pmd, pte_t *pte)
16147 {
16148 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16149 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16150 +}
16151 +
16152 +static inline void pmd_populate_user(struct mm_struct *mm,
16153 + pmd_t *pmd, pte_t *pte)
16154 +{
16155 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16156 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16157 }
16158
16159 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16160
16161 #ifdef CONFIG_X86_PAE
16162 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16163 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16164 +{
16165 + pud_populate(mm, pudp, pmd);
16166 +}
16167 #else /* !CONFIG_X86_PAE */
16168 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16169 {
16170 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16171 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16172 }
16173 +
16174 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16175 +{
16176 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16177 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16178 +}
16179 #endif /* CONFIG_X86_PAE */
16180
16181 #if PAGETABLE_LEVELS > 3
16182 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16183 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16184 }
16185
16186 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16187 +{
16188 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16189 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16190 +}
16191 +
16192 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16193 {
16194 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16195 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16196 index 3bf2dd0..23d2a9f 100644
16197 --- a/arch/x86/include/asm/pgtable-2level.h
16198 +++ b/arch/x86/include/asm/pgtable-2level.h
16199 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16200
16201 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16202 {
16203 + pax_open_kernel();
16204 *pmdp = pmd;
16205 + pax_close_kernel();
16206 }
16207
16208 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16209 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16210 index 81bb91b..9392125 100644
16211 --- a/arch/x86/include/asm/pgtable-3level.h
16212 +++ b/arch/x86/include/asm/pgtable-3level.h
16213 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16214
16215 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16216 {
16217 + pax_open_kernel();
16218 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16219 + pax_close_kernel();
16220 }
16221
16222 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16223 {
16224 + pax_open_kernel();
16225 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16226 + pax_close_kernel();
16227 }
16228
16229 /*
16230 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16231 index 1c00631..845f898 100644
16232 --- a/arch/x86/include/asm/pgtable.h
16233 +++ b/arch/x86/include/asm/pgtable.h
16234 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16235
16236 #ifndef __PAGETABLE_PUD_FOLDED
16237 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16238 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16239 #define pgd_clear(pgd) native_pgd_clear(pgd)
16240 #endif
16241
16242 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16243
16244 #define arch_end_context_switch(prev) do {} while(0)
16245
16246 +#define pax_open_kernel() native_pax_open_kernel()
16247 +#define pax_close_kernel() native_pax_close_kernel()
16248 #endif /* CONFIG_PARAVIRT */
16249
16250 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16251 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16252 +
16253 +#ifdef CONFIG_PAX_KERNEXEC
16254 +static inline unsigned long native_pax_open_kernel(void)
16255 +{
16256 + unsigned long cr0;
16257 +
16258 + preempt_disable();
16259 + barrier();
16260 + cr0 = read_cr0() ^ X86_CR0_WP;
16261 + BUG_ON(cr0 & X86_CR0_WP);
16262 + write_cr0(cr0);
16263 + return cr0 ^ X86_CR0_WP;
16264 +}
16265 +
16266 +static inline unsigned long native_pax_close_kernel(void)
16267 +{
16268 + unsigned long cr0;
16269 +
16270 + cr0 = read_cr0() ^ X86_CR0_WP;
16271 + BUG_ON(!(cr0 & X86_CR0_WP));
16272 + write_cr0(cr0);
16273 + barrier();
16274 + preempt_enable_no_resched();
16275 + return cr0 ^ X86_CR0_WP;
16276 +}
16277 +#else
16278 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16279 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16280 +#endif
16281 +
16282 /*
16283 * The following only work if pte_present() is true.
16284 * Undefined behaviour if not..
16285 */
16286 +static inline int pte_user(pte_t pte)
16287 +{
16288 + return pte_val(pte) & _PAGE_USER;
16289 +}
16290 +
16291 static inline int pte_dirty(pte_t pte)
16292 {
16293 return pte_flags(pte) & _PAGE_DIRTY;
16294 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16295 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16296 }
16297
16298 +static inline unsigned long pgd_pfn(pgd_t pgd)
16299 +{
16300 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16301 +}
16302 +
16303 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16304
16305 static inline int pmd_large(pmd_t pte)
16306 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16307 return pte_clear_flags(pte, _PAGE_RW);
16308 }
16309
16310 +static inline pte_t pte_mkread(pte_t pte)
16311 +{
16312 + return __pte(pte_val(pte) | _PAGE_USER);
16313 +}
16314 +
16315 static inline pte_t pte_mkexec(pte_t pte)
16316 {
16317 - return pte_clear_flags(pte, _PAGE_NX);
16318 +#ifdef CONFIG_X86_PAE
16319 + if (__supported_pte_mask & _PAGE_NX)
16320 + return pte_clear_flags(pte, _PAGE_NX);
16321 + else
16322 +#endif
16323 + return pte_set_flags(pte, _PAGE_USER);
16324 +}
16325 +
16326 +static inline pte_t pte_exprotect(pte_t pte)
16327 +{
16328 +#ifdef CONFIG_X86_PAE
16329 + if (__supported_pte_mask & _PAGE_NX)
16330 + return pte_set_flags(pte, _PAGE_NX);
16331 + else
16332 +#endif
16333 + return pte_clear_flags(pte, _PAGE_USER);
16334 }
16335
16336 static inline pte_t pte_mkdirty(pte_t pte)
16337 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16338 #endif
16339
16340 #ifndef __ASSEMBLY__
16341 +
16342 +#ifdef CONFIG_PAX_PER_CPU_PGD
16343 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16344 +enum cpu_pgd_type {kernel = 0, user = 1};
16345 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16346 +{
16347 + return cpu_pgd[cpu][type];
16348 +}
16349 +#endif
16350 +
16351 #include <linux/mm_types.h>
16352 #include <linux/log2.h>
16353
16354 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16355 * Currently stuck as a macro due to indirect forward reference to
16356 * linux/mmzone.h's __section_mem_map_addr() definition:
16357 */
16358 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16359 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16360
16361 /* Find an entry in the second-level page table.. */
16362 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16363 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16364 * Currently stuck as a macro due to indirect forward reference to
16365 * linux/mmzone.h's __section_mem_map_addr() definition:
16366 */
16367 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16368 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16369
16370 /* to find an entry in a page-table-directory. */
16371 static inline unsigned long pud_index(unsigned long address)
16372 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16373
16374 static inline int pgd_bad(pgd_t pgd)
16375 {
16376 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16377 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16378 }
16379
16380 static inline int pgd_none(pgd_t pgd)
16381 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16382 * pgd_offset() returns a (pgd_t *)
16383 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16384 */
16385 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16386 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16387 +
16388 +#ifdef CONFIG_PAX_PER_CPU_PGD
16389 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16390 +#endif
16391 +
16392 /*
16393 * a shortcut which implies the use of the kernel's pgd, instead
16394 * of a process's
16395 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16396 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16397 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16398
16399 +#ifdef CONFIG_X86_32
16400 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16401 +#else
16402 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16403 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16404 +
16405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16406 +#ifdef __ASSEMBLY__
16407 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16408 +#else
16409 +extern unsigned long pax_user_shadow_base;
16410 +extern pgdval_t clone_pgd_mask;
16411 +#endif
16412 +#endif
16413 +
16414 +#endif
16415 +
16416 #ifndef __ASSEMBLY__
16417
16418 extern int direct_gbpages;
16419 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16420 * dst and src can be on the same page, but the range must not overlap,
16421 * and must not cross a page boundary.
16422 */
16423 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16424 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16425 {
16426 - memcpy(dst, src, count * sizeof(pgd_t));
16427 + pax_open_kernel();
16428 + while (count--)
16429 + *dst++ = *src++;
16430 + pax_close_kernel();
16431 }
16432
16433 +#ifdef CONFIG_PAX_PER_CPU_PGD
16434 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16435 +#endif
16436 +
16437 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16438 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16439 +#else
16440 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16441 +#endif
16442 +
16443 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16444 static inline int page_level_shift(enum pg_level level)
16445 {
16446 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16447 index 9ee3221..b979c6b 100644
16448 --- a/arch/x86/include/asm/pgtable_32.h
16449 +++ b/arch/x86/include/asm/pgtable_32.h
16450 @@ -25,9 +25,6 @@
16451 struct mm_struct;
16452 struct vm_area_struct;
16453
16454 -extern pgd_t swapper_pg_dir[1024];
16455 -extern pgd_t initial_page_table[1024];
16456 -
16457 static inline void pgtable_cache_init(void) { }
16458 static inline void check_pgt_cache(void) { }
16459 void paging_init(void);
16460 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16461 # include <asm/pgtable-2level.h>
16462 #endif
16463
16464 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16465 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16466 +#ifdef CONFIG_X86_PAE
16467 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16468 +#endif
16469 +
16470 #if defined(CONFIG_HIGHPTE)
16471 #define pte_offset_map(dir, address) \
16472 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16473 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16474 /* Clear a kernel PTE and flush it from the TLB */
16475 #define kpte_clear_flush(ptep, vaddr) \
16476 do { \
16477 + pax_open_kernel(); \
16478 pte_clear(&init_mm, (vaddr), (ptep)); \
16479 + pax_close_kernel(); \
16480 __flush_tlb_one((vaddr)); \
16481 } while (0)
16482
16483 #endif /* !__ASSEMBLY__ */
16484
16485 +#define HAVE_ARCH_UNMAPPED_AREA
16486 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16487 +
16488 /*
16489 * kern_addr_valid() is (1) for FLATMEM and (0) for
16490 * SPARSEMEM and DISCONTIGMEM
16491 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16492 index ed5903b..c7fe163 100644
16493 --- a/arch/x86/include/asm/pgtable_32_types.h
16494 +++ b/arch/x86/include/asm/pgtable_32_types.h
16495 @@ -8,7 +8,7 @@
16496 */
16497 #ifdef CONFIG_X86_PAE
16498 # include <asm/pgtable-3level_types.h>
16499 -# define PMD_SIZE (1UL << PMD_SHIFT)
16500 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16501 # define PMD_MASK (~(PMD_SIZE - 1))
16502 #else
16503 # include <asm/pgtable-2level_types.h>
16504 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16505 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16506 #endif
16507
16508 +#ifdef CONFIG_PAX_KERNEXEC
16509 +#ifndef __ASSEMBLY__
16510 +extern unsigned char MODULES_EXEC_VADDR[];
16511 +extern unsigned char MODULES_EXEC_END[];
16512 +#endif
16513 +#include <asm/boot.h>
16514 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16515 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16516 +#else
16517 +#define ktla_ktva(addr) (addr)
16518 +#define ktva_ktla(addr) (addr)
16519 +#endif
16520 +
16521 #define MODULES_VADDR VMALLOC_START
16522 #define MODULES_END VMALLOC_END
16523 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16524 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16525 index e22c1db..23a625a 100644
16526 --- a/arch/x86/include/asm/pgtable_64.h
16527 +++ b/arch/x86/include/asm/pgtable_64.h
16528 @@ -16,10 +16,14 @@
16529
16530 extern pud_t level3_kernel_pgt[512];
16531 extern pud_t level3_ident_pgt[512];
16532 +extern pud_t level3_vmalloc_start_pgt[512];
16533 +extern pud_t level3_vmalloc_end_pgt[512];
16534 +extern pud_t level3_vmemmap_pgt[512];
16535 +extern pud_t level2_vmemmap_pgt[512];
16536 extern pmd_t level2_kernel_pgt[512];
16537 extern pmd_t level2_fixmap_pgt[512];
16538 -extern pmd_t level2_ident_pgt[512];
16539 -extern pgd_t init_level4_pgt[];
16540 +extern pmd_t level2_ident_pgt[512*2];
16541 +extern pgd_t init_level4_pgt[512];
16542
16543 #define swapper_pg_dir init_level4_pgt
16544
16545 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16546
16547 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16548 {
16549 + pax_open_kernel();
16550 *pmdp = pmd;
16551 + pax_close_kernel();
16552 }
16553
16554 static inline void native_pmd_clear(pmd_t *pmd)
16555 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16556
16557 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16558 {
16559 + pax_open_kernel();
16560 *pudp = pud;
16561 + pax_close_kernel();
16562 }
16563
16564 static inline void native_pud_clear(pud_t *pud)
16565 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16566
16567 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16568 {
16569 + pax_open_kernel();
16570 + *pgdp = pgd;
16571 + pax_close_kernel();
16572 +}
16573 +
16574 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16575 +{
16576 *pgdp = pgd;
16577 }
16578
16579 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16580 index 2d88344..4679fc3 100644
16581 --- a/arch/x86/include/asm/pgtable_64_types.h
16582 +++ b/arch/x86/include/asm/pgtable_64_types.h
16583 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16584 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16585 #define MODULES_END _AC(0xffffffffff000000, UL)
16586 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16587 +#define MODULES_EXEC_VADDR MODULES_VADDR
16588 +#define MODULES_EXEC_END MODULES_END
16589 +
16590 +#define ktla_ktva(addr) (addr)
16591 +#define ktva_ktla(addr) (addr)
16592
16593 #define EARLY_DYNAMIC_PAGE_TABLES 64
16594
16595 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16596 index f4843e0..a2526f8 100644
16597 --- a/arch/x86/include/asm/pgtable_types.h
16598 +++ b/arch/x86/include/asm/pgtable_types.h
16599 @@ -16,13 +16,12 @@
16600 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16601 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16602 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16603 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16604 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16605 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16606 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16607 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16608 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16609 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16610 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16611 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16612 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16613 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16614
16615 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16616 @@ -40,7 +39,6 @@
16617 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16618 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16619 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16620 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16621 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16622 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16623 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16624 @@ -84,8 +82,10 @@
16625
16626 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16627 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16628 -#else
16629 +#elif defined(CONFIG_KMEMCHECK)
16630 #define _PAGE_NX (_AT(pteval_t, 0))
16631 +#else
16632 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16633 #endif
16634
16635 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16636 @@ -143,6 +143,9 @@
16637 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16638 _PAGE_ACCESSED)
16639
16640 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16641 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16642 +
16643 #define __PAGE_KERNEL_EXEC \
16644 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16645 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16646 @@ -153,7 +156,7 @@
16647 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16648 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16649 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16650 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16651 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16652 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16653 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16654 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16655 @@ -215,8 +218,8 @@
16656 * bits are combined, this will alow user to access the high address mapped
16657 * VDSO in the presence of CONFIG_COMPAT_VDSO
16658 */
16659 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16660 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16661 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16662 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16663 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16664 #endif
16665
16666 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16667 {
16668 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16669 }
16670 +#endif
16671
16672 +#if PAGETABLE_LEVELS == 3
16673 +#include <asm-generic/pgtable-nopud.h>
16674 +#endif
16675 +
16676 +#if PAGETABLE_LEVELS == 2
16677 +#include <asm-generic/pgtable-nopmd.h>
16678 +#endif
16679 +
16680 +#ifndef __ASSEMBLY__
16681 #if PAGETABLE_LEVELS > 3
16682 typedef struct { pudval_t pud; } pud_t;
16683
16684 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16685 return pud.pud;
16686 }
16687 #else
16688 -#include <asm-generic/pgtable-nopud.h>
16689 -
16690 static inline pudval_t native_pud_val(pud_t pud)
16691 {
16692 return native_pgd_val(pud.pgd);
16693 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16694 return pmd.pmd;
16695 }
16696 #else
16697 -#include <asm-generic/pgtable-nopmd.h>
16698 -
16699 static inline pmdval_t native_pmd_val(pmd_t pmd)
16700 {
16701 return native_pgd_val(pmd.pud.pgd);
16702 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16703
16704 extern pteval_t __supported_pte_mask;
16705 extern void set_nx(void);
16706 -extern int nx_enabled;
16707
16708 #define pgprot_writecombine pgprot_writecombine
16709 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16710 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16711 index 24cf5ae..4d9fa2d 100644
16712 --- a/arch/x86/include/asm/processor.h
16713 +++ b/arch/x86/include/asm/processor.h
16714 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16715 : "memory");
16716 }
16717
16718 +/* invpcid (%rdx),%rax */
16719 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16720 +
16721 +#define INVPCID_SINGLE_ADDRESS 0UL
16722 +#define INVPCID_SINGLE_CONTEXT 1UL
16723 +#define INVPCID_ALL_GLOBAL 2UL
16724 +#define INVPCID_ALL_MONGLOBAL 3UL
16725 +
16726 +#define PCID_KERNEL 0UL
16727 +#define PCID_USER 1UL
16728 +#define PCID_NOFLUSH (1UL << 63)
16729 +
16730 static inline void load_cr3(pgd_t *pgdir)
16731 {
16732 - write_cr3(__pa(pgdir));
16733 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16734 }
16735
16736 #ifdef CONFIG_X86_32
16737 @@ -283,7 +295,7 @@ struct tss_struct {
16738
16739 } ____cacheline_aligned;
16740
16741 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16742 +extern struct tss_struct init_tss[NR_CPUS];
16743
16744 /*
16745 * Save the original ist values for checking stack pointers during debugging
16746 @@ -453,6 +465,7 @@ struct thread_struct {
16747 unsigned short ds;
16748 unsigned short fsindex;
16749 unsigned short gsindex;
16750 + unsigned short ss;
16751 #endif
16752 #ifdef CONFIG_X86_32
16753 unsigned long ip;
16754 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16755 extern unsigned long mmu_cr4_features;
16756 extern u32 *trampoline_cr4_features;
16757
16758 -static inline void set_in_cr4(unsigned long mask)
16759 -{
16760 - unsigned long cr4;
16761 -
16762 - mmu_cr4_features |= mask;
16763 - if (trampoline_cr4_features)
16764 - *trampoline_cr4_features = mmu_cr4_features;
16765 - cr4 = read_cr4();
16766 - cr4 |= mask;
16767 - write_cr4(cr4);
16768 -}
16769 -
16770 -static inline void clear_in_cr4(unsigned long mask)
16771 -{
16772 - unsigned long cr4;
16773 -
16774 - mmu_cr4_features &= ~mask;
16775 - if (trampoline_cr4_features)
16776 - *trampoline_cr4_features = mmu_cr4_features;
16777 - cr4 = read_cr4();
16778 - cr4 &= ~mask;
16779 - write_cr4(cr4);
16780 -}
16781 +extern void set_in_cr4(unsigned long mask);
16782 +extern void clear_in_cr4(unsigned long mask);
16783
16784 typedef struct {
16785 unsigned long seg;
16786 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16787 */
16788 #define TASK_SIZE PAGE_OFFSET
16789 #define TASK_SIZE_MAX TASK_SIZE
16790 +
16791 +#ifdef CONFIG_PAX_SEGMEXEC
16792 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16793 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16794 +#else
16795 #define STACK_TOP TASK_SIZE
16796 -#define STACK_TOP_MAX STACK_TOP
16797 +#endif
16798 +
16799 +#define STACK_TOP_MAX TASK_SIZE
16800
16801 #define INIT_THREAD { \
16802 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16803 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16804 .vm86_info = NULL, \
16805 .sysenter_cs = __KERNEL_CS, \
16806 .io_bitmap_ptr = NULL, \
16807 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16808 */
16809 #define INIT_TSS { \
16810 .x86_tss = { \
16811 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16812 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16813 .ss0 = __KERNEL_DS, \
16814 .ss1 = __KERNEL_CS, \
16815 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16816 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16817 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16818
16819 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16820 -#define KSTK_TOP(info) \
16821 -({ \
16822 - unsigned long *__ptr = (unsigned long *)(info); \
16823 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16824 -})
16825 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16826
16827 /*
16828 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16829 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16830 #define task_pt_regs(task) \
16831 ({ \
16832 struct pt_regs *__regs__; \
16833 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16834 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16835 __regs__ - 1; \
16836 })
16837
16838 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16839 /*
16840 * User space process size. 47bits minus one guard page.
16841 */
16842 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16843 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16844
16845 /* This decides where the kernel will search for a free chunk of vm
16846 * space during mmap's.
16847 */
16848 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16849 - 0xc0000000 : 0xFFFFe000)
16850 + 0xc0000000 : 0xFFFFf000)
16851
16852 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16853 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16854 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16855 #define STACK_TOP_MAX TASK_SIZE_MAX
16856
16857 #define INIT_THREAD { \
16858 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16859 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16860 }
16861
16862 #define INIT_TSS { \
16863 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16864 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16865 }
16866
16867 /*
16868 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16869 */
16870 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16871
16872 +#ifdef CONFIG_PAX_SEGMEXEC
16873 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16874 +#endif
16875 +
16876 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16877
16878 /* Get/set a process' ability to use the timestamp counter instruction */
16879 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16880 extern u16 amd_get_nb_id(int cpu);
16881
16882 struct aperfmperf {
16883 - u64 aperf, mperf;
16884 + u64 aperf __intentional_overflow(0);
16885 + u64 mperf __intentional_overflow(0);
16886 };
16887
16888 static inline void get_aperfmperf(struct aperfmperf *am)
16889 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16890 return ratio;
16891 }
16892
16893 -extern unsigned long arch_align_stack(unsigned long sp);
16894 +#define arch_align_stack(x) ((x) & ~0xfUL)
16895 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16896
16897 void default_idle(void);
16898 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16899 #define xen_set_default_idle 0
16900 #endif
16901
16902 -void stop_this_cpu(void *dummy);
16903 +void stop_this_cpu(void *dummy) __noreturn;
16904 void df_debug(struct pt_regs *regs, long error_code);
16905 #endif /* _ASM_X86_PROCESSOR_H */
16906 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16907 index 942a086..6c26446 100644
16908 --- a/arch/x86/include/asm/ptrace.h
16909 +++ b/arch/x86/include/asm/ptrace.h
16910 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16911 }
16912
16913 /*
16914 - * user_mode_vm(regs) determines whether a register set came from user mode.
16915 + * user_mode(regs) determines whether a register set came from user mode.
16916 * This is true if V8086 mode was enabled OR if the register set was from
16917 * protected mode with RPL-3 CS value. This tricky test checks that with
16918 * one comparison. Many places in the kernel can bypass this full check
16919 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16920 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16921 + * be used.
16922 */
16923 -static inline int user_mode(struct pt_regs *regs)
16924 +static inline int user_mode_novm(struct pt_regs *regs)
16925 {
16926 #ifdef CONFIG_X86_32
16927 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
16928 #else
16929 - return !!(regs->cs & 3);
16930 + return !!(regs->cs & SEGMENT_RPL_MASK);
16931 #endif
16932 }
16933
16934 -static inline int user_mode_vm(struct pt_regs *regs)
16935 +static inline int user_mode(struct pt_regs *regs)
16936 {
16937 #ifdef CONFIG_X86_32
16938 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
16939 USER_RPL;
16940 #else
16941 - return user_mode(regs);
16942 + return user_mode_novm(regs);
16943 #endif
16944 }
16945
16946 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
16947 #ifdef CONFIG_X86_64
16948 static inline bool user_64bit_mode(struct pt_regs *regs)
16949 {
16950 + unsigned long cs = regs->cs & 0xffff;
16951 #ifndef CONFIG_PARAVIRT
16952 /*
16953 * On non-paravirt systems, this is the only long mode CPL 3
16954 * selector. We do not allow long mode selectors in the LDT.
16955 */
16956 - return regs->cs == __USER_CS;
16957 + return cs == __USER_CS;
16958 #else
16959 /* Headers are too twisted for this to go in paravirt.h. */
16960 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
16961 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
16962 #endif
16963 }
16964
16965 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
16966 * Traps from the kernel do not save sp and ss.
16967 * Use the helper function to retrieve sp.
16968 */
16969 - if (offset == offsetof(struct pt_regs, sp) &&
16970 - regs->cs == __KERNEL_CS)
16971 - return kernel_stack_pointer(regs);
16972 + if (offset == offsetof(struct pt_regs, sp)) {
16973 + unsigned long cs = regs->cs & 0xffff;
16974 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
16975 + return kernel_stack_pointer(regs);
16976 + }
16977 #endif
16978 return *(unsigned long *)((unsigned long)regs + offset);
16979 }
16980 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
16981 index 9c6b890..5305f53 100644
16982 --- a/arch/x86/include/asm/realmode.h
16983 +++ b/arch/x86/include/asm/realmode.h
16984 @@ -22,16 +22,14 @@ struct real_mode_header {
16985 #endif
16986 /* APM/BIOS reboot */
16987 u32 machine_real_restart_asm;
16988 -#ifdef CONFIG_X86_64
16989 u32 machine_real_restart_seg;
16990 -#endif
16991 };
16992
16993 /* This must match data at trampoline_32/64.S */
16994 struct trampoline_header {
16995 #ifdef CONFIG_X86_32
16996 u32 start;
16997 - u16 gdt_pad;
16998 + u16 boot_cs;
16999 u16 gdt_limit;
17000 u32 gdt_base;
17001 #else
17002 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17003 index a82c4f1..ac45053 100644
17004 --- a/arch/x86/include/asm/reboot.h
17005 +++ b/arch/x86/include/asm/reboot.h
17006 @@ -6,13 +6,13 @@
17007 struct pt_regs;
17008
17009 struct machine_ops {
17010 - void (*restart)(char *cmd);
17011 - void (*halt)(void);
17012 - void (*power_off)(void);
17013 + void (* __noreturn restart)(char *cmd);
17014 + void (* __noreturn halt)(void);
17015 + void (* __noreturn power_off)(void);
17016 void (*shutdown)(void);
17017 void (*crash_shutdown)(struct pt_regs *);
17018 - void (*emergency_restart)(void);
17019 -};
17020 + void (* __noreturn emergency_restart)(void);
17021 +} __no_const;
17022
17023 extern struct machine_ops machine_ops;
17024
17025 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17026 index cad82c9..2e5c5c1 100644
17027 --- a/arch/x86/include/asm/rwsem.h
17028 +++ b/arch/x86/include/asm/rwsem.h
17029 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17030 {
17031 asm volatile("# beginning down_read\n\t"
17032 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17033 +
17034 +#ifdef CONFIG_PAX_REFCOUNT
17035 + "jno 0f\n"
17036 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17037 + "int $4\n0:\n"
17038 + _ASM_EXTABLE(0b, 0b)
17039 +#endif
17040 +
17041 /* adds 0x00000001 */
17042 " jns 1f\n"
17043 " call call_rwsem_down_read_failed\n"
17044 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17045 "1:\n\t"
17046 " mov %1,%2\n\t"
17047 " add %3,%2\n\t"
17048 +
17049 +#ifdef CONFIG_PAX_REFCOUNT
17050 + "jno 0f\n"
17051 + "sub %3,%2\n"
17052 + "int $4\n0:\n"
17053 + _ASM_EXTABLE(0b, 0b)
17054 +#endif
17055 +
17056 " jle 2f\n\t"
17057 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17058 " jnz 1b\n\t"
17059 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17060 long tmp;
17061 asm volatile("# beginning down_write\n\t"
17062 LOCK_PREFIX " xadd %1,(%2)\n\t"
17063 +
17064 +#ifdef CONFIG_PAX_REFCOUNT
17065 + "jno 0f\n"
17066 + "mov %1,(%2)\n"
17067 + "int $4\n0:\n"
17068 + _ASM_EXTABLE(0b, 0b)
17069 +#endif
17070 +
17071 /* adds 0xffff0001, returns the old value */
17072 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17073 /* was the active mask 0 before? */
17074 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17075 long tmp;
17076 asm volatile("# beginning __up_read\n\t"
17077 LOCK_PREFIX " xadd %1,(%2)\n\t"
17078 +
17079 +#ifdef CONFIG_PAX_REFCOUNT
17080 + "jno 0f\n"
17081 + "mov %1,(%2)\n"
17082 + "int $4\n0:\n"
17083 + _ASM_EXTABLE(0b, 0b)
17084 +#endif
17085 +
17086 /* subtracts 1, returns the old value */
17087 " jns 1f\n\t"
17088 " call call_rwsem_wake\n" /* expects old value in %edx */
17089 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17090 long tmp;
17091 asm volatile("# beginning __up_write\n\t"
17092 LOCK_PREFIX " xadd %1,(%2)\n\t"
17093 +
17094 +#ifdef CONFIG_PAX_REFCOUNT
17095 + "jno 0f\n"
17096 + "mov %1,(%2)\n"
17097 + "int $4\n0:\n"
17098 + _ASM_EXTABLE(0b, 0b)
17099 +#endif
17100 +
17101 /* subtracts 0xffff0001, returns the old value */
17102 " jns 1f\n\t"
17103 " call call_rwsem_wake\n" /* expects old value in %edx */
17104 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17105 {
17106 asm volatile("# beginning __downgrade_write\n\t"
17107 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17108 +
17109 +#ifdef CONFIG_PAX_REFCOUNT
17110 + "jno 0f\n"
17111 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17112 + "int $4\n0:\n"
17113 + _ASM_EXTABLE(0b, 0b)
17114 +#endif
17115 +
17116 /*
17117 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17118 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17119 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17120 */
17121 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17122 {
17123 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17124 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17125 +
17126 +#ifdef CONFIG_PAX_REFCOUNT
17127 + "jno 0f\n"
17128 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17129 + "int $4\n0:\n"
17130 + _ASM_EXTABLE(0b, 0b)
17131 +#endif
17132 +
17133 : "+m" (sem->count)
17134 : "er" (delta));
17135 }
17136 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17137 */
17138 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17139 {
17140 - return delta + xadd(&sem->count, delta);
17141 + return delta + xadd_check_overflow(&sem->count, delta);
17142 }
17143
17144 #endif /* __KERNEL__ */
17145 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17146 index c48a950..bc40804 100644
17147 --- a/arch/x86/include/asm/segment.h
17148 +++ b/arch/x86/include/asm/segment.h
17149 @@ -64,10 +64,15 @@
17150 * 26 - ESPFIX small SS
17151 * 27 - per-cpu [ offset to per-cpu data area ]
17152 * 28 - stack_canary-20 [ for stack protector ]
17153 - * 29 - unused
17154 - * 30 - unused
17155 + * 29 - PCI BIOS CS
17156 + * 30 - PCI BIOS DS
17157 * 31 - TSS for double fault handler
17158 */
17159 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17160 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17161 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17162 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17163 +
17164 #define GDT_ENTRY_TLS_MIN 6
17165 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17166
17167 @@ -79,6 +84,8 @@
17168
17169 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17170
17171 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17172 +
17173 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17174
17175 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17176 @@ -104,6 +111,12 @@
17177 #define __KERNEL_STACK_CANARY 0
17178 #endif
17179
17180 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17181 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17182 +
17183 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17184 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17185 +
17186 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17187
17188 /*
17189 @@ -141,7 +154,7 @@
17190 */
17191
17192 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17193 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17194 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17195
17196
17197 #else
17198 @@ -165,6 +178,8 @@
17199 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17200 #define __USER32_DS __USER_DS
17201
17202 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17203 +
17204 #define GDT_ENTRY_TSS 8 /* needs two entries */
17205 #define GDT_ENTRY_LDT 10 /* needs two entries */
17206 #define GDT_ENTRY_TLS_MIN 12
17207 @@ -173,6 +188,8 @@
17208 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17209 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17210
17211 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17212 +
17213 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17214 #define FS_TLS 0
17215 #define GS_TLS 1
17216 @@ -180,12 +197,14 @@
17217 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17218 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17219
17220 -#define GDT_ENTRIES 16
17221 +#define GDT_ENTRIES 17
17222
17223 #endif
17224
17225 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17226 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17227 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17228 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17229 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17230 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17231 #ifndef CONFIG_PARAVIRT
17232 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17233 {
17234 unsigned long __limit;
17235 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17236 - return __limit + 1;
17237 + return __limit;
17238 }
17239
17240 #endif /* !__ASSEMBLY__ */
17241 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17242 index 8d3120f..352b440 100644
17243 --- a/arch/x86/include/asm/smap.h
17244 +++ b/arch/x86/include/asm/smap.h
17245 @@ -25,11 +25,40 @@
17246
17247 #include <asm/alternative-asm.h>
17248
17249 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17250 +#define ASM_PAX_OPEN_USERLAND \
17251 + 661: jmp 663f; \
17252 + .pushsection .altinstr_replacement, "a" ; \
17253 + 662: pushq %rax; nop; \
17254 + .popsection ; \
17255 + .pushsection .altinstructions, "a" ; \
17256 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17257 + .popsection ; \
17258 + call __pax_open_userland; \
17259 + popq %rax; \
17260 + 663:
17261 +
17262 +#define ASM_PAX_CLOSE_USERLAND \
17263 + 661: jmp 663f; \
17264 + .pushsection .altinstr_replacement, "a" ; \
17265 + 662: pushq %rax; nop; \
17266 + .popsection; \
17267 + .pushsection .altinstructions, "a" ; \
17268 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17269 + .popsection; \
17270 + call __pax_close_userland; \
17271 + popq %rax; \
17272 + 663:
17273 +#else
17274 +#define ASM_PAX_OPEN_USERLAND
17275 +#define ASM_PAX_CLOSE_USERLAND
17276 +#endif
17277 +
17278 #ifdef CONFIG_X86_SMAP
17279
17280 #define ASM_CLAC \
17281 661: ASM_NOP3 ; \
17282 - .pushsection .altinstr_replacement, "ax" ; \
17283 + .pushsection .altinstr_replacement, "a" ; \
17284 662: __ASM_CLAC ; \
17285 .popsection ; \
17286 .pushsection .altinstructions, "a" ; \
17287 @@ -38,7 +67,7 @@
17288
17289 #define ASM_STAC \
17290 661: ASM_NOP3 ; \
17291 - .pushsection .altinstr_replacement, "ax" ; \
17292 + .pushsection .altinstr_replacement, "a" ; \
17293 662: __ASM_STAC ; \
17294 .popsection ; \
17295 .pushsection .altinstructions, "a" ; \
17296 @@ -56,6 +85,37 @@
17297
17298 #include <asm/alternative.h>
17299
17300 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17301 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17302 +
17303 +extern void __pax_open_userland(void);
17304 +static __always_inline unsigned long pax_open_userland(void)
17305 +{
17306 +
17307 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17308 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17309 + :
17310 + : [open] "i" (__pax_open_userland)
17311 + : "memory", "rax");
17312 +#endif
17313 +
17314 + return 0;
17315 +}
17316 +
17317 +extern void __pax_close_userland(void);
17318 +static __always_inline unsigned long pax_close_userland(void)
17319 +{
17320 +
17321 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17322 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17323 + :
17324 + : [close] "i" (__pax_close_userland)
17325 + : "memory", "rax");
17326 +#endif
17327 +
17328 + return 0;
17329 +}
17330 +
17331 #ifdef CONFIG_X86_SMAP
17332
17333 static __always_inline void clac(void)
17334 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17335 index 4137890..03fa172 100644
17336 --- a/arch/x86/include/asm/smp.h
17337 +++ b/arch/x86/include/asm/smp.h
17338 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17339 /* cpus sharing the last level cache: */
17340 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17341 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17342 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17343 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17344
17345 static inline struct cpumask *cpu_sibling_mask(int cpu)
17346 {
17347 @@ -79,7 +79,7 @@ struct smp_ops {
17348
17349 void (*send_call_func_ipi)(const struct cpumask *mask);
17350 void (*send_call_func_single_ipi)(int cpu);
17351 -};
17352 +} __no_const;
17353
17354 /* Globals due to paravirt */
17355 extern void set_cpu_sibling_map(int cpu);
17356 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17357 extern int safe_smp_processor_id(void);
17358
17359 #elif defined(CONFIG_X86_64_SMP)
17360 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17361 -
17362 -#define stack_smp_processor_id() \
17363 -({ \
17364 - struct thread_info *ti; \
17365 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17366 - ti->cpu; \
17367 -})
17368 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17369 +#define stack_smp_processor_id() raw_smp_processor_id()
17370 #define safe_smp_processor_id() smp_processor_id()
17371
17372 #endif
17373 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17374 index e3ddd7d..3611fce 100644
17375 --- a/arch/x86/include/asm/spinlock.h
17376 +++ b/arch/x86/include/asm/spinlock.h
17377 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17378 static inline void arch_read_lock(arch_rwlock_t *rw)
17379 {
17380 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17381 +
17382 +#ifdef CONFIG_PAX_REFCOUNT
17383 + "jno 0f\n"
17384 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17385 + "int $4\n0:\n"
17386 + _ASM_EXTABLE(0b, 0b)
17387 +#endif
17388 +
17389 "jns 1f\n"
17390 "call __read_lock_failed\n\t"
17391 "1:\n"
17392 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17393 static inline void arch_write_lock(arch_rwlock_t *rw)
17394 {
17395 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17396 +
17397 +#ifdef CONFIG_PAX_REFCOUNT
17398 + "jno 0f\n"
17399 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17400 + "int $4\n0:\n"
17401 + _ASM_EXTABLE(0b, 0b)
17402 +#endif
17403 +
17404 "jz 1f\n"
17405 "call __write_lock_failed\n\t"
17406 "1:\n"
17407 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17408
17409 static inline void arch_read_unlock(arch_rwlock_t *rw)
17410 {
17411 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17412 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17413 +
17414 +#ifdef CONFIG_PAX_REFCOUNT
17415 + "jno 0f\n"
17416 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17417 + "int $4\n0:\n"
17418 + _ASM_EXTABLE(0b, 0b)
17419 +#endif
17420 +
17421 :"+m" (rw->lock) : : "memory");
17422 }
17423
17424 static inline void arch_write_unlock(arch_rwlock_t *rw)
17425 {
17426 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17427 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17428 +
17429 +#ifdef CONFIG_PAX_REFCOUNT
17430 + "jno 0f\n"
17431 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17432 + "int $4\n0:\n"
17433 + _ASM_EXTABLE(0b, 0b)
17434 +#endif
17435 +
17436 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17437 }
17438
17439 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17440 index 6a99859..03cb807 100644
17441 --- a/arch/x86/include/asm/stackprotector.h
17442 +++ b/arch/x86/include/asm/stackprotector.h
17443 @@ -47,7 +47,7 @@
17444 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17445 */
17446 #define GDT_STACK_CANARY_INIT \
17447 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17448 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17449
17450 /*
17451 * Initialize the stackprotector canary value.
17452 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17453
17454 static inline void load_stack_canary_segment(void)
17455 {
17456 -#ifdef CONFIG_X86_32
17457 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17458 asm volatile ("mov %0, %%gs" : : "r" (0));
17459 #endif
17460 }
17461 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17462 index 70bbe39..4ae2bd4 100644
17463 --- a/arch/x86/include/asm/stacktrace.h
17464 +++ b/arch/x86/include/asm/stacktrace.h
17465 @@ -11,28 +11,20 @@
17466
17467 extern int kstack_depth_to_print;
17468
17469 -struct thread_info;
17470 +struct task_struct;
17471 struct stacktrace_ops;
17472
17473 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17474 - unsigned long *stack,
17475 - unsigned long bp,
17476 - const struct stacktrace_ops *ops,
17477 - void *data,
17478 - unsigned long *end,
17479 - int *graph);
17480 +typedef unsigned long walk_stack_t(struct task_struct *task,
17481 + void *stack_start,
17482 + unsigned long *stack,
17483 + unsigned long bp,
17484 + const struct stacktrace_ops *ops,
17485 + void *data,
17486 + unsigned long *end,
17487 + int *graph);
17488
17489 -extern unsigned long
17490 -print_context_stack(struct thread_info *tinfo,
17491 - unsigned long *stack, unsigned long bp,
17492 - const struct stacktrace_ops *ops, void *data,
17493 - unsigned long *end, int *graph);
17494 -
17495 -extern unsigned long
17496 -print_context_stack_bp(struct thread_info *tinfo,
17497 - unsigned long *stack, unsigned long bp,
17498 - const struct stacktrace_ops *ops, void *data,
17499 - unsigned long *end, int *graph);
17500 +extern walk_stack_t print_context_stack;
17501 +extern walk_stack_t print_context_stack_bp;
17502
17503 /* Generic stack tracer with callbacks */
17504
17505 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17506 void (*address)(void *data, unsigned long address, int reliable);
17507 /* On negative return stop dumping */
17508 int (*stack)(void *data, char *name);
17509 - walk_stack_t walk_stack;
17510 + walk_stack_t *walk_stack;
17511 };
17512
17513 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17514 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17515 index 4ec45b3..a4f0a8a 100644
17516 --- a/arch/x86/include/asm/switch_to.h
17517 +++ b/arch/x86/include/asm/switch_to.h
17518 @@ -108,7 +108,7 @@ do { \
17519 "call __switch_to\n\t" \
17520 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17521 __switch_canary \
17522 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17523 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17524 "movq %%rax,%%rdi\n\t" \
17525 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17526 "jnz ret_from_fork\n\t" \
17527 @@ -119,7 +119,7 @@ do { \
17528 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17529 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17530 [_tif_fork] "i" (_TIF_FORK), \
17531 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17532 + [thread_info] "m" (current_tinfo), \
17533 [current_task] "m" (current_task) \
17534 __switch_canary_iparam \
17535 : "memory", "cc" __EXTRA_CLOBBER)
17536 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17537 index 2781119..618b59b 100644
17538 --- a/arch/x86/include/asm/thread_info.h
17539 +++ b/arch/x86/include/asm/thread_info.h
17540 @@ -10,6 +10,7 @@
17541 #include <linux/compiler.h>
17542 #include <asm/page.h>
17543 #include <asm/types.h>
17544 +#include <asm/percpu.h>
17545
17546 /*
17547 * low level task data that entry.S needs immediate access to
17548 @@ -23,7 +24,6 @@ struct exec_domain;
17549 #include <linux/atomic.h>
17550
17551 struct thread_info {
17552 - struct task_struct *task; /* main task structure */
17553 struct exec_domain *exec_domain; /* execution domain */
17554 __u32 flags; /* low level flags */
17555 __u32 status; /* thread synchronous flags */
17556 @@ -33,19 +33,13 @@ struct thread_info {
17557 mm_segment_t addr_limit;
17558 struct restart_block restart_block;
17559 void __user *sysenter_return;
17560 -#ifdef CONFIG_X86_32
17561 - unsigned long previous_esp; /* ESP of the previous stack in
17562 - case of nested (IRQ) stacks
17563 - */
17564 - __u8 supervisor_stack[0];
17565 -#endif
17566 + unsigned long lowest_stack;
17567 unsigned int sig_on_uaccess_error:1;
17568 unsigned int uaccess_err:1; /* uaccess failed */
17569 };
17570
17571 -#define INIT_THREAD_INFO(tsk) \
17572 +#define INIT_THREAD_INFO \
17573 { \
17574 - .task = &tsk, \
17575 .exec_domain = &default_exec_domain, \
17576 .flags = 0, \
17577 .cpu = 0, \
17578 @@ -56,7 +50,7 @@ struct thread_info {
17579 }, \
17580 }
17581
17582 -#define init_thread_info (init_thread_union.thread_info)
17583 +#define init_thread_info (init_thread_union.stack)
17584 #define init_stack (init_thread_union.stack)
17585
17586 #else /* !__ASSEMBLY__ */
17587 @@ -96,6 +90,7 @@ struct thread_info {
17588 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17589 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17590 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17591 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17592
17593 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17594 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17595 @@ -119,17 +114,18 @@ struct thread_info {
17596 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17597 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17598 #define _TIF_X32 (1 << TIF_X32)
17599 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17600
17601 /* work to do in syscall_trace_enter() */
17602 #define _TIF_WORK_SYSCALL_ENTRY \
17603 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17604 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17605 - _TIF_NOHZ)
17606 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17607
17608 /* work to do in syscall_trace_leave() */
17609 #define _TIF_WORK_SYSCALL_EXIT \
17610 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17611 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17612 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17613
17614 /* work to do on interrupt/exception return */
17615 #define _TIF_WORK_MASK \
17616 @@ -140,7 +136,7 @@ struct thread_info {
17617 /* work to do on any return to user space */
17618 #define _TIF_ALLWORK_MASK \
17619 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17620 - _TIF_NOHZ)
17621 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17622
17623 /* Only used for 64 bit */
17624 #define _TIF_DO_NOTIFY_MASK \
17625 @@ -156,45 +152,40 @@ struct thread_info {
17626
17627 #define PREEMPT_ACTIVE 0x10000000
17628
17629 -#ifdef CONFIG_X86_32
17630 -
17631 -#define STACK_WARN (THREAD_SIZE/8)
17632 -/*
17633 - * macros/functions for gaining access to the thread information structure
17634 - *
17635 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17636 - */
17637 -#ifndef __ASSEMBLY__
17638 -
17639 -
17640 -/* how to get the current stack pointer from C */
17641 -register unsigned long current_stack_pointer asm("esp") __used;
17642 -
17643 -/* how to get the thread information struct from C */
17644 -static inline struct thread_info *current_thread_info(void)
17645 -{
17646 - return (struct thread_info *)
17647 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17648 -}
17649 -
17650 -#else /* !__ASSEMBLY__ */
17651 -
17652 +#ifdef __ASSEMBLY__
17653 /* how to get the thread information struct from ASM */
17654 #define GET_THREAD_INFO(reg) \
17655 - movl $-THREAD_SIZE, reg; \
17656 - andl %esp, reg
17657 + mov PER_CPU_VAR(current_tinfo), reg
17658
17659 /* use this one if reg already contains %esp */
17660 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17661 - andl $-THREAD_SIZE, reg
17662 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17663 +#else
17664 +/* how to get the thread information struct from C */
17665 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17666 +
17667 +static __always_inline struct thread_info *current_thread_info(void)
17668 +{
17669 + return this_cpu_read_stable(current_tinfo);
17670 +}
17671 +#endif
17672 +
17673 +#ifdef CONFIG_X86_32
17674 +
17675 +#define STACK_WARN (THREAD_SIZE/8)
17676 +/*
17677 + * macros/functions for gaining access to the thread information structure
17678 + *
17679 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17680 + */
17681 +#ifndef __ASSEMBLY__
17682 +
17683 +/* how to get the current stack pointer from C */
17684 +register unsigned long current_stack_pointer asm("esp") __used;
17685
17686 #endif
17687
17688 #else /* X86_32 */
17689
17690 -#include <asm/percpu.h>
17691 -#define KERNEL_STACK_OFFSET (5*8)
17692 -
17693 /*
17694 * macros/functions for gaining access to the thread information structure
17695 * preempt_count needs to be 1 initially, until the scheduler is functional.
17696 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17697 #ifndef __ASSEMBLY__
17698 DECLARE_PER_CPU(unsigned long, kernel_stack);
17699
17700 -static inline struct thread_info *current_thread_info(void)
17701 -{
17702 - struct thread_info *ti;
17703 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17704 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17705 - return ti;
17706 -}
17707 -
17708 -#else /* !__ASSEMBLY__ */
17709 -
17710 -/* how to get the thread information struct from ASM */
17711 -#define GET_THREAD_INFO(reg) \
17712 - movq PER_CPU_VAR(kernel_stack),reg ; \
17713 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17714 -
17715 -/*
17716 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17717 - * a certain register (to be used in assembler memory operands).
17718 - */
17719 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17720 -
17721 +/* how to get the current stack pointer from C */
17722 +register unsigned long current_stack_pointer asm("rsp") __used;
17723 #endif
17724
17725 #endif /* !X86_32 */
17726 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17727 extern void arch_task_cache_init(void);
17728 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17729 extern void arch_release_task_struct(struct task_struct *tsk);
17730 +
17731 +#define __HAVE_THREAD_FUNCTIONS
17732 +#define task_thread_info(task) (&(task)->tinfo)
17733 +#define task_stack_page(task) ((task)->stack)
17734 +#define setup_thread_stack(p, org) do {} while (0)
17735 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17736 +
17737 #endif
17738 #endif /* _ASM_X86_THREAD_INFO_H */
17739 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17740 index cf51200..63ff068 100644
17741 --- a/arch/x86/include/asm/tlbflush.h
17742 +++ b/arch/x86/include/asm/tlbflush.h
17743 @@ -17,18 +17,44 @@
17744
17745 static inline void __native_flush_tlb(void)
17746 {
17747 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17748 + u64 descriptor[2];
17749 +
17750 + descriptor[0] = PCID_KERNEL;
17751 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17752 + return;
17753 + }
17754 +
17755 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17756 + if (static_cpu_has(X86_FEATURE_PCID)) {
17757 + unsigned int cpu = raw_get_cpu();
17758 +
17759 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17760 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17761 + raw_put_cpu_no_resched();
17762 + return;
17763 + }
17764 +#endif
17765 +
17766 native_write_cr3(native_read_cr3());
17767 }
17768
17769 static inline void __native_flush_tlb_global_irq_disabled(void)
17770 {
17771 - unsigned long cr4;
17772 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17773 + u64 descriptor[2];
17774
17775 - cr4 = native_read_cr4();
17776 - /* clear PGE */
17777 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17778 - /* write old PGE again and flush TLBs */
17779 - native_write_cr4(cr4);
17780 + descriptor[0] = PCID_KERNEL;
17781 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17782 + } else {
17783 + unsigned long cr4;
17784 +
17785 + cr4 = native_read_cr4();
17786 + /* clear PGE */
17787 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17788 + /* write old PGE again and flush TLBs */
17789 + native_write_cr4(cr4);
17790 + }
17791 }
17792
17793 static inline void __native_flush_tlb_global(void)
17794 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17795
17796 static inline void __native_flush_tlb_single(unsigned long addr)
17797 {
17798 +
17799 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17800 + u64 descriptor[2];
17801 +
17802 + descriptor[0] = PCID_KERNEL;
17803 + descriptor[1] = addr;
17804 +
17805 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17806 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17807 + if (addr < TASK_SIZE_MAX)
17808 + descriptor[1] += pax_user_shadow_base;
17809 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17810 + }
17811 +
17812 + descriptor[0] = PCID_USER;
17813 + descriptor[1] = addr;
17814 +#endif
17815 +
17816 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17817 + return;
17818 + }
17819 +
17820 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17821 + if (static_cpu_has(X86_FEATURE_PCID)) {
17822 + unsigned int cpu = raw_get_cpu();
17823 +
17824 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17825 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17826 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17827 + raw_put_cpu_no_resched();
17828 +
17829 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17830 + addr += pax_user_shadow_base;
17831 + }
17832 +#endif
17833 +
17834 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17835 }
17836
17837 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17838 index 5ee2687..74590b9 100644
17839 --- a/arch/x86/include/asm/uaccess.h
17840 +++ b/arch/x86/include/asm/uaccess.h
17841 @@ -7,6 +7,7 @@
17842 #include <linux/compiler.h>
17843 #include <linux/thread_info.h>
17844 #include <linux/string.h>
17845 +#include <linux/sched.h>
17846 #include <asm/asm.h>
17847 #include <asm/page.h>
17848 #include <asm/smap.h>
17849 @@ -29,7 +30,12 @@
17850
17851 #define get_ds() (KERNEL_DS)
17852 #define get_fs() (current_thread_info()->addr_limit)
17853 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17854 +void __set_fs(mm_segment_t x);
17855 +void set_fs(mm_segment_t x);
17856 +#else
17857 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17858 +#endif
17859
17860 #define segment_eq(a, b) ((a).seg == (b).seg)
17861
17862 @@ -77,8 +83,33 @@
17863 * checks that the pointer is in the user space range - after calling
17864 * this function, memory access functions may still return -EFAULT.
17865 */
17866 -#define access_ok(type, addr, size) \
17867 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17868 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17869 +#define access_ok(type, addr, size) \
17870 +({ \
17871 + long __size = size; \
17872 + unsigned long __addr = (unsigned long)addr; \
17873 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17874 + unsigned long __end_ao = __addr + __size - 1; \
17875 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17876 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17877 + while(__addr_ao <= __end_ao) { \
17878 + char __c_ao; \
17879 + __addr_ao += PAGE_SIZE; \
17880 + if (__size > PAGE_SIZE) \
17881 + cond_resched(); \
17882 + if (__get_user(__c_ao, (char __user *)__addr)) \
17883 + break; \
17884 + if (type != VERIFY_WRITE) { \
17885 + __addr = __addr_ao; \
17886 + continue; \
17887 + } \
17888 + if (__put_user(__c_ao, (char __user *)__addr)) \
17889 + break; \
17890 + __addr = __addr_ao; \
17891 + } \
17892 + } \
17893 + __ret_ao; \
17894 +})
17895
17896 /*
17897 * The exception table consists of pairs of addresses relative to the
17898 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17899 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17900 __chk_user_ptr(ptr); \
17901 might_fault(); \
17902 + pax_open_userland(); \
17903 asm volatile("call __get_user_%P3" \
17904 : "=a" (__ret_gu), "=r" (__val_gu) \
17905 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17906 (x) = (__typeof__(*(ptr))) __val_gu; \
17907 + pax_close_userland(); \
17908 __ret_gu; \
17909 })
17910
17911 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17912 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17913 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17914
17915 -
17916 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17917 +#define __copyuser_seg "gs;"
17918 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17919 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17920 +#else
17921 +#define __copyuser_seg
17922 +#define __COPYUSER_SET_ES
17923 +#define __COPYUSER_RESTORE_ES
17924 +#endif
17925
17926 #ifdef CONFIG_X86_32
17927 #define __put_user_asm_u64(x, addr, err, errret) \
17928 asm volatile(ASM_STAC "\n" \
17929 - "1: movl %%eax,0(%2)\n" \
17930 - "2: movl %%edx,4(%2)\n" \
17931 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
17932 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
17933 "3: " ASM_CLAC "\n" \
17934 ".section .fixup,\"ax\"\n" \
17935 "4: movl %3,%0\n" \
17936 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17937
17938 #define __put_user_asm_ex_u64(x, addr) \
17939 asm volatile(ASM_STAC "\n" \
17940 - "1: movl %%eax,0(%1)\n" \
17941 - "2: movl %%edx,4(%1)\n" \
17942 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
17943 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
17944 "3: " ASM_CLAC "\n" \
17945 _ASM_EXTABLE_EX(1b, 2b) \
17946 _ASM_EXTABLE_EX(2b, 3b) \
17947 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
17948 __typeof__(*(ptr)) __pu_val; \
17949 __chk_user_ptr(ptr); \
17950 might_fault(); \
17951 - __pu_val = x; \
17952 + __pu_val = (x); \
17953 + pax_open_userland(); \
17954 switch (sizeof(*(ptr))) { \
17955 case 1: \
17956 __put_user_x(1, __pu_val, ptr, __ret_pu); \
17957 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
17958 __put_user_x(X, __pu_val, ptr, __ret_pu); \
17959 break; \
17960 } \
17961 + pax_close_userland(); \
17962 __ret_pu; \
17963 })
17964
17965 @@ -344,8 +387,10 @@ do { \
17966 } while (0)
17967
17968 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
17969 +do { \
17970 + pax_open_userland(); \
17971 asm volatile(ASM_STAC "\n" \
17972 - "1: mov"itype" %2,%"rtype"1\n" \
17973 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
17974 "2: " ASM_CLAC "\n" \
17975 ".section .fixup,\"ax\"\n" \
17976 "3: mov %3,%0\n" \
17977 @@ -353,8 +398,10 @@ do { \
17978 " jmp 2b\n" \
17979 ".previous\n" \
17980 _ASM_EXTABLE(1b, 3b) \
17981 - : "=r" (err), ltype(x) \
17982 - : "m" (__m(addr)), "i" (errret), "0" (err))
17983 + : "=r" (err), ltype (x) \
17984 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
17985 + pax_close_userland(); \
17986 +} while (0)
17987
17988 #define __get_user_size_ex(x, ptr, size) \
17989 do { \
17990 @@ -378,7 +425,7 @@ do { \
17991 } while (0)
17992
17993 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
17994 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
17995 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
17996 "2:\n" \
17997 _ASM_EXTABLE_EX(1b, 2b) \
17998 : ltype(x) : "m" (__m(addr)))
17999 @@ -395,13 +442,24 @@ do { \
18000 int __gu_err; \
18001 unsigned long __gu_val; \
18002 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18003 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18004 + (x) = (__typeof__(*(ptr)))__gu_val; \
18005 __gu_err; \
18006 })
18007
18008 /* FIXME: this hack is definitely wrong -AK */
18009 struct __large_struct { unsigned long buf[100]; };
18010 -#define __m(x) (*(struct __large_struct __user *)(x))
18011 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18012 +#define ____m(x) \
18013 +({ \
18014 + unsigned long ____x = (unsigned long)(x); \
18015 + if (____x < pax_user_shadow_base) \
18016 + ____x += pax_user_shadow_base; \
18017 + (typeof(x))____x; \
18018 +})
18019 +#else
18020 +#define ____m(x) (x)
18021 +#endif
18022 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18023
18024 /*
18025 * Tell gcc we read from memory instead of writing: this is because
18026 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18027 * aliasing issues.
18028 */
18029 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18030 +do { \
18031 + pax_open_userland(); \
18032 asm volatile(ASM_STAC "\n" \
18033 - "1: mov"itype" %"rtype"1,%2\n" \
18034 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18035 "2: " ASM_CLAC "\n" \
18036 ".section .fixup,\"ax\"\n" \
18037 "3: mov %3,%0\n" \
18038 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18039 ".previous\n" \
18040 _ASM_EXTABLE(1b, 3b) \
18041 : "=r"(err) \
18042 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18043 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18044 + pax_close_userland(); \
18045 +} while (0)
18046
18047 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18048 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18049 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18050 "2:\n" \
18051 _ASM_EXTABLE_EX(1b, 2b) \
18052 : : ltype(x), "m" (__m(addr)))
18053 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18054 */
18055 #define uaccess_try do { \
18056 current_thread_info()->uaccess_err = 0; \
18057 + pax_open_userland(); \
18058 stac(); \
18059 barrier();
18060
18061 #define uaccess_catch(err) \
18062 clac(); \
18063 + pax_close_userland(); \
18064 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18065 } while (0)
18066
18067 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18068 * On error, the variable @x is set to zero.
18069 */
18070
18071 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18072 +#define __get_user(x, ptr) get_user((x), (ptr))
18073 +#else
18074 #define __get_user(x, ptr) \
18075 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18076 +#endif
18077
18078 /**
18079 * __put_user: - Write a simple value into user space, with less checking.
18080 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18081 * Returns zero on success, or -EFAULT on error.
18082 */
18083
18084 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18085 +#define __put_user(x, ptr) put_user((x), (ptr))
18086 +#else
18087 #define __put_user(x, ptr) \
18088 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18089 +#endif
18090
18091 #define __get_user_unaligned __get_user
18092 #define __put_user_unaligned __put_user
18093 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18094 #define get_user_ex(x, ptr) do { \
18095 unsigned long __gue_val; \
18096 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18097 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18098 + (x) = (__typeof__(*(ptr)))__gue_val; \
18099 } while (0)
18100
18101 #define put_user_try uaccess_try
18102 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18103 extern __must_check long strlen_user(const char __user *str);
18104 extern __must_check long strnlen_user(const char __user *str, long n);
18105
18106 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18107 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18108 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18109 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18110
18111 /*
18112 * movsl can be slow when source and dest are not both 8-byte aligned
18113 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18114 index 7f760a9..04b1c65 100644
18115 --- a/arch/x86/include/asm/uaccess_32.h
18116 +++ b/arch/x86/include/asm/uaccess_32.h
18117 @@ -11,15 +11,15 @@
18118 #include <asm/page.h>
18119
18120 unsigned long __must_check __copy_to_user_ll
18121 - (void __user *to, const void *from, unsigned long n);
18122 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18123 unsigned long __must_check __copy_from_user_ll
18124 - (void *to, const void __user *from, unsigned long n);
18125 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18126 unsigned long __must_check __copy_from_user_ll_nozero
18127 - (void *to, const void __user *from, unsigned long n);
18128 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18129 unsigned long __must_check __copy_from_user_ll_nocache
18130 - (void *to, const void __user *from, unsigned long n);
18131 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18132 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18133 - (void *to, const void __user *from, unsigned long n);
18134 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18135
18136 /**
18137 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18138 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18139 static __always_inline unsigned long __must_check
18140 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18141 {
18142 + if ((long)n < 0)
18143 + return n;
18144 +
18145 + check_object_size(from, n, true);
18146 +
18147 if (__builtin_constant_p(n)) {
18148 unsigned long ret;
18149
18150 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18151 __copy_to_user(void __user *to, const void *from, unsigned long n)
18152 {
18153 might_fault();
18154 +
18155 return __copy_to_user_inatomic(to, from, n);
18156 }
18157
18158 static __always_inline unsigned long
18159 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18160 {
18161 + if ((long)n < 0)
18162 + return n;
18163 +
18164 /* Avoid zeroing the tail if the copy fails..
18165 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18166 * but as the zeroing behaviour is only significant when n is not
18167 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18168 __copy_from_user(void *to, const void __user *from, unsigned long n)
18169 {
18170 might_fault();
18171 +
18172 + if ((long)n < 0)
18173 + return n;
18174 +
18175 + check_object_size(to, n, false);
18176 +
18177 if (__builtin_constant_p(n)) {
18178 unsigned long ret;
18179
18180 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18181 const void __user *from, unsigned long n)
18182 {
18183 might_fault();
18184 +
18185 + if ((long)n < 0)
18186 + return n;
18187 +
18188 if (__builtin_constant_p(n)) {
18189 unsigned long ret;
18190
18191 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18192 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18193 unsigned long n)
18194 {
18195 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18196 + if ((long)n < 0)
18197 + return n;
18198 +
18199 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18200 }
18201
18202 -unsigned long __must_check copy_to_user(void __user *to,
18203 - const void *from, unsigned long n);
18204 -unsigned long __must_check _copy_from_user(void *to,
18205 - const void __user *from,
18206 - unsigned long n);
18207 -
18208 +extern void copy_to_user_overflow(void)
18209 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18210 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18211 +#else
18212 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18213 +#endif
18214 +;
18215
18216 extern void copy_from_user_overflow(void)
18217 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18218 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18219 #endif
18220 ;
18221
18222 -static inline unsigned long __must_check copy_from_user(void *to,
18223 - const void __user *from,
18224 - unsigned long n)
18225 +/**
18226 + * copy_to_user: - Copy a block of data into user space.
18227 + * @to: Destination address, in user space.
18228 + * @from: Source address, in kernel space.
18229 + * @n: Number of bytes to copy.
18230 + *
18231 + * Context: User context only. This function may sleep.
18232 + *
18233 + * Copy data from kernel space to user space.
18234 + *
18235 + * Returns number of bytes that could not be copied.
18236 + * On success, this will be zero.
18237 + */
18238 +static inline unsigned long __must_check
18239 +copy_to_user(void __user *to, const void *from, unsigned long n)
18240 {
18241 - int sz = __compiletime_object_size(to);
18242 + size_t sz = __compiletime_object_size(from);
18243
18244 - if (likely(sz == -1 || sz >= n))
18245 - n = _copy_from_user(to, from, n);
18246 - else
18247 + if (unlikely(sz != (size_t)-1 && sz < n))
18248 + copy_to_user_overflow();
18249 + else if (access_ok(VERIFY_WRITE, to, n))
18250 + n = __copy_to_user(to, from, n);
18251 + return n;
18252 +}
18253 +
18254 +/**
18255 + * copy_from_user: - Copy a block of data from user space.
18256 + * @to: Destination address, in kernel space.
18257 + * @from: Source address, in user space.
18258 + * @n: Number of bytes to copy.
18259 + *
18260 + * Context: User context only. This function may sleep.
18261 + *
18262 + * Copy data from user space to kernel space.
18263 + *
18264 + * Returns number of bytes that could not be copied.
18265 + * On success, this will be zero.
18266 + *
18267 + * If some data could not be copied, this function will pad the copied
18268 + * data to the requested size using zero bytes.
18269 + */
18270 +static inline unsigned long __must_check
18271 +copy_from_user(void *to, const void __user *from, unsigned long n)
18272 +{
18273 + size_t sz = __compiletime_object_size(to);
18274 +
18275 + check_object_size(to, n, false);
18276 +
18277 + if (unlikely(sz != (size_t)-1 && sz < n))
18278 copy_from_user_overflow();
18279 -
18280 + else if (access_ok(VERIFY_READ, from, n))
18281 + n = __copy_from_user(to, from, n);
18282 + else if ((long)n > 0)
18283 + memset(to, 0, n);
18284 return n;
18285 }
18286
18287 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18288 index 4f7923d..20cb24e 100644
18289 --- a/arch/x86/include/asm/uaccess_64.h
18290 +++ b/arch/x86/include/asm/uaccess_64.h
18291 @@ -10,6 +10,9 @@
18292 #include <asm/alternative.h>
18293 #include <asm/cpufeature.h>
18294 #include <asm/page.h>
18295 +#include <asm/pgtable.h>
18296 +
18297 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18298
18299 /*
18300 * Copy To/From Userspace
18301 @@ -17,13 +20,13 @@
18302
18303 /* Handles exceptions in both to and from, but doesn't do access_ok */
18304 __must_check unsigned long
18305 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18306 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18307 __must_check unsigned long
18308 -copy_user_generic_string(void *to, const void *from, unsigned len);
18309 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18310 __must_check unsigned long
18311 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18312 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18313
18314 -static __always_inline __must_check unsigned long
18315 +static __always_inline __must_check __size_overflow(3) unsigned long
18316 copy_user_generic(void *to, const void *from, unsigned len)
18317 {
18318 unsigned ret;
18319 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
18320 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
18321 "=d" (len)),
18322 "1" (to), "2" (from), "3" (len)
18323 - : "memory", "rcx", "r8", "r9", "r10", "r11");
18324 + : "memory", "rcx", "r8", "r9", "r11");
18325 return ret;
18326 }
18327
18328 +static __always_inline __must_check unsigned long
18329 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18330 +static __always_inline __must_check unsigned long
18331 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18332 __must_check unsigned long
18333 -_copy_to_user(void __user *to, const void *from, unsigned len);
18334 -__must_check unsigned long
18335 -_copy_from_user(void *to, const void __user *from, unsigned len);
18336 -__must_check unsigned long
18337 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18338 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18339 +
18340 +extern void copy_to_user_overflow(void)
18341 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18342 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18343 +#else
18344 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18345 +#endif
18346 +;
18347 +
18348 +extern void copy_from_user_overflow(void)
18349 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18350 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18351 +#else
18352 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18353 +#endif
18354 +;
18355
18356 static inline unsigned long __must_check copy_from_user(void *to,
18357 const void __user *from,
18358 unsigned long n)
18359 {
18360 - int sz = __compiletime_object_size(to);
18361 -
18362 might_fault();
18363 - if (likely(sz == -1 || sz >= n))
18364 - n = _copy_from_user(to, from, n);
18365 -#ifdef CONFIG_DEBUG_VM
18366 - else
18367 - WARN(1, "Buffer overflow detected!\n");
18368 -#endif
18369 +
18370 + check_object_size(to, n, false);
18371 +
18372 + if (access_ok(VERIFY_READ, from, n))
18373 + n = __copy_from_user(to, from, n);
18374 + else if (n < INT_MAX)
18375 + memset(to, 0, n);
18376 return n;
18377 }
18378
18379 static __always_inline __must_check
18380 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18381 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18382 {
18383 might_fault();
18384
18385 - return _copy_to_user(dst, src, size);
18386 + if (access_ok(VERIFY_WRITE, dst, size))
18387 + size = __copy_to_user(dst, src, size);
18388 + return size;
18389 }
18390
18391 static __always_inline __must_check
18392 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18393 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18394 {
18395 - int ret = 0;
18396 + size_t sz = __compiletime_object_size(dst);
18397 + unsigned ret = 0;
18398
18399 might_fault();
18400 +
18401 + if (size > INT_MAX)
18402 + return size;
18403 +
18404 + check_object_size(dst, size, false);
18405 +
18406 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18407 + if (!__access_ok(VERIFY_READ, src, size))
18408 + return size;
18409 +#endif
18410 +
18411 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18412 + copy_from_user_overflow();
18413 + return size;
18414 + }
18415 +
18416 if (!__builtin_constant_p(size))
18417 - return copy_user_generic(dst, (__force void *)src, size);
18418 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18419 switch (size) {
18420 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18421 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18422 ret, "b", "b", "=q", 1);
18423 return ret;
18424 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18425 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18426 ret, "w", "w", "=r", 2);
18427 return ret;
18428 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18429 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18430 ret, "l", "k", "=r", 4);
18431 return ret;
18432 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18433 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18434 ret, "q", "", "=r", 8);
18435 return ret;
18436 case 10:
18437 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18438 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18439 ret, "q", "", "=r", 10);
18440 if (unlikely(ret))
18441 return ret;
18442 __get_user_asm(*(u16 *)(8 + (char *)dst),
18443 - (u16 __user *)(8 + (char __user *)src),
18444 + (const u16 __user *)(8 + (const char __user *)src),
18445 ret, "w", "w", "=r", 2);
18446 return ret;
18447 case 16:
18448 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18449 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18450 ret, "q", "", "=r", 16);
18451 if (unlikely(ret))
18452 return ret;
18453 __get_user_asm(*(u64 *)(8 + (char *)dst),
18454 - (u64 __user *)(8 + (char __user *)src),
18455 + (const u64 __user *)(8 + (const char __user *)src),
18456 ret, "q", "", "=r", 8);
18457 return ret;
18458 default:
18459 - return copy_user_generic(dst, (__force void *)src, size);
18460 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18461 }
18462 }
18463
18464 static __always_inline __must_check
18465 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18466 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18467 {
18468 - int ret = 0;
18469 + size_t sz = __compiletime_object_size(src);
18470 + unsigned ret = 0;
18471
18472 might_fault();
18473 +
18474 + if (size > INT_MAX)
18475 + return size;
18476 +
18477 + check_object_size(src, size, true);
18478 +
18479 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18480 + if (!__access_ok(VERIFY_WRITE, dst, size))
18481 + return size;
18482 +#endif
18483 +
18484 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18485 + copy_to_user_overflow();
18486 + return size;
18487 + }
18488 +
18489 if (!__builtin_constant_p(size))
18490 - return copy_user_generic((__force void *)dst, src, size);
18491 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18492 switch (size) {
18493 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18494 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18495 ret, "b", "b", "iq", 1);
18496 return ret;
18497 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18498 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18499 ret, "w", "w", "ir", 2);
18500 return ret;
18501 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18502 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18503 ret, "l", "k", "ir", 4);
18504 return ret;
18505 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18506 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18507 ret, "q", "", "er", 8);
18508 return ret;
18509 case 10:
18510 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18511 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18512 ret, "q", "", "er", 10);
18513 if (unlikely(ret))
18514 return ret;
18515 asm("":::"memory");
18516 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18517 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18518 ret, "w", "w", "ir", 2);
18519 return ret;
18520 case 16:
18521 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18522 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18523 ret, "q", "", "er", 16);
18524 if (unlikely(ret))
18525 return ret;
18526 asm("":::"memory");
18527 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18528 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18529 ret, "q", "", "er", 8);
18530 return ret;
18531 default:
18532 - return copy_user_generic((__force void *)dst, src, size);
18533 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18534 }
18535 }
18536
18537 static __always_inline __must_check
18538 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18539 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18540 {
18541 - int ret = 0;
18542 + unsigned ret = 0;
18543
18544 might_fault();
18545 +
18546 + if (size > INT_MAX)
18547 + return size;
18548 +
18549 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18550 + if (!__access_ok(VERIFY_READ, src, size))
18551 + return size;
18552 + if (!__access_ok(VERIFY_WRITE, dst, size))
18553 + return size;
18554 +#endif
18555 +
18556 if (!__builtin_constant_p(size))
18557 - return copy_user_generic((__force void *)dst,
18558 - (__force void *)src, size);
18559 + return copy_user_generic((__force_kernel void *)____m(dst),
18560 + (__force_kernel const void *)____m(src), size);
18561 switch (size) {
18562 case 1: {
18563 u8 tmp;
18564 - __get_user_asm(tmp, (u8 __user *)src,
18565 + __get_user_asm(tmp, (const u8 __user *)src,
18566 ret, "b", "b", "=q", 1);
18567 if (likely(!ret))
18568 __put_user_asm(tmp, (u8 __user *)dst,
18569 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18570 }
18571 case 2: {
18572 u16 tmp;
18573 - __get_user_asm(tmp, (u16 __user *)src,
18574 + __get_user_asm(tmp, (const u16 __user *)src,
18575 ret, "w", "w", "=r", 2);
18576 if (likely(!ret))
18577 __put_user_asm(tmp, (u16 __user *)dst,
18578 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18579
18580 case 4: {
18581 u32 tmp;
18582 - __get_user_asm(tmp, (u32 __user *)src,
18583 + __get_user_asm(tmp, (const u32 __user *)src,
18584 ret, "l", "k", "=r", 4);
18585 if (likely(!ret))
18586 __put_user_asm(tmp, (u32 __user *)dst,
18587 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18588 }
18589 case 8: {
18590 u64 tmp;
18591 - __get_user_asm(tmp, (u64 __user *)src,
18592 + __get_user_asm(tmp, (const u64 __user *)src,
18593 ret, "q", "", "=r", 8);
18594 if (likely(!ret))
18595 __put_user_asm(tmp, (u64 __user *)dst,
18596 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18597 return ret;
18598 }
18599 default:
18600 - return copy_user_generic((__force void *)dst,
18601 - (__force void *)src, size);
18602 + return copy_user_generic((__force_kernel void *)____m(dst),
18603 + (__force_kernel const void *)____m(src), size);
18604 }
18605 }
18606
18607 -static __must_check __always_inline int
18608 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18609 +static __must_check __always_inline unsigned long
18610 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18611 {
18612 - return copy_user_generic(dst, (__force const void *)src, size);
18613 + if (size > INT_MAX)
18614 + return size;
18615 +
18616 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18617 + if (!__access_ok(VERIFY_READ, src, size))
18618 + return size;
18619 +#endif
18620 +
18621 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18622 }
18623
18624 -static __must_check __always_inline int
18625 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18626 +static __must_check __always_inline unsigned long
18627 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18628 {
18629 - return copy_user_generic((__force void *)dst, src, size);
18630 + if (size > INT_MAX)
18631 + return size;
18632 +
18633 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18634 + if (!__access_ok(VERIFY_WRITE, dst, size))
18635 + return size;
18636 +#endif
18637 +
18638 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18639 }
18640
18641 -extern long __copy_user_nocache(void *dst, const void __user *src,
18642 - unsigned size, int zerorest);
18643 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18644 + unsigned long size, int zerorest) __size_overflow(3);
18645
18646 -static inline int
18647 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18648 +static inline unsigned long
18649 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18650 {
18651 might_fault();
18652 +
18653 + if (size > INT_MAX)
18654 + return size;
18655 +
18656 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18657 + if (!__access_ok(VERIFY_READ, src, size))
18658 + return size;
18659 +#endif
18660 +
18661 return __copy_user_nocache(dst, src, size, 1);
18662 }
18663
18664 -static inline int
18665 +static inline unsigned long
18666 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18667 - unsigned size)
18668 + unsigned long size)
18669 {
18670 + if (size > INT_MAX)
18671 + return size;
18672 +
18673 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18674 + if (!__access_ok(VERIFY_READ, src, size))
18675 + return size;
18676 +#endif
18677 +
18678 return __copy_user_nocache(dst, src, size, 0);
18679 }
18680
18681 unsigned long
18682 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18683 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18684
18685 #endif /* _ASM_X86_UACCESS_64_H */
18686 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18687 index 5b238981..77fdd78 100644
18688 --- a/arch/x86/include/asm/word-at-a-time.h
18689 +++ b/arch/x86/include/asm/word-at-a-time.h
18690 @@ -11,7 +11,7 @@
18691 * and shift, for example.
18692 */
18693 struct word_at_a_time {
18694 - const unsigned long one_bits, high_bits;
18695 + unsigned long one_bits, high_bits;
18696 };
18697
18698 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18699 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18700 index 828a156..650e625 100644
18701 --- a/arch/x86/include/asm/x86_init.h
18702 +++ b/arch/x86/include/asm/x86_init.h
18703 @@ -129,7 +129,7 @@ struct x86_init_ops {
18704 struct x86_init_timers timers;
18705 struct x86_init_iommu iommu;
18706 struct x86_init_pci pci;
18707 -};
18708 +} __no_const;
18709
18710 /**
18711 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18712 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18713 void (*setup_percpu_clockev)(void);
18714 void (*early_percpu_clock_init)(void);
18715 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18716 -};
18717 +} __no_const;
18718
18719 struct timespec;
18720
18721 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18722 void (*save_sched_clock_state)(void);
18723 void (*restore_sched_clock_state)(void);
18724 void (*apic_post_init)(void);
18725 -};
18726 +} __no_const;
18727
18728 struct pci_dev;
18729 struct msi_msg;
18730 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18731 void (*teardown_msi_irqs)(struct pci_dev *dev);
18732 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18733 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18734 -};
18735 +} __no_const;
18736
18737 struct IO_APIC_route_entry;
18738 struct io_apic_irq_attr;
18739 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18740 unsigned int destination, int vector,
18741 struct io_apic_irq_attr *attr);
18742 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18743 -};
18744 +} __no_const;
18745
18746 extern struct x86_init_ops x86_init;
18747 extern struct x86_cpuinit_ops x86_cpuinit;
18748 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18749 index 0415cda..3b22adc 100644
18750 --- a/arch/x86/include/asm/xsave.h
18751 +++ b/arch/x86/include/asm/xsave.h
18752 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18753 if (unlikely(err))
18754 return -EFAULT;
18755
18756 + pax_open_userland();
18757 __asm__ __volatile__(ASM_STAC "\n"
18758 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18759 + "1:"
18760 + __copyuser_seg
18761 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18762 "2: " ASM_CLAC "\n"
18763 ".section .fixup,\"ax\"\n"
18764 "3: movl $-1,%[err]\n"
18765 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18766 : [err] "=r" (err)
18767 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18768 : "memory");
18769 + pax_close_userland();
18770 return err;
18771 }
18772
18773 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18774 {
18775 int err;
18776 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18777 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18778 u32 lmask = mask;
18779 u32 hmask = mask >> 32;
18780
18781 + pax_open_userland();
18782 __asm__ __volatile__(ASM_STAC "\n"
18783 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18784 + "1:"
18785 + __copyuser_seg
18786 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18787 "2: " ASM_CLAC "\n"
18788 ".section .fixup,\"ax\"\n"
18789 "3: movl $-1,%[err]\n"
18790 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18791 : [err] "=r" (err)
18792 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18793 : "memory"); /* memory required? */
18794 + pax_close_userland();
18795 return err;
18796 }
18797
18798 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18799 index bbae024..e1528f9 100644
18800 --- a/arch/x86/include/uapi/asm/e820.h
18801 +++ b/arch/x86/include/uapi/asm/e820.h
18802 @@ -63,7 +63,7 @@ struct e820map {
18803 #define ISA_START_ADDRESS 0xa0000
18804 #define ISA_END_ADDRESS 0x100000
18805
18806 -#define BIOS_BEGIN 0x000a0000
18807 +#define BIOS_BEGIN 0x000c0000
18808 #define BIOS_END 0x00100000
18809
18810 #define BIOS_ROM_BASE 0xffe00000
18811 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18812 index 88d99ea..9fc7e17 100644
18813 --- a/arch/x86/kernel/Makefile
18814 +++ b/arch/x86/kernel/Makefile
18815 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18816 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18817 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18818 obj-y += probe_roms.o
18819 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18820 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18821 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18822 obj-y += syscall_$(BITS).o
18823 obj-$(CONFIG_X86_64) += vsyscall_64.o
18824 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18825 index 2627a81..cd8325e 100644
18826 --- a/arch/x86/kernel/acpi/boot.c
18827 +++ b/arch/x86/kernel/acpi/boot.c
18828 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18829 * If your system is blacklisted here, but you find that acpi=force
18830 * works for you, please contact linux-acpi@vger.kernel.org
18831 */
18832 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18833 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18834 /*
18835 * Boxes that need ACPI disabled
18836 */
18837 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18838 };
18839
18840 /* second table for DMI checks that should run after early-quirks */
18841 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18842 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18843 /*
18844 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18845 * which includes some code which overrides all temperature
18846 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18847 index 3312010..a65ca7b 100644
18848 --- a/arch/x86/kernel/acpi/sleep.c
18849 +++ b/arch/x86/kernel/acpi/sleep.c
18850 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18851 #else /* CONFIG_64BIT */
18852 #ifdef CONFIG_SMP
18853 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18854 +
18855 + pax_open_kernel();
18856 early_gdt_descr.address =
18857 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18858 + pax_close_kernel();
18859 +
18860 initial_gs = per_cpu_offset(smp_processor_id());
18861 #endif
18862 initial_code = (unsigned long)wakeup_long64;
18863 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18864 index d1daa66..59fecba 100644
18865 --- a/arch/x86/kernel/acpi/wakeup_32.S
18866 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18867 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18868 # and restore the stack ... but you need gdt for this to work
18869 movl saved_context_esp, %esp
18870
18871 - movl %cs:saved_magic, %eax
18872 - cmpl $0x12345678, %eax
18873 + cmpl $0x12345678, saved_magic
18874 jne bogus_magic
18875
18876 # jump to place where we left off
18877 - movl saved_eip, %eax
18878 - jmp *%eax
18879 + jmp *(saved_eip)
18880
18881 bogus_magic:
18882 jmp bogus_magic
18883 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18884 index c15cf9a..0e63558 100644
18885 --- a/arch/x86/kernel/alternative.c
18886 +++ b/arch/x86/kernel/alternative.c
18887 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18888 */
18889 for (a = start; a < end; a++) {
18890 instr = (u8 *)&a->instr_offset + a->instr_offset;
18891 +
18892 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18893 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18894 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18895 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18896 +#endif
18897 +
18898 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18899 BUG_ON(a->replacementlen > a->instrlen);
18900 BUG_ON(a->instrlen > sizeof(insnbuf));
18901 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18902 for (poff = start; poff < end; poff++) {
18903 u8 *ptr = (u8 *)poff + *poff;
18904
18905 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18906 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18907 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18908 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18909 +#endif
18910 +
18911 if (!*poff || ptr < text || ptr >= text_end)
18912 continue;
18913 /* turn DS segment override prefix into lock prefix */
18914 - if (*ptr == 0x3e)
18915 + if (*ktla_ktva(ptr) == 0x3e)
18916 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18917 }
18918 mutex_unlock(&text_mutex);
18919 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18920 for (poff = start; poff < end; poff++) {
18921 u8 *ptr = (u8 *)poff + *poff;
18922
18923 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18924 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18925 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18926 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18927 +#endif
18928 +
18929 if (!*poff || ptr < text || ptr >= text_end)
18930 continue;
18931 /* turn lock prefix into DS segment override prefix */
18932 - if (*ptr == 0xf0)
18933 + if (*ktla_ktva(ptr) == 0xf0)
18934 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18935 }
18936 mutex_unlock(&text_mutex);
18937 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18938
18939 BUG_ON(p->len > MAX_PATCH_LEN);
18940 /* prep the buffer with the original instructions */
18941 - memcpy(insnbuf, p->instr, p->len);
18942 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
18943 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
18944 (unsigned long)p->instr, p->len);
18945
18946 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
18947 if (!uniproc_patched || num_possible_cpus() == 1)
18948 free_init_pages("SMP alternatives",
18949 (unsigned long)__smp_locks,
18950 - (unsigned long)__smp_locks_end);
18951 + PAGE_ALIGN((unsigned long)__smp_locks_end));
18952 #endif
18953
18954 apply_paravirt(__parainstructions, __parainstructions_end);
18955 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
18956 * instructions. And on the local CPU you need to be protected again NMI or MCE
18957 * handlers seeing an inconsistent instruction while you patch.
18958 */
18959 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
18960 +void *__kprobes text_poke_early(void *addr, const void *opcode,
18961 size_t len)
18962 {
18963 unsigned long flags;
18964 local_irq_save(flags);
18965 - memcpy(addr, opcode, len);
18966 +
18967 + pax_open_kernel();
18968 + memcpy(ktla_ktva(addr), opcode, len);
18969 sync_core();
18970 + pax_close_kernel();
18971 +
18972 local_irq_restore(flags);
18973 /* Could also do a CLFLUSH here to speed up CPU recovery; but
18974 that causes hangs on some VIA CPUs. */
18975 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
18976 */
18977 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
18978 {
18979 - unsigned long flags;
18980 - char *vaddr;
18981 + unsigned char *vaddr = ktla_ktva(addr);
18982 struct page *pages[2];
18983 - int i;
18984 + size_t i;
18985
18986 if (!core_kernel_text((unsigned long)addr)) {
18987 - pages[0] = vmalloc_to_page(addr);
18988 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
18989 + pages[0] = vmalloc_to_page(vaddr);
18990 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
18991 } else {
18992 - pages[0] = virt_to_page(addr);
18993 + pages[0] = virt_to_page(vaddr);
18994 WARN_ON(!PageReserved(pages[0]));
18995 - pages[1] = virt_to_page(addr + PAGE_SIZE);
18996 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
18997 }
18998 BUG_ON(!pages[0]);
18999 - local_irq_save(flags);
19000 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19001 - if (pages[1])
19002 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19003 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19004 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19005 - clear_fixmap(FIX_TEXT_POKE0);
19006 - if (pages[1])
19007 - clear_fixmap(FIX_TEXT_POKE1);
19008 - local_flush_tlb();
19009 - sync_core();
19010 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19011 - that causes hangs on some VIA CPUs. */
19012 + text_poke_early(addr, opcode, len);
19013 for (i = 0; i < len; i++)
19014 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19015 - local_irq_restore(flags);
19016 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19017 return addr;
19018 }
19019
19020 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19021 index eca89c5..d566b78 100644
19022 --- a/arch/x86/kernel/apic/apic.c
19023 +++ b/arch/x86/kernel/apic/apic.c
19024 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19025 /*
19026 * Debug level, exported for io_apic.c
19027 */
19028 -unsigned int apic_verbosity;
19029 +int apic_verbosity;
19030
19031 int pic_mode;
19032
19033 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19034 apic_write(APIC_ESR, 0);
19035 v1 = apic_read(APIC_ESR);
19036 ack_APIC_irq();
19037 - atomic_inc(&irq_err_count);
19038 + atomic_inc_unchecked(&irq_err_count);
19039
19040 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19041 smp_processor_id(), v0 , v1);
19042 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19043 index 00c77cf..2dc6a2d 100644
19044 --- a/arch/x86/kernel/apic/apic_flat_64.c
19045 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19046 @@ -157,7 +157,7 @@ static int flat_probe(void)
19047 return 1;
19048 }
19049
19050 -static struct apic apic_flat = {
19051 +static struct apic apic_flat __read_only = {
19052 .name = "flat",
19053 .probe = flat_probe,
19054 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19055 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19056 return 0;
19057 }
19058
19059 -static struct apic apic_physflat = {
19060 +static struct apic apic_physflat __read_only = {
19061
19062 .name = "physical flat",
19063 .probe = physflat_probe,
19064 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19065 index e145f28..2752888 100644
19066 --- a/arch/x86/kernel/apic/apic_noop.c
19067 +++ b/arch/x86/kernel/apic/apic_noop.c
19068 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19069 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19070 }
19071
19072 -struct apic apic_noop = {
19073 +struct apic apic_noop __read_only = {
19074 .name = "noop",
19075 .probe = noop_probe,
19076 .acpi_madt_oem_check = NULL,
19077 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19078 index d50e364..543bee3 100644
19079 --- a/arch/x86/kernel/apic/bigsmp_32.c
19080 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19081 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19082 return dmi_bigsmp;
19083 }
19084
19085 -static struct apic apic_bigsmp = {
19086 +static struct apic apic_bigsmp __read_only = {
19087
19088 .name = "bigsmp",
19089 .probe = probe_bigsmp,
19090 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19091 index c552247..587a316 100644
19092 --- a/arch/x86/kernel/apic/es7000_32.c
19093 +++ b/arch/x86/kernel/apic/es7000_32.c
19094 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19095 return ret && es7000_apic_is_cluster();
19096 }
19097
19098 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19099 -static struct apic __refdata apic_es7000_cluster = {
19100 +static struct apic apic_es7000_cluster __read_only = {
19101
19102 .name = "es7000",
19103 .probe = probe_es7000,
19104 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19105 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19106 };
19107
19108 -static struct apic __refdata apic_es7000 = {
19109 +static struct apic apic_es7000 __read_only = {
19110
19111 .name = "es7000",
19112 .probe = probe_es7000,
19113 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19114 index 9ed796c..e930fe4 100644
19115 --- a/arch/x86/kernel/apic/io_apic.c
19116 +++ b/arch/x86/kernel/apic/io_apic.c
19117 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19118 }
19119 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19120
19121 -void lock_vector_lock(void)
19122 +void lock_vector_lock(void) __acquires(vector_lock)
19123 {
19124 /* Used to the online set of cpus does not change
19125 * during assign_irq_vector.
19126 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19127 raw_spin_lock(&vector_lock);
19128 }
19129
19130 -void unlock_vector_lock(void)
19131 +void unlock_vector_lock(void) __releases(vector_lock)
19132 {
19133 raw_spin_unlock(&vector_lock);
19134 }
19135 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19136 ack_APIC_irq();
19137 }
19138
19139 -atomic_t irq_mis_count;
19140 +atomic_unchecked_t irq_mis_count;
19141
19142 #ifdef CONFIG_GENERIC_PENDING_IRQ
19143 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19144 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19145 * at the cpu.
19146 */
19147 if (!(v & (1 << (i & 0x1f)))) {
19148 - atomic_inc(&irq_mis_count);
19149 + atomic_inc_unchecked(&irq_mis_count);
19150
19151 eoi_ioapic_irq(irq, cfg);
19152 }
19153 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19154 index 1e42e8f..daacf44 100644
19155 --- a/arch/x86/kernel/apic/numaq_32.c
19156 +++ b/arch/x86/kernel/apic/numaq_32.c
19157 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19158 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19159 }
19160
19161 -/* Use __refdata to keep false positive warning calm. */
19162 -static struct apic __refdata apic_numaq = {
19163 +static struct apic apic_numaq __read_only = {
19164
19165 .name = "NUMAQ",
19166 .probe = probe_numaq,
19167 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19168 index eb35ef9..f184a21 100644
19169 --- a/arch/x86/kernel/apic/probe_32.c
19170 +++ b/arch/x86/kernel/apic/probe_32.c
19171 @@ -72,7 +72,7 @@ static int probe_default(void)
19172 return 1;
19173 }
19174
19175 -static struct apic apic_default = {
19176 +static struct apic apic_default __read_only = {
19177
19178 .name = "default",
19179 .probe = probe_default,
19180 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19181 index 77c95c0..434f8a4 100644
19182 --- a/arch/x86/kernel/apic/summit_32.c
19183 +++ b/arch/x86/kernel/apic/summit_32.c
19184 @@ -486,7 +486,7 @@ void setup_summit(void)
19185 }
19186 #endif
19187
19188 -static struct apic apic_summit = {
19189 +static struct apic apic_summit __read_only = {
19190
19191 .name = "summit",
19192 .probe = probe_summit,
19193 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19194 index 140e29d..d88bc95 100644
19195 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19196 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19197 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19198 return notifier_from_errno(err);
19199 }
19200
19201 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19202 +static struct notifier_block x2apic_cpu_notifier = {
19203 .notifier_call = update_clusterinfo,
19204 };
19205
19206 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19207 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19208 }
19209
19210 -static struct apic apic_x2apic_cluster = {
19211 +static struct apic apic_x2apic_cluster __read_only = {
19212
19213 .name = "cluster x2apic",
19214 .probe = x2apic_cluster_probe,
19215 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19216 index 562a76d..a003c0f 100644
19217 --- a/arch/x86/kernel/apic/x2apic_phys.c
19218 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19219 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19220 return apic == &apic_x2apic_phys;
19221 }
19222
19223 -static struct apic apic_x2apic_phys = {
19224 +static struct apic apic_x2apic_phys __read_only = {
19225
19226 .name = "physical x2apic",
19227 .probe = x2apic_phys_probe,
19228 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19229 index 1191ac1..2335fa4 100644
19230 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19231 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19232 @@ -357,7 +357,7 @@ static int uv_probe(void)
19233 return apic == &apic_x2apic_uv_x;
19234 }
19235
19236 -static struct apic __refdata apic_x2apic_uv_x = {
19237 +static struct apic apic_x2apic_uv_x __read_only = {
19238
19239 .name = "UV large system",
19240 .probe = uv_probe,
19241 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19242 index 53a4e27..038760a 100644
19243 --- a/arch/x86/kernel/apm_32.c
19244 +++ b/arch/x86/kernel/apm_32.c
19245 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19246 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19247 * even though they are called in protected mode.
19248 */
19249 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19250 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19251 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19252
19253 static const char driver_version[] = "1.16ac"; /* no spaces */
19254 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19255 BUG_ON(cpu != 0);
19256 gdt = get_cpu_gdt_table(cpu);
19257 save_desc_40 = gdt[0x40 / 8];
19258 +
19259 + pax_open_kernel();
19260 gdt[0x40 / 8] = bad_bios_desc;
19261 + pax_close_kernel();
19262
19263 apm_irq_save(flags);
19264 APM_DO_SAVE_SEGS;
19265 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19266 &call->esi);
19267 APM_DO_RESTORE_SEGS;
19268 apm_irq_restore(flags);
19269 +
19270 + pax_open_kernel();
19271 gdt[0x40 / 8] = save_desc_40;
19272 + pax_close_kernel();
19273 +
19274 put_cpu();
19275
19276 return call->eax & 0xff;
19277 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19278 BUG_ON(cpu != 0);
19279 gdt = get_cpu_gdt_table(cpu);
19280 save_desc_40 = gdt[0x40 / 8];
19281 +
19282 + pax_open_kernel();
19283 gdt[0x40 / 8] = bad_bios_desc;
19284 + pax_close_kernel();
19285
19286 apm_irq_save(flags);
19287 APM_DO_SAVE_SEGS;
19288 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19289 &call->eax);
19290 APM_DO_RESTORE_SEGS;
19291 apm_irq_restore(flags);
19292 +
19293 + pax_open_kernel();
19294 gdt[0x40 / 8] = save_desc_40;
19295 + pax_close_kernel();
19296 +
19297 put_cpu();
19298 return error;
19299 }
19300 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19301 * code to that CPU.
19302 */
19303 gdt = get_cpu_gdt_table(0);
19304 +
19305 + pax_open_kernel();
19306 set_desc_base(&gdt[APM_CS >> 3],
19307 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19308 set_desc_base(&gdt[APM_CS_16 >> 3],
19309 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19310 set_desc_base(&gdt[APM_DS >> 3],
19311 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19312 + pax_close_kernel();
19313
19314 proc_create("apm", 0, NULL, &apm_file_ops);
19315
19316 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19317 index 2861082..6d4718e 100644
19318 --- a/arch/x86/kernel/asm-offsets.c
19319 +++ b/arch/x86/kernel/asm-offsets.c
19320 @@ -33,6 +33,8 @@ void common(void) {
19321 OFFSET(TI_status, thread_info, status);
19322 OFFSET(TI_addr_limit, thread_info, addr_limit);
19323 OFFSET(TI_preempt_count, thread_info, preempt_count);
19324 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19325 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19326
19327 BLANK();
19328 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19329 @@ -53,8 +55,26 @@ void common(void) {
19330 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19331 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19332 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19333 +
19334 +#ifdef CONFIG_PAX_KERNEXEC
19335 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19336 #endif
19337
19338 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19339 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19340 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19341 +#ifdef CONFIG_X86_64
19342 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19343 +#endif
19344 +#endif
19345 +
19346 +#endif
19347 +
19348 + BLANK();
19349 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19350 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19351 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19352 +
19353 #ifdef CONFIG_XEN
19354 BLANK();
19355 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19356 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19357 index e7c798b..2b2019b 100644
19358 --- a/arch/x86/kernel/asm-offsets_64.c
19359 +++ b/arch/x86/kernel/asm-offsets_64.c
19360 @@ -77,6 +77,7 @@ int main(void)
19361 BLANK();
19362 #undef ENTRY
19363
19364 + DEFINE(TSS_size, sizeof(struct tss_struct));
19365 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19366 BLANK();
19367
19368 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19369 index 47b56a7..efc2bc6 100644
19370 --- a/arch/x86/kernel/cpu/Makefile
19371 +++ b/arch/x86/kernel/cpu/Makefile
19372 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19373 CFLAGS_REMOVE_perf_event.o = -pg
19374 endif
19375
19376 -# Make sure load_percpu_segment has no stackprotector
19377 -nostackp := $(call cc-option, -fno-stack-protector)
19378 -CFLAGS_common.o := $(nostackp)
19379 -
19380 obj-y := intel_cacheinfo.o scattered.o topology.o
19381 obj-y += proc.o capflags.o powerflags.o common.o
19382 obj-y += rdrand.o
19383 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19384 index 08a0890..e557865 100644
19385 --- a/arch/x86/kernel/cpu/amd.c
19386 +++ b/arch/x86/kernel/cpu/amd.c
19387 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19388 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19389 {
19390 /* AMD errata T13 (order #21922) */
19391 - if ((c->x86 == 6)) {
19392 + if (c->x86 == 6) {
19393 /* Duron Rev A0 */
19394 if (c->x86_model == 3 && c->x86_mask == 0)
19395 size = 64;
19396 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19397 index 25eb274..3a92d93 100644
19398 --- a/arch/x86/kernel/cpu/common.c
19399 +++ b/arch/x86/kernel/cpu/common.c
19400 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19401
19402 static const struct cpu_dev *this_cpu = &default_cpu;
19403
19404 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19405 -#ifdef CONFIG_X86_64
19406 - /*
19407 - * We need valid kernel segments for data and code in long mode too
19408 - * IRET will check the segment types kkeil 2000/10/28
19409 - * Also sysret mandates a special GDT layout
19410 - *
19411 - * TLS descriptors are currently at a different place compared to i386.
19412 - * Hopefully nobody expects them at a fixed place (Wine?)
19413 - */
19414 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19415 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19416 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19417 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19418 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19419 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19420 -#else
19421 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19422 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19423 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19424 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19425 - /*
19426 - * Segments used for calling PnP BIOS have byte granularity.
19427 - * They code segments and data segments have fixed 64k limits,
19428 - * the transfer segment sizes are set at run time.
19429 - */
19430 - /* 32-bit code */
19431 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19432 - /* 16-bit code */
19433 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19434 - /* 16-bit data */
19435 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19436 - /* 16-bit data */
19437 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19438 - /* 16-bit data */
19439 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19440 - /*
19441 - * The APM segments have byte granularity and their bases
19442 - * are set at run time. All have 64k limits.
19443 - */
19444 - /* 32-bit code */
19445 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19446 - /* 16-bit code */
19447 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19448 - /* data */
19449 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19450 -
19451 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19452 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19453 - GDT_STACK_CANARY_INIT
19454 -#endif
19455 -} };
19456 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19457 -
19458 static int __init x86_xsave_setup(char *s)
19459 {
19460 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19461 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19462 set_in_cr4(X86_CR4_SMAP);
19463 }
19464
19465 +#ifdef CONFIG_X86_64
19466 +static __init int setup_disable_pcid(char *arg)
19467 +{
19468 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19469 +
19470 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19471 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19472 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19473 +#endif
19474 +
19475 + return 1;
19476 +}
19477 +__setup("nopcid", setup_disable_pcid);
19478 +
19479 +static void setup_pcid(struct cpuinfo_x86 *c)
19480 +{
19481 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19482 +
19483 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19484 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19485 + pax_open_kernel();
19486 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19487 + pax_close_kernel();
19488 + printk("PAX: slow and weak UDEREF enabled\n");
19489 + } else
19490 + printk("PAX: UDEREF disabled\n");
19491 +#endif
19492 +
19493 + return;
19494 + }
19495 +
19496 + printk("PAX: PCID detected\n");
19497 + set_in_cr4(X86_CR4_PCIDE);
19498 +
19499 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19500 + pax_open_kernel();
19501 + clone_pgd_mask = ~(pgdval_t)0UL;
19502 + pax_close_kernel();
19503 + if (pax_user_shadow_base)
19504 + printk("PAX: weak UDEREF enabled\n");
19505 + else {
19506 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19507 + printk("PAX: strong UDEREF enabled\n");
19508 + }
19509 +#endif
19510 +
19511 + if (cpu_has(c, X86_FEATURE_INVPCID))
19512 + printk("PAX: INVPCID detected\n");
19513 +}
19514 +#endif
19515 +
19516 /*
19517 * Some CPU features depend on higher CPUID levels, which may not always
19518 * be available due to CPUID level capping or broken virtualization
19519 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19520 {
19521 struct desc_ptr gdt_descr;
19522
19523 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19524 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19525 gdt_descr.size = GDT_SIZE - 1;
19526 load_gdt(&gdt_descr);
19527 /* Reload the per-cpu base */
19528 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19529 setup_smep(c);
19530 setup_smap(c);
19531
19532 +#ifdef CONFIG_X86_64
19533 + setup_pcid(c);
19534 +#endif
19535 +
19536 /*
19537 * The vendor-specific functions might have changed features.
19538 * Now we do "generic changes."
19539 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19540 /* Filter out anything that depends on CPUID levels we don't have */
19541 filter_cpuid_features(c, true);
19542
19543 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19544 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19545 +#endif
19546 +
19547 /* If the model name is still unset, do table lookup. */
19548 if (!c->x86_model_id[0]) {
19549 const char *p;
19550 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19551 }
19552 __setup("clearcpuid=", setup_disablecpuid);
19553
19554 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19555 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19556 +
19557 #ifdef CONFIG_X86_64
19558 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19559 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19560 - (unsigned long) debug_idt_table };
19561 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19562 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19563
19564 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19565 irq_stack_union) __aligned(PAGE_SIZE);
19566 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19567 EXPORT_PER_CPU_SYMBOL(current_task);
19568
19569 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19570 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19571 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19572 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19573
19574 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19575 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19576 load_ucode_ap();
19577
19578 cpu = stack_smp_processor_id();
19579 - t = &per_cpu(init_tss, cpu);
19580 + t = init_tss + cpu;
19581 oist = &per_cpu(orig_ist, cpu);
19582
19583 #ifdef CONFIG_NUMA
19584 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19585 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19586 barrier();
19587
19588 - x86_configure_nx();
19589 enable_x2apic();
19590
19591 /*
19592 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19593 {
19594 int cpu = smp_processor_id();
19595 struct task_struct *curr = current;
19596 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19597 + struct tss_struct *t = init_tss + cpu;
19598 struct thread_struct *thread = &curr->thread;
19599
19600 show_ucode_info_early();
19601 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19602 index 1414c90..1159406 100644
19603 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19604 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19605 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19606 };
19607
19608 #ifdef CONFIG_AMD_NB
19609 +static struct attribute *default_attrs_amd_nb[] = {
19610 + &type.attr,
19611 + &level.attr,
19612 + &coherency_line_size.attr,
19613 + &physical_line_partition.attr,
19614 + &ways_of_associativity.attr,
19615 + &number_of_sets.attr,
19616 + &size.attr,
19617 + &shared_cpu_map.attr,
19618 + &shared_cpu_list.attr,
19619 + NULL,
19620 + NULL,
19621 + NULL,
19622 + NULL
19623 +};
19624 +
19625 static struct attribute **amd_l3_attrs(void)
19626 {
19627 static struct attribute **attrs;
19628 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19629
19630 n = ARRAY_SIZE(default_attrs);
19631
19632 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19633 - n += 2;
19634 -
19635 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19636 - n += 1;
19637 -
19638 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19639 - if (attrs == NULL)
19640 - return attrs = default_attrs;
19641 -
19642 - for (n = 0; default_attrs[n]; n++)
19643 - attrs[n] = default_attrs[n];
19644 + attrs = default_attrs_amd_nb;
19645
19646 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19647 attrs[n++] = &cache_disable_0.attr;
19648 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19649 .default_attrs = default_attrs,
19650 };
19651
19652 +#ifdef CONFIG_AMD_NB
19653 +static struct kobj_type ktype_cache_amd_nb = {
19654 + .sysfs_ops = &sysfs_ops,
19655 + .default_attrs = default_attrs_amd_nb,
19656 +};
19657 +#endif
19658 +
19659 static struct kobj_type ktype_percpu_entry = {
19660 .sysfs_ops = &sysfs_ops,
19661 };
19662 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19663 return retval;
19664 }
19665
19666 +#ifdef CONFIG_AMD_NB
19667 + amd_l3_attrs();
19668 +#endif
19669 +
19670 for (i = 0; i < num_cache_leaves; i++) {
19671 + struct kobj_type *ktype;
19672 +
19673 this_object = INDEX_KOBJECT_PTR(cpu, i);
19674 this_object->cpu = cpu;
19675 this_object->index = i;
19676
19677 this_leaf = CPUID4_INFO_IDX(cpu, i);
19678
19679 - ktype_cache.default_attrs = default_attrs;
19680 + ktype = &ktype_cache;
19681 #ifdef CONFIG_AMD_NB
19682 if (this_leaf->base.nb)
19683 - ktype_cache.default_attrs = amd_l3_attrs();
19684 + ktype = &ktype_cache_amd_nb;
19685 #endif
19686 retval = kobject_init_and_add(&(this_object->kobj),
19687 - &ktype_cache,
19688 + ktype,
19689 per_cpu(ici_cache_kobject, cpu),
19690 "index%1lu", i);
19691 if (unlikely(retval)) {
19692 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19693 index 87a65c9..92fcce6 100644
19694 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19695 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19696 @@ -45,6 +45,7 @@
19697 #include <asm/processor.h>
19698 #include <asm/mce.h>
19699 #include <asm/msr.h>
19700 +#include <asm/local.h>
19701
19702 #include "mce-internal.h"
19703
19704 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19705 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19706 m->cs, m->ip);
19707
19708 - if (m->cs == __KERNEL_CS)
19709 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19710 print_symbol("{%s}", m->ip);
19711 pr_cont("\n");
19712 }
19713 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19714
19715 #define PANIC_TIMEOUT 5 /* 5 seconds */
19716
19717 -static atomic_t mce_paniced;
19718 +static atomic_unchecked_t mce_paniced;
19719
19720 static int fake_panic;
19721 -static atomic_t mce_fake_paniced;
19722 +static atomic_unchecked_t mce_fake_paniced;
19723
19724 /* Panic in progress. Enable interrupts and wait for final IPI */
19725 static void wait_for_panic(void)
19726 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19727 /*
19728 * Make sure only one CPU runs in machine check panic
19729 */
19730 - if (atomic_inc_return(&mce_paniced) > 1)
19731 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19732 wait_for_panic();
19733 barrier();
19734
19735 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19736 console_verbose();
19737 } else {
19738 /* Don't log too much for fake panic */
19739 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19740 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19741 return;
19742 }
19743 /* First print corrected ones that are still unlogged */
19744 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19745 if (!fake_panic) {
19746 if (panic_timeout == 0)
19747 panic_timeout = mca_cfg.panic_timeout;
19748 - panic(msg);
19749 + panic("%s", msg);
19750 } else
19751 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19752 }
19753 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19754 * might have been modified by someone else.
19755 */
19756 rmb();
19757 - if (atomic_read(&mce_paniced))
19758 + if (atomic_read_unchecked(&mce_paniced))
19759 wait_for_panic();
19760 if (!mca_cfg.monarch_timeout)
19761 goto out;
19762 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19763 }
19764
19765 /* Call the installed machine check handler for this CPU setup. */
19766 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19767 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19768 unexpected_machine_check;
19769
19770 /*
19771 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19772 return;
19773 }
19774
19775 + pax_open_kernel();
19776 machine_check_vector = do_machine_check;
19777 + pax_close_kernel();
19778
19779 __mcheck_cpu_init_generic();
19780 __mcheck_cpu_init_vendor(c);
19781 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19782 */
19783
19784 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19785 -static int mce_chrdev_open_count; /* #times opened */
19786 +static local_t mce_chrdev_open_count; /* #times opened */
19787 static int mce_chrdev_open_exclu; /* already open exclusive? */
19788
19789 static int mce_chrdev_open(struct inode *inode, struct file *file)
19790 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19791 spin_lock(&mce_chrdev_state_lock);
19792
19793 if (mce_chrdev_open_exclu ||
19794 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19795 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19796 spin_unlock(&mce_chrdev_state_lock);
19797
19798 return -EBUSY;
19799 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19800
19801 if (file->f_flags & O_EXCL)
19802 mce_chrdev_open_exclu = 1;
19803 - mce_chrdev_open_count++;
19804 + local_inc(&mce_chrdev_open_count);
19805
19806 spin_unlock(&mce_chrdev_state_lock);
19807
19808 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19809 {
19810 spin_lock(&mce_chrdev_state_lock);
19811
19812 - mce_chrdev_open_count--;
19813 + local_dec(&mce_chrdev_open_count);
19814 mce_chrdev_open_exclu = 0;
19815
19816 spin_unlock(&mce_chrdev_state_lock);
19817 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19818
19819 for (i = 0; i < mca_cfg.banks; i++) {
19820 struct mce_bank *b = &mce_banks[i];
19821 - struct device_attribute *a = &b->attr;
19822 + device_attribute_no_const *a = &b->attr;
19823
19824 sysfs_attr_init(&a->attr);
19825 a->attr.name = b->attrname;
19826 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19827 static void mce_reset(void)
19828 {
19829 cpu_missing = 0;
19830 - atomic_set(&mce_fake_paniced, 0);
19831 + atomic_set_unchecked(&mce_fake_paniced, 0);
19832 atomic_set(&mce_executing, 0);
19833 atomic_set(&mce_callin, 0);
19834 atomic_set(&global_nwo, 0);
19835 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19836 index 1c044b1..37a2a43 100644
19837 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19838 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19839 @@ -11,6 +11,7 @@
19840 #include <asm/processor.h>
19841 #include <asm/mce.h>
19842 #include <asm/msr.h>
19843 +#include <asm/pgtable.h>
19844
19845 /* By default disabled */
19846 int mce_p5_enabled __read_mostly;
19847 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19848 if (!cpu_has(c, X86_FEATURE_MCE))
19849 return;
19850
19851 + pax_open_kernel();
19852 machine_check_vector = pentium_machine_check;
19853 + pax_close_kernel();
19854 /* Make sure the vector pointer is visible before we enable MCEs: */
19855 wmb();
19856
19857 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19858 index e9a701a..35317d6 100644
19859 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19860 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19861 @@ -10,6 +10,7 @@
19862 #include <asm/processor.h>
19863 #include <asm/mce.h>
19864 #include <asm/msr.h>
19865 +#include <asm/pgtable.h>
19866
19867 /* Machine check handler for WinChip C6: */
19868 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19869 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19870 {
19871 u32 lo, hi;
19872
19873 + pax_open_kernel();
19874 machine_check_vector = winchip_machine_check;
19875 + pax_close_kernel();
19876 /* Make sure the vector pointer is visible before we enable MCEs: */
19877 wmb();
19878
19879 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19880 index f961de9..8a9d332 100644
19881 --- a/arch/x86/kernel/cpu/mtrr/main.c
19882 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19883 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19884 u64 size_or_mask, size_and_mask;
19885 static bool mtrr_aps_delayed_init;
19886
19887 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19888 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19889
19890 const struct mtrr_ops *mtrr_if;
19891
19892 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19893 index df5e41f..816c719 100644
19894 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19895 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19896 @@ -25,7 +25,7 @@ struct mtrr_ops {
19897 int (*validate_add_page)(unsigned long base, unsigned long size,
19898 unsigned int type);
19899 int (*have_wrcomb)(void);
19900 -};
19901 +} __do_const;
19902
19903 extern int generic_get_free_region(unsigned long base, unsigned long size,
19904 int replace_reg);
19905 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19906 index a7c7305..b9705ab 100644
19907 --- a/arch/x86/kernel/cpu/perf_event.c
19908 +++ b/arch/x86/kernel/cpu/perf_event.c
19909 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19910 pr_info("no hardware sampling interrupt available.\n");
19911 }
19912
19913 -static struct attribute_group x86_pmu_format_group = {
19914 +static attribute_group_no_const x86_pmu_format_group = {
19915 .name = "format",
19916 .attrs = NULL,
19917 };
19918 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19919 NULL,
19920 };
19921
19922 -static struct attribute_group x86_pmu_events_group = {
19923 +static attribute_group_no_const x86_pmu_events_group = {
19924 .name = "events",
19925 .attrs = events_attr,
19926 };
19927 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19928 if (idx > GDT_ENTRIES)
19929 return 0;
19930
19931 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19932 + desc = get_cpu_gdt_table(smp_processor_id());
19933 }
19934
19935 return get_desc_base(desc + idx);
19936 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
19937 break;
19938
19939 perf_callchain_store(entry, frame.return_address);
19940 - fp = frame.next_frame;
19941 + fp = (const void __force_user *)frame.next_frame;
19942 }
19943 }
19944
19945 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19946 index 639d128..e92d7e5 100644
19947 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19948 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19949 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
19950 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
19951 {
19952 struct attribute **attrs;
19953 - struct attribute_group *attr_group;
19954 + attribute_group_no_const *attr_group;
19955 int i = 0, j;
19956
19957 while (amd_iommu_v2_event_descs[i].attr.attr.name)
19958 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
19959 index a45d8d4..8abd32c 100644
19960 --- a/arch/x86/kernel/cpu/perf_event_intel.c
19961 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
19962 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
19963 * v2 and above have a perf capabilities MSR
19964 */
19965 if (version > 1) {
19966 - u64 capabilities;
19967 + u64 capabilities = x86_pmu.intel_cap.capabilities;
19968
19969 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
19970 - x86_pmu.intel_cap.capabilities = capabilities;
19971 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
19972 + x86_pmu.intel_cap.capabilities = capabilities;
19973 }
19974
19975 intel_ds_init();
19976 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19977 index 1fb6c72..f5fa2a3 100644
19978 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19979 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19980 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
19981 static int __init uncore_type_init(struct intel_uncore_type *type)
19982 {
19983 struct intel_uncore_pmu *pmus;
19984 - struct attribute_group *attr_group;
19985 + attribute_group_no_const *attr_group;
19986 struct attribute **attrs;
19987 int i, j;
19988
19989 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19990 index 47b3d00c..2cf1751 100644
19991 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19992 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19993 @@ -488,7 +488,7 @@ struct intel_uncore_box {
19994 struct uncore_event_desc {
19995 struct kobj_attribute attr;
19996 const char *config;
19997 -};
19998 +} __do_const;
19999
20000 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20001 { \
20002 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20003 index 7d9481c..99c7e4b 100644
20004 --- a/arch/x86/kernel/cpuid.c
20005 +++ b/arch/x86/kernel/cpuid.c
20006 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20007 return notifier_from_errno(err);
20008 }
20009
20010 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20011 +static struct notifier_block cpuid_class_cpu_notifier =
20012 {
20013 .notifier_call = cpuid_class_cpu_callback,
20014 };
20015 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20016 index 74467fe..18793d5 100644
20017 --- a/arch/x86/kernel/crash.c
20018 +++ b/arch/x86/kernel/crash.c
20019 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20020 {
20021 #ifdef CONFIG_X86_32
20022 struct pt_regs fixed_regs;
20023 -#endif
20024
20025 -#ifdef CONFIG_X86_32
20026 - if (!user_mode_vm(regs)) {
20027 + if (!user_mode(regs)) {
20028 crash_fixup_ss_esp(&fixed_regs, regs);
20029 regs = &fixed_regs;
20030 }
20031 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20032 index afa64ad..dce67dd 100644
20033 --- a/arch/x86/kernel/crash_dump_64.c
20034 +++ b/arch/x86/kernel/crash_dump_64.c
20035 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20036 return -ENOMEM;
20037
20038 if (userbuf) {
20039 - if (copy_to_user(buf, vaddr + offset, csize)) {
20040 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20041 iounmap(vaddr);
20042 return -EFAULT;
20043 }
20044 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20045 index 5d3fe8d..02e1429 100644
20046 --- a/arch/x86/kernel/doublefault.c
20047 +++ b/arch/x86/kernel/doublefault.c
20048 @@ -13,7 +13,7 @@
20049
20050 #define DOUBLEFAULT_STACKSIZE (1024)
20051 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20052 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20053 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20054
20055 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20056
20057 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20058 unsigned long gdt, tss;
20059
20060 native_store_gdt(&gdt_desc);
20061 - gdt = gdt_desc.address;
20062 + gdt = (unsigned long)gdt_desc.address;
20063
20064 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20065
20066 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20067 /* 0x2 bit is always set */
20068 .flags = X86_EFLAGS_SF | 0x2,
20069 .sp = STACK_START,
20070 - .es = __USER_DS,
20071 + .es = __KERNEL_DS,
20072 .cs = __KERNEL_CS,
20073 .ss = __KERNEL_DS,
20074 - .ds = __USER_DS,
20075 + .ds = __KERNEL_DS,
20076 .fs = __KERNEL_PERCPU,
20077
20078 .__cr3 = __pa_nodebug(swapper_pg_dir),
20079 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20080 index deb6421..76bbc12 100644
20081 --- a/arch/x86/kernel/dumpstack.c
20082 +++ b/arch/x86/kernel/dumpstack.c
20083 @@ -2,6 +2,9 @@
20084 * Copyright (C) 1991, 1992 Linus Torvalds
20085 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20086 */
20087 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20088 +#define __INCLUDED_BY_HIDESYM 1
20089 +#endif
20090 #include <linux/kallsyms.h>
20091 #include <linux/kprobes.h>
20092 #include <linux/uaccess.h>
20093 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20094 static void
20095 print_ftrace_graph_addr(unsigned long addr, void *data,
20096 const struct stacktrace_ops *ops,
20097 - struct thread_info *tinfo, int *graph)
20098 + struct task_struct *task, int *graph)
20099 {
20100 - struct task_struct *task;
20101 unsigned long ret_addr;
20102 int index;
20103
20104 if (addr != (unsigned long)return_to_handler)
20105 return;
20106
20107 - task = tinfo->task;
20108 index = task->curr_ret_stack;
20109
20110 if (!task->ret_stack || index < *graph)
20111 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20112 static inline void
20113 print_ftrace_graph_addr(unsigned long addr, void *data,
20114 const struct stacktrace_ops *ops,
20115 - struct thread_info *tinfo, int *graph)
20116 + struct task_struct *task, int *graph)
20117 { }
20118 #endif
20119
20120 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20121 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20122 */
20123
20124 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20125 - void *p, unsigned int size, void *end)
20126 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20127 {
20128 - void *t = tinfo;
20129 if (end) {
20130 if (p < end && p >= (end-THREAD_SIZE))
20131 return 1;
20132 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20133 }
20134
20135 unsigned long
20136 -print_context_stack(struct thread_info *tinfo,
20137 +print_context_stack(struct task_struct *task, void *stack_start,
20138 unsigned long *stack, unsigned long bp,
20139 const struct stacktrace_ops *ops, void *data,
20140 unsigned long *end, int *graph)
20141 {
20142 struct stack_frame *frame = (struct stack_frame *)bp;
20143
20144 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20145 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20146 unsigned long addr;
20147
20148 addr = *stack;
20149 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20150 } else {
20151 ops->address(data, addr, 0);
20152 }
20153 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20154 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20155 }
20156 stack++;
20157 }
20158 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20159 EXPORT_SYMBOL_GPL(print_context_stack);
20160
20161 unsigned long
20162 -print_context_stack_bp(struct thread_info *tinfo,
20163 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20164 unsigned long *stack, unsigned long bp,
20165 const struct stacktrace_ops *ops, void *data,
20166 unsigned long *end, int *graph)
20167 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20168 struct stack_frame *frame = (struct stack_frame *)bp;
20169 unsigned long *ret_addr = &frame->return_address;
20170
20171 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20172 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20173 unsigned long addr = *ret_addr;
20174
20175 if (!__kernel_text_address(addr))
20176 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20177 ops->address(data, addr, 1);
20178 frame = frame->next_frame;
20179 ret_addr = &frame->return_address;
20180 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20181 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20182 }
20183
20184 return (unsigned long)frame;
20185 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20186 static void print_trace_address(void *data, unsigned long addr, int reliable)
20187 {
20188 touch_nmi_watchdog();
20189 - printk(data);
20190 + printk("%s", (char *)data);
20191 printk_address(addr, reliable);
20192 }
20193
20194 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20195 }
20196 EXPORT_SYMBOL_GPL(oops_begin);
20197
20198 +extern void gr_handle_kernel_exploit(void);
20199 +
20200 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20201 {
20202 if (regs && kexec_should_crash(current))
20203 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20204 panic("Fatal exception in interrupt");
20205 if (panic_on_oops)
20206 panic("Fatal exception");
20207 - do_exit(signr);
20208 +
20209 + gr_handle_kernel_exploit();
20210 +
20211 + do_group_exit(signr);
20212 }
20213
20214 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20215 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20216 print_modules();
20217 show_regs(regs);
20218 #ifdef CONFIG_X86_32
20219 - if (user_mode_vm(regs)) {
20220 + if (user_mode(regs)) {
20221 sp = regs->sp;
20222 ss = regs->ss & 0xffff;
20223 } else {
20224 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20225 unsigned long flags = oops_begin();
20226 int sig = SIGSEGV;
20227
20228 - if (!user_mode_vm(regs))
20229 + if (!user_mode(regs))
20230 report_bug(regs->ip, regs);
20231
20232 if (__die(str, regs, err))
20233 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20234 index f2a1770..540657f 100644
20235 --- a/arch/x86/kernel/dumpstack_32.c
20236 +++ b/arch/x86/kernel/dumpstack_32.c
20237 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20238 bp = stack_frame(task, regs);
20239
20240 for (;;) {
20241 - struct thread_info *context;
20242 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20243
20244 - context = (struct thread_info *)
20245 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20246 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20247 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20248
20249 - stack = (unsigned long *)context->previous_esp;
20250 - if (!stack)
20251 + if (stack_start == task_stack_page(task))
20252 break;
20253 + stack = *(unsigned long **)stack_start;
20254 if (ops->stack(data, "IRQ") < 0)
20255 break;
20256 touch_nmi_watchdog();
20257 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20258 int i;
20259
20260 show_regs_print_info(KERN_EMERG);
20261 - __show_regs(regs, !user_mode_vm(regs));
20262 + __show_regs(regs, !user_mode(regs));
20263
20264 /*
20265 * When in-kernel, we also print out the stack and code at the
20266 * time of the fault..
20267 */
20268 - if (!user_mode_vm(regs)) {
20269 + if (!user_mode(regs)) {
20270 unsigned int code_prologue = code_bytes * 43 / 64;
20271 unsigned int code_len = code_bytes;
20272 unsigned char c;
20273 u8 *ip;
20274 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20275
20276 pr_emerg("Stack:\n");
20277 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20278
20279 pr_emerg("Code:");
20280
20281 - ip = (u8 *)regs->ip - code_prologue;
20282 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20283 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20284 /* try starting at IP */
20285 - ip = (u8 *)regs->ip;
20286 + ip = (u8 *)regs->ip + cs_base;
20287 code_len = code_len - code_prologue + 1;
20288 }
20289 for (i = 0; i < code_len; i++, ip++) {
20290 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20291 pr_cont(" Bad EIP value.");
20292 break;
20293 }
20294 - if (ip == (u8 *)regs->ip)
20295 + if (ip == (u8 *)regs->ip + cs_base)
20296 pr_cont(" <%02x>", c);
20297 else
20298 pr_cont(" %02x", c);
20299 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20300 {
20301 unsigned short ud2;
20302
20303 + ip = ktla_ktva(ip);
20304 if (ip < PAGE_OFFSET)
20305 return 0;
20306 if (probe_kernel_address((unsigned short *)ip, ud2))
20307 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20308
20309 return ud2 == 0x0b0f;
20310 }
20311 +
20312 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20313 +void pax_check_alloca(unsigned long size)
20314 +{
20315 + unsigned long sp = (unsigned long)&sp, stack_left;
20316 +
20317 + /* all kernel stacks are of the same size */
20318 + stack_left = sp & (THREAD_SIZE - 1);
20319 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20320 +}
20321 +EXPORT_SYMBOL(pax_check_alloca);
20322 +#endif
20323 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20324 index addb207..99635fa 100644
20325 --- a/arch/x86/kernel/dumpstack_64.c
20326 +++ b/arch/x86/kernel/dumpstack_64.c
20327 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20328 unsigned long *irq_stack_end =
20329 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20330 unsigned used = 0;
20331 - struct thread_info *tinfo;
20332 int graph = 0;
20333 unsigned long dummy;
20334 + void *stack_start;
20335
20336 if (!task)
20337 task = current;
20338 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20339 * current stack address. If the stacks consist of nested
20340 * exceptions
20341 */
20342 - tinfo = task_thread_info(task);
20343 for (;;) {
20344 char *id;
20345 unsigned long *estack_end;
20346 +
20347 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20348 &used, &id);
20349
20350 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20351 if (ops->stack(data, id) < 0)
20352 break;
20353
20354 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20355 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20356 data, estack_end, &graph);
20357 ops->stack(data, "<EOE>");
20358 /*
20359 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20360 * second-to-last pointer (index -2 to end) in the
20361 * exception stack:
20362 */
20363 + if ((u16)estack_end[-1] != __KERNEL_DS)
20364 + goto out;
20365 stack = (unsigned long *) estack_end[-2];
20366 continue;
20367 }
20368 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20369 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20370 if (ops->stack(data, "IRQ") < 0)
20371 break;
20372 - bp = ops->walk_stack(tinfo, stack, bp,
20373 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20374 ops, data, irq_stack_end, &graph);
20375 /*
20376 * We link to the next stack (which would be
20377 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20378 /*
20379 * This handles the process stack:
20380 */
20381 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20382 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20383 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20384 +out:
20385 put_cpu();
20386 }
20387 EXPORT_SYMBOL(dump_trace);
20388 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20389
20390 return ud2 == 0x0b0f;
20391 }
20392 +
20393 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20394 +void pax_check_alloca(unsigned long size)
20395 +{
20396 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20397 + unsigned cpu, used;
20398 + char *id;
20399 +
20400 + /* check the process stack first */
20401 + stack_start = (unsigned long)task_stack_page(current);
20402 + stack_end = stack_start + THREAD_SIZE;
20403 + if (likely(stack_start <= sp && sp < stack_end)) {
20404 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20405 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20406 + return;
20407 + }
20408 +
20409 + cpu = get_cpu();
20410 +
20411 + /* check the irq stacks */
20412 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20413 + stack_start = stack_end - IRQ_STACK_SIZE;
20414 + if (stack_start <= sp && sp < stack_end) {
20415 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20416 + put_cpu();
20417 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20418 + return;
20419 + }
20420 +
20421 + /* check the exception stacks */
20422 + used = 0;
20423 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20424 + stack_start = stack_end - EXCEPTION_STKSZ;
20425 + if (stack_end && stack_start <= sp && sp < stack_end) {
20426 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20427 + put_cpu();
20428 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20429 + return;
20430 + }
20431 +
20432 + put_cpu();
20433 +
20434 + /* unknown stack */
20435 + BUG();
20436 +}
20437 +EXPORT_SYMBOL(pax_check_alloca);
20438 +#endif
20439 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20440 index d32abea..74daf4f 100644
20441 --- a/arch/x86/kernel/e820.c
20442 +++ b/arch/x86/kernel/e820.c
20443 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20444
20445 static void early_panic(char *msg)
20446 {
20447 - early_printk(msg);
20448 - panic(msg);
20449 + early_printk("%s", msg);
20450 + panic("%s", msg);
20451 }
20452
20453 static int userdef __initdata;
20454 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20455 index d15f575..d692043 100644
20456 --- a/arch/x86/kernel/early_printk.c
20457 +++ b/arch/x86/kernel/early_printk.c
20458 @@ -7,6 +7,7 @@
20459 #include <linux/pci_regs.h>
20460 #include <linux/pci_ids.h>
20461 #include <linux/errno.h>
20462 +#include <linux/sched.h>
20463 #include <asm/io.h>
20464 #include <asm/processor.h>
20465 #include <asm/fcntl.h>
20466 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20467 index 2cfbc3a..b756682 100644
20468 --- a/arch/x86/kernel/entry_32.S
20469 +++ b/arch/x86/kernel/entry_32.S
20470 @@ -177,13 +177,153 @@
20471 /*CFI_REL_OFFSET gs, PT_GS*/
20472 .endm
20473 .macro SET_KERNEL_GS reg
20474 +
20475 +#ifdef CONFIG_CC_STACKPROTECTOR
20476 movl $(__KERNEL_STACK_CANARY), \reg
20477 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20478 + movl $(__USER_DS), \reg
20479 +#else
20480 + xorl \reg, \reg
20481 +#endif
20482 +
20483 movl \reg, %gs
20484 .endm
20485
20486 #endif /* CONFIG_X86_32_LAZY_GS */
20487
20488 -.macro SAVE_ALL
20489 +.macro pax_enter_kernel
20490 +#ifdef CONFIG_PAX_KERNEXEC
20491 + call pax_enter_kernel
20492 +#endif
20493 +.endm
20494 +
20495 +.macro pax_exit_kernel
20496 +#ifdef CONFIG_PAX_KERNEXEC
20497 + call pax_exit_kernel
20498 +#endif
20499 +.endm
20500 +
20501 +#ifdef CONFIG_PAX_KERNEXEC
20502 +ENTRY(pax_enter_kernel)
20503 +#ifdef CONFIG_PARAVIRT
20504 + pushl %eax
20505 + pushl %ecx
20506 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20507 + mov %eax, %esi
20508 +#else
20509 + mov %cr0, %esi
20510 +#endif
20511 + bts $16, %esi
20512 + jnc 1f
20513 + mov %cs, %esi
20514 + cmp $__KERNEL_CS, %esi
20515 + jz 3f
20516 + ljmp $__KERNEL_CS, $3f
20517 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20518 +2:
20519 +#ifdef CONFIG_PARAVIRT
20520 + mov %esi, %eax
20521 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20522 +#else
20523 + mov %esi, %cr0
20524 +#endif
20525 +3:
20526 +#ifdef CONFIG_PARAVIRT
20527 + popl %ecx
20528 + popl %eax
20529 +#endif
20530 + ret
20531 +ENDPROC(pax_enter_kernel)
20532 +
20533 +ENTRY(pax_exit_kernel)
20534 +#ifdef CONFIG_PARAVIRT
20535 + pushl %eax
20536 + pushl %ecx
20537 +#endif
20538 + mov %cs, %esi
20539 + cmp $__KERNEXEC_KERNEL_CS, %esi
20540 + jnz 2f
20541 +#ifdef CONFIG_PARAVIRT
20542 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20543 + mov %eax, %esi
20544 +#else
20545 + mov %cr0, %esi
20546 +#endif
20547 + btr $16, %esi
20548 + ljmp $__KERNEL_CS, $1f
20549 +1:
20550 +#ifdef CONFIG_PARAVIRT
20551 + mov %esi, %eax
20552 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20553 +#else
20554 + mov %esi, %cr0
20555 +#endif
20556 +2:
20557 +#ifdef CONFIG_PARAVIRT
20558 + popl %ecx
20559 + popl %eax
20560 +#endif
20561 + ret
20562 +ENDPROC(pax_exit_kernel)
20563 +#endif
20564 +
20565 + .macro pax_erase_kstack
20566 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20567 + call pax_erase_kstack
20568 +#endif
20569 + .endm
20570 +
20571 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20572 +/*
20573 + * ebp: thread_info
20574 + */
20575 +ENTRY(pax_erase_kstack)
20576 + pushl %edi
20577 + pushl %ecx
20578 + pushl %eax
20579 +
20580 + mov TI_lowest_stack(%ebp), %edi
20581 + mov $-0xBEEF, %eax
20582 + std
20583 +
20584 +1: mov %edi, %ecx
20585 + and $THREAD_SIZE_asm - 1, %ecx
20586 + shr $2, %ecx
20587 + repne scasl
20588 + jecxz 2f
20589 +
20590 + cmp $2*16, %ecx
20591 + jc 2f
20592 +
20593 + mov $2*16, %ecx
20594 + repe scasl
20595 + jecxz 2f
20596 + jne 1b
20597 +
20598 +2: cld
20599 + mov %esp, %ecx
20600 + sub %edi, %ecx
20601 +
20602 + cmp $THREAD_SIZE_asm, %ecx
20603 + jb 3f
20604 + ud2
20605 +3:
20606 +
20607 + shr $2, %ecx
20608 + rep stosl
20609 +
20610 + mov TI_task_thread_sp0(%ebp), %edi
20611 + sub $128, %edi
20612 + mov %edi, TI_lowest_stack(%ebp)
20613 +
20614 + popl %eax
20615 + popl %ecx
20616 + popl %edi
20617 + ret
20618 +ENDPROC(pax_erase_kstack)
20619 +#endif
20620 +
20621 +.macro __SAVE_ALL _DS
20622 cld
20623 PUSH_GS
20624 pushl_cfi %fs
20625 @@ -206,7 +346,7 @@
20626 CFI_REL_OFFSET ecx, 0
20627 pushl_cfi %ebx
20628 CFI_REL_OFFSET ebx, 0
20629 - movl $(__USER_DS), %edx
20630 + movl $\_DS, %edx
20631 movl %edx, %ds
20632 movl %edx, %es
20633 movl $(__KERNEL_PERCPU), %edx
20634 @@ -214,6 +354,15 @@
20635 SET_KERNEL_GS %edx
20636 .endm
20637
20638 +.macro SAVE_ALL
20639 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20640 + __SAVE_ALL __KERNEL_DS
20641 + pax_enter_kernel
20642 +#else
20643 + __SAVE_ALL __USER_DS
20644 +#endif
20645 +.endm
20646 +
20647 .macro RESTORE_INT_REGS
20648 popl_cfi %ebx
20649 CFI_RESTORE ebx
20650 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20651 popfl_cfi
20652 jmp syscall_exit
20653 CFI_ENDPROC
20654 -END(ret_from_fork)
20655 +ENDPROC(ret_from_fork)
20656
20657 ENTRY(ret_from_kernel_thread)
20658 CFI_STARTPROC
20659 @@ -344,7 +493,15 @@ ret_from_intr:
20660 andl $SEGMENT_RPL_MASK, %eax
20661 #endif
20662 cmpl $USER_RPL, %eax
20663 +
20664 +#ifdef CONFIG_PAX_KERNEXEC
20665 + jae resume_userspace
20666 +
20667 + pax_exit_kernel
20668 + jmp resume_kernel
20669 +#else
20670 jb resume_kernel # not returning to v8086 or userspace
20671 +#endif
20672
20673 ENTRY(resume_userspace)
20674 LOCKDEP_SYS_EXIT
20675 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20676 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20677 # int/exception return?
20678 jne work_pending
20679 - jmp restore_all
20680 -END(ret_from_exception)
20681 + jmp restore_all_pax
20682 +ENDPROC(ret_from_exception)
20683
20684 #ifdef CONFIG_PREEMPT
20685 ENTRY(resume_kernel)
20686 @@ -372,7 +529,7 @@ need_resched:
20687 jz restore_all
20688 call preempt_schedule_irq
20689 jmp need_resched
20690 -END(resume_kernel)
20691 +ENDPROC(resume_kernel)
20692 #endif
20693 CFI_ENDPROC
20694 /*
20695 @@ -406,30 +563,45 @@ sysenter_past_esp:
20696 /*CFI_REL_OFFSET cs, 0*/
20697 /*
20698 * Push current_thread_info()->sysenter_return to the stack.
20699 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20700 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20701 */
20702 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20703 + pushl_cfi $0
20704 CFI_REL_OFFSET eip, 0
20705
20706 pushl_cfi %eax
20707 SAVE_ALL
20708 + GET_THREAD_INFO(%ebp)
20709 + movl TI_sysenter_return(%ebp),%ebp
20710 + movl %ebp,PT_EIP(%esp)
20711 ENABLE_INTERRUPTS(CLBR_NONE)
20712
20713 /*
20714 * Load the potential sixth argument from user stack.
20715 * Careful about security.
20716 */
20717 + movl PT_OLDESP(%esp),%ebp
20718 +
20719 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20720 + mov PT_OLDSS(%esp),%ds
20721 +1: movl %ds:(%ebp),%ebp
20722 + push %ss
20723 + pop %ds
20724 +#else
20725 cmpl $__PAGE_OFFSET-3,%ebp
20726 jae syscall_fault
20727 ASM_STAC
20728 1: movl (%ebp),%ebp
20729 ASM_CLAC
20730 +#endif
20731 +
20732 movl %ebp,PT_EBP(%esp)
20733 _ASM_EXTABLE(1b,syscall_fault)
20734
20735 GET_THREAD_INFO(%ebp)
20736
20737 +#ifdef CONFIG_PAX_RANDKSTACK
20738 + pax_erase_kstack
20739 +#endif
20740 +
20741 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20742 jnz sysenter_audit
20743 sysenter_do_call:
20744 @@ -444,12 +616,24 @@ sysenter_do_call:
20745 testl $_TIF_ALLWORK_MASK, %ecx
20746 jne sysexit_audit
20747 sysenter_exit:
20748 +
20749 +#ifdef CONFIG_PAX_RANDKSTACK
20750 + pushl_cfi %eax
20751 + movl %esp, %eax
20752 + call pax_randomize_kstack
20753 + popl_cfi %eax
20754 +#endif
20755 +
20756 + pax_erase_kstack
20757 +
20758 /* if something modifies registers it must also disable sysexit */
20759 movl PT_EIP(%esp), %edx
20760 movl PT_OLDESP(%esp), %ecx
20761 xorl %ebp,%ebp
20762 TRACE_IRQS_ON
20763 1: mov PT_FS(%esp), %fs
20764 +2: mov PT_DS(%esp), %ds
20765 +3: mov PT_ES(%esp), %es
20766 PTGS_TO_GS
20767 ENABLE_INTERRUPTS_SYSEXIT
20768
20769 @@ -466,6 +650,9 @@ sysenter_audit:
20770 movl %eax,%edx /* 2nd arg: syscall number */
20771 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20772 call __audit_syscall_entry
20773 +
20774 + pax_erase_kstack
20775 +
20776 pushl_cfi %ebx
20777 movl PT_EAX(%esp),%eax /* reload syscall number */
20778 jmp sysenter_do_call
20779 @@ -491,10 +678,16 @@ sysexit_audit:
20780
20781 CFI_ENDPROC
20782 .pushsection .fixup,"ax"
20783 -2: movl $0,PT_FS(%esp)
20784 +4: movl $0,PT_FS(%esp)
20785 + jmp 1b
20786 +5: movl $0,PT_DS(%esp)
20787 + jmp 1b
20788 +6: movl $0,PT_ES(%esp)
20789 jmp 1b
20790 .popsection
20791 - _ASM_EXTABLE(1b,2b)
20792 + _ASM_EXTABLE(1b,4b)
20793 + _ASM_EXTABLE(2b,5b)
20794 + _ASM_EXTABLE(3b,6b)
20795 PTGS_TO_GS_EX
20796 ENDPROC(ia32_sysenter_target)
20797
20798 @@ -509,6 +702,11 @@ ENTRY(system_call)
20799 pushl_cfi %eax # save orig_eax
20800 SAVE_ALL
20801 GET_THREAD_INFO(%ebp)
20802 +
20803 +#ifdef CONFIG_PAX_RANDKSTACK
20804 + pax_erase_kstack
20805 +#endif
20806 +
20807 # system call tracing in operation / emulation
20808 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20809 jnz syscall_trace_entry
20810 @@ -527,6 +725,15 @@ syscall_exit:
20811 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20812 jne syscall_exit_work
20813
20814 +restore_all_pax:
20815 +
20816 +#ifdef CONFIG_PAX_RANDKSTACK
20817 + movl %esp, %eax
20818 + call pax_randomize_kstack
20819 +#endif
20820 +
20821 + pax_erase_kstack
20822 +
20823 restore_all:
20824 TRACE_IRQS_IRET
20825 restore_all_notrace:
20826 @@ -583,14 +790,34 @@ ldt_ss:
20827 * compensating for the offset by changing to the ESPFIX segment with
20828 * a base address that matches for the difference.
20829 */
20830 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20831 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20832 mov %esp, %edx /* load kernel esp */
20833 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20834 mov %dx, %ax /* eax: new kernel esp */
20835 sub %eax, %edx /* offset (low word is 0) */
20836 +#ifdef CONFIG_SMP
20837 + movl PER_CPU_VAR(cpu_number), %ebx
20838 + shll $PAGE_SHIFT_asm, %ebx
20839 + addl $cpu_gdt_table, %ebx
20840 +#else
20841 + movl $cpu_gdt_table, %ebx
20842 +#endif
20843 shr $16, %edx
20844 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20845 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20846 +
20847 +#ifdef CONFIG_PAX_KERNEXEC
20848 + mov %cr0, %esi
20849 + btr $16, %esi
20850 + mov %esi, %cr0
20851 +#endif
20852 +
20853 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20854 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20855 +
20856 +#ifdef CONFIG_PAX_KERNEXEC
20857 + bts $16, %esi
20858 + mov %esi, %cr0
20859 +#endif
20860 +
20861 pushl_cfi $__ESPFIX_SS
20862 pushl_cfi %eax /* new kernel esp */
20863 /* Disable interrupts, but do not irqtrace this section: we
20864 @@ -619,20 +846,18 @@ work_resched:
20865 movl TI_flags(%ebp), %ecx
20866 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20867 # than syscall tracing?
20868 - jz restore_all
20869 + jz restore_all_pax
20870 testb $_TIF_NEED_RESCHED, %cl
20871 jnz work_resched
20872
20873 work_notifysig: # deal with pending signals and
20874 # notify-resume requests
20875 + movl %esp, %eax
20876 #ifdef CONFIG_VM86
20877 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20878 - movl %esp, %eax
20879 jne work_notifysig_v86 # returning to kernel-space or
20880 # vm86-space
20881 1:
20882 -#else
20883 - movl %esp, %eax
20884 #endif
20885 TRACE_IRQS_ON
20886 ENABLE_INTERRUPTS(CLBR_NONE)
20887 @@ -653,7 +878,7 @@ work_notifysig_v86:
20888 movl %eax, %esp
20889 jmp 1b
20890 #endif
20891 -END(work_pending)
20892 +ENDPROC(work_pending)
20893
20894 # perform syscall exit tracing
20895 ALIGN
20896 @@ -661,11 +886,14 @@ syscall_trace_entry:
20897 movl $-ENOSYS,PT_EAX(%esp)
20898 movl %esp, %eax
20899 call syscall_trace_enter
20900 +
20901 + pax_erase_kstack
20902 +
20903 /* What it returned is what we'll actually use. */
20904 cmpl $(NR_syscalls), %eax
20905 jnae syscall_call
20906 jmp syscall_exit
20907 -END(syscall_trace_entry)
20908 +ENDPROC(syscall_trace_entry)
20909
20910 # perform syscall exit tracing
20911 ALIGN
20912 @@ -678,21 +906,25 @@ syscall_exit_work:
20913 movl %esp, %eax
20914 call syscall_trace_leave
20915 jmp resume_userspace
20916 -END(syscall_exit_work)
20917 +ENDPROC(syscall_exit_work)
20918 CFI_ENDPROC
20919
20920 RING0_INT_FRAME # can't unwind into user space anyway
20921 syscall_fault:
20922 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20923 + push %ss
20924 + pop %ds
20925 +#endif
20926 ASM_CLAC
20927 GET_THREAD_INFO(%ebp)
20928 movl $-EFAULT,PT_EAX(%esp)
20929 jmp resume_userspace
20930 -END(syscall_fault)
20931 +ENDPROC(syscall_fault)
20932
20933 syscall_badsys:
20934 movl $-ENOSYS,PT_EAX(%esp)
20935 jmp resume_userspace
20936 -END(syscall_badsys)
20937 +ENDPROC(syscall_badsys)
20938 CFI_ENDPROC
20939 /*
20940 * End of kprobes section
20941 @@ -708,8 +940,15 @@ END(syscall_badsys)
20942 * normal stack and adjusts ESP with the matching offset.
20943 */
20944 /* fixup the stack */
20945 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
20946 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
20947 +#ifdef CONFIG_SMP
20948 + movl PER_CPU_VAR(cpu_number), %ebx
20949 + shll $PAGE_SHIFT_asm, %ebx
20950 + addl $cpu_gdt_table, %ebx
20951 +#else
20952 + movl $cpu_gdt_table, %ebx
20953 +#endif
20954 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
20955 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
20956 shl $16, %eax
20957 addl %esp, %eax /* the adjusted stack pointer */
20958 pushl_cfi $__KERNEL_DS
20959 @@ -762,7 +1001,7 @@ vector=vector+1
20960 .endr
20961 2: jmp common_interrupt
20962 .endr
20963 -END(irq_entries_start)
20964 +ENDPROC(irq_entries_start)
20965
20966 .previous
20967 END(interrupt)
20968 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
20969 pushl_cfi $do_coprocessor_error
20970 jmp error_code
20971 CFI_ENDPROC
20972 -END(coprocessor_error)
20973 +ENDPROC(coprocessor_error)
20974
20975 ENTRY(simd_coprocessor_error)
20976 RING0_INT_FRAME
20977 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
20978 .section .altinstructions,"a"
20979 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
20980 .previous
20981 -.section .altinstr_replacement,"ax"
20982 +.section .altinstr_replacement,"a"
20983 663: pushl $do_simd_coprocessor_error
20984 664:
20985 .previous
20986 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
20987 #endif
20988 jmp error_code
20989 CFI_ENDPROC
20990 -END(simd_coprocessor_error)
20991 +ENDPROC(simd_coprocessor_error)
20992
20993 ENTRY(device_not_available)
20994 RING0_INT_FRAME
20995 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
20996 pushl_cfi $do_device_not_available
20997 jmp error_code
20998 CFI_ENDPROC
20999 -END(device_not_available)
21000 +ENDPROC(device_not_available)
21001
21002 #ifdef CONFIG_PARAVIRT
21003 ENTRY(native_iret)
21004 iret
21005 _ASM_EXTABLE(native_iret, iret_exc)
21006 -END(native_iret)
21007 +ENDPROC(native_iret)
21008
21009 ENTRY(native_irq_enable_sysexit)
21010 sti
21011 sysexit
21012 -END(native_irq_enable_sysexit)
21013 +ENDPROC(native_irq_enable_sysexit)
21014 #endif
21015
21016 ENTRY(overflow)
21017 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21018 pushl_cfi $do_overflow
21019 jmp error_code
21020 CFI_ENDPROC
21021 -END(overflow)
21022 +ENDPROC(overflow)
21023
21024 ENTRY(bounds)
21025 RING0_INT_FRAME
21026 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21027 pushl_cfi $do_bounds
21028 jmp error_code
21029 CFI_ENDPROC
21030 -END(bounds)
21031 +ENDPROC(bounds)
21032
21033 ENTRY(invalid_op)
21034 RING0_INT_FRAME
21035 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21036 pushl_cfi $do_invalid_op
21037 jmp error_code
21038 CFI_ENDPROC
21039 -END(invalid_op)
21040 +ENDPROC(invalid_op)
21041
21042 ENTRY(coprocessor_segment_overrun)
21043 RING0_INT_FRAME
21044 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21045 pushl_cfi $do_coprocessor_segment_overrun
21046 jmp error_code
21047 CFI_ENDPROC
21048 -END(coprocessor_segment_overrun)
21049 +ENDPROC(coprocessor_segment_overrun)
21050
21051 ENTRY(invalid_TSS)
21052 RING0_EC_FRAME
21053 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21054 pushl_cfi $do_invalid_TSS
21055 jmp error_code
21056 CFI_ENDPROC
21057 -END(invalid_TSS)
21058 +ENDPROC(invalid_TSS)
21059
21060 ENTRY(segment_not_present)
21061 RING0_EC_FRAME
21062 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21063 pushl_cfi $do_segment_not_present
21064 jmp error_code
21065 CFI_ENDPROC
21066 -END(segment_not_present)
21067 +ENDPROC(segment_not_present)
21068
21069 ENTRY(stack_segment)
21070 RING0_EC_FRAME
21071 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21072 pushl_cfi $do_stack_segment
21073 jmp error_code
21074 CFI_ENDPROC
21075 -END(stack_segment)
21076 +ENDPROC(stack_segment)
21077
21078 ENTRY(alignment_check)
21079 RING0_EC_FRAME
21080 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21081 pushl_cfi $do_alignment_check
21082 jmp error_code
21083 CFI_ENDPROC
21084 -END(alignment_check)
21085 +ENDPROC(alignment_check)
21086
21087 ENTRY(divide_error)
21088 RING0_INT_FRAME
21089 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21090 pushl_cfi $do_divide_error
21091 jmp error_code
21092 CFI_ENDPROC
21093 -END(divide_error)
21094 +ENDPROC(divide_error)
21095
21096 #ifdef CONFIG_X86_MCE
21097 ENTRY(machine_check)
21098 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21099 pushl_cfi machine_check_vector
21100 jmp error_code
21101 CFI_ENDPROC
21102 -END(machine_check)
21103 +ENDPROC(machine_check)
21104 #endif
21105
21106 ENTRY(spurious_interrupt_bug)
21107 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21108 pushl_cfi $do_spurious_interrupt_bug
21109 jmp error_code
21110 CFI_ENDPROC
21111 -END(spurious_interrupt_bug)
21112 +ENDPROC(spurious_interrupt_bug)
21113 /*
21114 * End of kprobes section
21115 */
21116 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21117
21118 ENTRY(mcount)
21119 ret
21120 -END(mcount)
21121 +ENDPROC(mcount)
21122
21123 ENTRY(ftrace_caller)
21124 cmpl $0, function_trace_stop
21125 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21126 .globl ftrace_stub
21127 ftrace_stub:
21128 ret
21129 -END(ftrace_caller)
21130 +ENDPROC(ftrace_caller)
21131
21132 ENTRY(ftrace_regs_caller)
21133 pushf /* push flags before compare (in cs location) */
21134 @@ -1207,7 +1446,7 @@ trace:
21135 popl %ecx
21136 popl %eax
21137 jmp ftrace_stub
21138 -END(mcount)
21139 +ENDPROC(mcount)
21140 #endif /* CONFIG_DYNAMIC_FTRACE */
21141 #endif /* CONFIG_FUNCTION_TRACER */
21142
21143 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21144 popl %ecx
21145 popl %eax
21146 ret
21147 -END(ftrace_graph_caller)
21148 +ENDPROC(ftrace_graph_caller)
21149
21150 .globl return_to_handler
21151 return_to_handler:
21152 @@ -1281,15 +1520,18 @@ error_code:
21153 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21154 REG_TO_PTGS %ecx
21155 SET_KERNEL_GS %ecx
21156 - movl $(__USER_DS), %ecx
21157 + movl $(__KERNEL_DS), %ecx
21158 movl %ecx, %ds
21159 movl %ecx, %es
21160 +
21161 + pax_enter_kernel
21162 +
21163 TRACE_IRQS_OFF
21164 movl %esp,%eax # pt_regs pointer
21165 call *%edi
21166 jmp ret_from_exception
21167 CFI_ENDPROC
21168 -END(page_fault)
21169 +ENDPROC(page_fault)
21170
21171 /*
21172 * Debug traps and NMI can happen at the one SYSENTER instruction
21173 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21174 call do_debug
21175 jmp ret_from_exception
21176 CFI_ENDPROC
21177 -END(debug)
21178 +ENDPROC(debug)
21179
21180 /*
21181 * NMI is doubly nasty. It can happen _while_ we're handling
21182 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21183 xorl %edx,%edx # zero error code
21184 movl %esp,%eax # pt_regs pointer
21185 call do_nmi
21186 +
21187 + pax_exit_kernel
21188 +
21189 jmp restore_all_notrace
21190 CFI_ENDPROC
21191
21192 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21193 FIXUP_ESPFIX_STACK # %eax == %esp
21194 xorl %edx,%edx # zero error code
21195 call do_nmi
21196 +
21197 + pax_exit_kernel
21198 +
21199 RESTORE_REGS
21200 lss 12+4(%esp), %esp # back to espfix stack
21201 CFI_ADJUST_CFA_OFFSET -24
21202 jmp irq_return
21203 CFI_ENDPROC
21204 -END(nmi)
21205 +ENDPROC(nmi)
21206
21207 ENTRY(int3)
21208 RING0_INT_FRAME
21209 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21210 call do_int3
21211 jmp ret_from_exception
21212 CFI_ENDPROC
21213 -END(int3)
21214 +ENDPROC(int3)
21215
21216 ENTRY(general_protection)
21217 RING0_EC_FRAME
21218 pushl_cfi $do_general_protection
21219 jmp error_code
21220 CFI_ENDPROC
21221 -END(general_protection)
21222 +ENDPROC(general_protection)
21223
21224 #ifdef CONFIG_KVM_GUEST
21225 ENTRY(async_page_fault)
21226 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21227 pushl_cfi $do_async_page_fault
21228 jmp error_code
21229 CFI_ENDPROC
21230 -END(async_page_fault)
21231 +ENDPROC(async_page_fault)
21232 #endif
21233
21234 /*
21235 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21236 index 1b69951..8430a6d 100644
21237 --- a/arch/x86/kernel/entry_64.S
21238 +++ b/arch/x86/kernel/entry_64.S
21239 @@ -59,6 +59,8 @@
21240 #include <asm/context_tracking.h>
21241 #include <asm/smap.h>
21242 #include <linux/err.h>
21243 +#include <asm/pgtable.h>
21244 +#include <asm/alternative-asm.h>
21245
21246 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21247 #include <linux/elf-em.h>
21248 @@ -80,8 +82,9 @@
21249 #ifdef CONFIG_DYNAMIC_FTRACE
21250
21251 ENTRY(function_hook)
21252 + pax_force_retaddr
21253 retq
21254 -END(function_hook)
21255 +ENDPROC(function_hook)
21256
21257 /* skip is set if stack has been adjusted */
21258 .macro ftrace_caller_setup skip=0
21259 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21260 #endif
21261
21262 GLOBAL(ftrace_stub)
21263 + pax_force_retaddr
21264 retq
21265 -END(ftrace_caller)
21266 +ENDPROC(ftrace_caller)
21267
21268 ENTRY(ftrace_regs_caller)
21269 /* Save the current flags before compare (in SS location)*/
21270 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21271 popfq
21272 jmp ftrace_stub
21273
21274 -END(ftrace_regs_caller)
21275 +ENDPROC(ftrace_regs_caller)
21276
21277
21278 #else /* ! CONFIG_DYNAMIC_FTRACE */
21279 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21280 #endif
21281
21282 GLOBAL(ftrace_stub)
21283 + pax_force_retaddr
21284 retq
21285
21286 trace:
21287 @@ -225,12 +230,13 @@ trace:
21288 #endif
21289 subq $MCOUNT_INSN_SIZE, %rdi
21290
21291 + pax_force_fptr ftrace_trace_function
21292 call *ftrace_trace_function
21293
21294 MCOUNT_RESTORE_FRAME
21295
21296 jmp ftrace_stub
21297 -END(function_hook)
21298 +ENDPROC(function_hook)
21299 #endif /* CONFIG_DYNAMIC_FTRACE */
21300 #endif /* CONFIG_FUNCTION_TRACER */
21301
21302 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21303
21304 MCOUNT_RESTORE_FRAME
21305
21306 + pax_force_retaddr
21307 retq
21308 -END(ftrace_graph_caller)
21309 +ENDPROC(ftrace_graph_caller)
21310
21311 GLOBAL(return_to_handler)
21312 subq $24, %rsp
21313 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21314 movq 8(%rsp), %rdx
21315 movq (%rsp), %rax
21316 addq $24, %rsp
21317 + pax_force_fptr %rdi
21318 jmp *%rdi
21319 +ENDPROC(return_to_handler)
21320 #endif
21321
21322
21323 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21324 ENDPROC(native_usergs_sysret64)
21325 #endif /* CONFIG_PARAVIRT */
21326
21327 + .macro ljmpq sel, off
21328 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21329 + .byte 0x48; ljmp *1234f(%rip)
21330 + .pushsection .rodata
21331 + .align 16
21332 + 1234: .quad \off; .word \sel
21333 + .popsection
21334 +#else
21335 + pushq $\sel
21336 + pushq $\off
21337 + lretq
21338 +#endif
21339 + .endm
21340 +
21341 + .macro pax_enter_kernel
21342 + pax_set_fptr_mask
21343 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21344 + call pax_enter_kernel
21345 +#endif
21346 + .endm
21347 +
21348 + .macro pax_exit_kernel
21349 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21350 + call pax_exit_kernel
21351 +#endif
21352 +
21353 + .endm
21354 +
21355 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21356 +ENTRY(pax_enter_kernel)
21357 + pushq %rdi
21358 +
21359 +#ifdef CONFIG_PARAVIRT
21360 + PV_SAVE_REGS(CLBR_RDI)
21361 +#endif
21362 +
21363 +#ifdef CONFIG_PAX_KERNEXEC
21364 + GET_CR0_INTO_RDI
21365 + bts $16,%rdi
21366 + jnc 3f
21367 + mov %cs,%edi
21368 + cmp $__KERNEL_CS,%edi
21369 + jnz 2f
21370 +1:
21371 +#endif
21372 +
21373 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21374 + 661: jmp 111f
21375 + .pushsection .altinstr_replacement, "a"
21376 + 662: ASM_NOP2
21377 + .popsection
21378 + .pushsection .altinstructions, "a"
21379 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21380 + .popsection
21381 + GET_CR3_INTO_RDI
21382 + cmp $0,%dil
21383 + jnz 112f
21384 + mov $__KERNEL_DS,%edi
21385 + mov %edi,%ss
21386 + jmp 111f
21387 +112: cmp $1,%dil
21388 + jz 113f
21389 + ud2
21390 +113: sub $4097,%rdi
21391 + bts $63,%rdi
21392 + SET_RDI_INTO_CR3
21393 + mov $__UDEREF_KERNEL_DS,%edi
21394 + mov %edi,%ss
21395 +111:
21396 +#endif
21397 +
21398 +#ifdef CONFIG_PARAVIRT
21399 + PV_RESTORE_REGS(CLBR_RDI)
21400 +#endif
21401 +
21402 + popq %rdi
21403 + pax_force_retaddr
21404 + retq
21405 +
21406 +#ifdef CONFIG_PAX_KERNEXEC
21407 +2: ljmpq __KERNEL_CS,1b
21408 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21409 +4: SET_RDI_INTO_CR0
21410 + jmp 1b
21411 +#endif
21412 +ENDPROC(pax_enter_kernel)
21413 +
21414 +ENTRY(pax_exit_kernel)
21415 + pushq %rdi
21416 +
21417 +#ifdef CONFIG_PARAVIRT
21418 + PV_SAVE_REGS(CLBR_RDI)
21419 +#endif
21420 +
21421 +#ifdef CONFIG_PAX_KERNEXEC
21422 + mov %cs,%rdi
21423 + cmp $__KERNEXEC_KERNEL_CS,%edi
21424 + jz 2f
21425 + GET_CR0_INTO_RDI
21426 + bts $16,%rdi
21427 + jnc 4f
21428 +1:
21429 +#endif
21430 +
21431 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21432 + 661: jmp 111f
21433 + .pushsection .altinstr_replacement, "a"
21434 + 662: ASM_NOP2
21435 + .popsection
21436 + .pushsection .altinstructions, "a"
21437 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21438 + .popsection
21439 + mov %ss,%edi
21440 + cmp $__UDEREF_KERNEL_DS,%edi
21441 + jnz 111f
21442 + GET_CR3_INTO_RDI
21443 + cmp $0,%dil
21444 + jz 112f
21445 + ud2
21446 +112: add $4097,%rdi
21447 + bts $63,%rdi
21448 + SET_RDI_INTO_CR3
21449 + mov $__KERNEL_DS,%edi
21450 + mov %edi,%ss
21451 +111:
21452 +#endif
21453 +
21454 +#ifdef CONFIG_PARAVIRT
21455 + PV_RESTORE_REGS(CLBR_RDI);
21456 +#endif
21457 +
21458 + popq %rdi
21459 + pax_force_retaddr
21460 + retq
21461 +
21462 +#ifdef CONFIG_PAX_KERNEXEC
21463 +2: GET_CR0_INTO_RDI
21464 + btr $16,%rdi
21465 + jnc 4f
21466 + ljmpq __KERNEL_CS,3f
21467 +3: SET_RDI_INTO_CR0
21468 + jmp 1b
21469 +4: ud2
21470 + jmp 4b
21471 +#endif
21472 +ENDPROC(pax_exit_kernel)
21473 +#endif
21474 +
21475 + .macro pax_enter_kernel_user
21476 + pax_set_fptr_mask
21477 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21478 + call pax_enter_kernel_user
21479 +#endif
21480 + .endm
21481 +
21482 + .macro pax_exit_kernel_user
21483 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21484 + call pax_exit_kernel_user
21485 +#endif
21486 +#ifdef CONFIG_PAX_RANDKSTACK
21487 + pushq %rax
21488 + pushq %r11
21489 + call pax_randomize_kstack
21490 + popq %r11
21491 + popq %rax
21492 +#endif
21493 + .endm
21494 +
21495 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21496 +ENTRY(pax_enter_kernel_user)
21497 + pushq %rdi
21498 + pushq %rbx
21499 +
21500 +#ifdef CONFIG_PARAVIRT
21501 + PV_SAVE_REGS(CLBR_RDI)
21502 +#endif
21503 +
21504 + 661: jmp 111f
21505 + .pushsection .altinstr_replacement, "a"
21506 + 662: ASM_NOP2
21507 + .popsection
21508 + .pushsection .altinstructions, "a"
21509 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21510 + .popsection
21511 + GET_CR3_INTO_RDI
21512 + cmp $1,%dil
21513 + jnz 4f
21514 + sub $4097,%rdi
21515 + bts $63,%rdi
21516 + SET_RDI_INTO_CR3
21517 + jmp 3f
21518 +111:
21519 +
21520 + GET_CR3_INTO_RDI
21521 + mov %rdi,%rbx
21522 + add $__START_KERNEL_map,%rbx
21523 + sub phys_base(%rip),%rbx
21524 +
21525 +#ifdef CONFIG_PARAVIRT
21526 + cmpl $0, pv_info+PARAVIRT_enabled
21527 + jz 1f
21528 + pushq %rdi
21529 + i = 0
21530 + .rept USER_PGD_PTRS
21531 + mov i*8(%rbx),%rsi
21532 + mov $0,%sil
21533 + lea i*8(%rbx),%rdi
21534 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21535 + i = i + 1
21536 + .endr
21537 + popq %rdi
21538 + jmp 2f
21539 +1:
21540 +#endif
21541 +
21542 + i = 0
21543 + .rept USER_PGD_PTRS
21544 + movb $0,i*8(%rbx)
21545 + i = i + 1
21546 + .endr
21547 +
21548 +2: SET_RDI_INTO_CR3
21549 +
21550 +#ifdef CONFIG_PAX_KERNEXEC
21551 + GET_CR0_INTO_RDI
21552 + bts $16,%rdi
21553 + SET_RDI_INTO_CR0
21554 +#endif
21555 +
21556 +3:
21557 +
21558 +#ifdef CONFIG_PARAVIRT
21559 + PV_RESTORE_REGS(CLBR_RDI)
21560 +#endif
21561 +
21562 + popq %rbx
21563 + popq %rdi
21564 + pax_force_retaddr
21565 + retq
21566 +4: ud2
21567 +ENDPROC(pax_enter_kernel_user)
21568 +
21569 +ENTRY(pax_exit_kernel_user)
21570 + pushq %rdi
21571 + pushq %rbx
21572 +
21573 +#ifdef CONFIG_PARAVIRT
21574 + PV_SAVE_REGS(CLBR_RDI)
21575 +#endif
21576 +
21577 + GET_CR3_INTO_RDI
21578 + 661: jmp 1f
21579 + .pushsection .altinstr_replacement, "a"
21580 + 662: ASM_NOP2
21581 + .popsection
21582 + .pushsection .altinstructions, "a"
21583 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21584 + .popsection
21585 + cmp $0,%dil
21586 + jnz 3f
21587 + add $4097,%rdi
21588 + bts $63,%rdi
21589 + SET_RDI_INTO_CR3
21590 + jmp 2f
21591 +1:
21592 +
21593 + mov %rdi,%rbx
21594 +
21595 +#ifdef CONFIG_PAX_KERNEXEC
21596 + GET_CR0_INTO_RDI
21597 + btr $16,%rdi
21598 + jnc 3f
21599 + SET_RDI_INTO_CR0
21600 +#endif
21601 +
21602 + add $__START_KERNEL_map,%rbx
21603 + sub phys_base(%rip),%rbx
21604 +
21605 +#ifdef CONFIG_PARAVIRT
21606 + cmpl $0, pv_info+PARAVIRT_enabled
21607 + jz 1f
21608 + i = 0
21609 + .rept USER_PGD_PTRS
21610 + mov i*8(%rbx),%rsi
21611 + mov $0x67,%sil
21612 + lea i*8(%rbx),%rdi
21613 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21614 + i = i + 1
21615 + .endr
21616 + jmp 2f
21617 +1:
21618 +#endif
21619 +
21620 + i = 0
21621 + .rept USER_PGD_PTRS
21622 + movb $0x67,i*8(%rbx)
21623 + i = i + 1
21624 + .endr
21625 +2:
21626 +
21627 +#ifdef CONFIG_PARAVIRT
21628 + PV_RESTORE_REGS(CLBR_RDI)
21629 +#endif
21630 +
21631 + popq %rbx
21632 + popq %rdi
21633 + pax_force_retaddr
21634 + retq
21635 +3: ud2
21636 +ENDPROC(pax_exit_kernel_user)
21637 +#endif
21638 +
21639 + .macro pax_enter_kernel_nmi
21640 + pax_set_fptr_mask
21641 +
21642 +#ifdef CONFIG_PAX_KERNEXEC
21643 + GET_CR0_INTO_RDI
21644 + bts $16,%rdi
21645 + jc 110f
21646 + SET_RDI_INTO_CR0
21647 + or $2,%ebx
21648 +110:
21649 +#endif
21650 +
21651 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21652 + 661: jmp 111f
21653 + .pushsection .altinstr_replacement, "a"
21654 + 662: ASM_NOP2
21655 + .popsection
21656 + .pushsection .altinstructions, "a"
21657 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21658 + .popsection
21659 + GET_CR3_INTO_RDI
21660 + cmp $0,%dil
21661 + jz 111f
21662 + sub $4097,%rdi
21663 + or $4,%ebx
21664 + bts $63,%rdi
21665 + SET_RDI_INTO_CR3
21666 + mov $__UDEREF_KERNEL_DS,%edi
21667 + mov %edi,%ss
21668 +111:
21669 +#endif
21670 + .endm
21671 +
21672 + .macro pax_exit_kernel_nmi
21673 +#ifdef CONFIG_PAX_KERNEXEC
21674 + btr $1,%ebx
21675 + jnc 110f
21676 + GET_CR0_INTO_RDI
21677 + btr $16,%rdi
21678 + SET_RDI_INTO_CR0
21679 +110:
21680 +#endif
21681 +
21682 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21683 + btr $2,%ebx
21684 + jnc 111f
21685 + GET_CR3_INTO_RDI
21686 + add $4097,%rdi
21687 + bts $63,%rdi
21688 + SET_RDI_INTO_CR3
21689 + mov $__KERNEL_DS,%edi
21690 + mov %edi,%ss
21691 +111:
21692 +#endif
21693 + .endm
21694 +
21695 + .macro pax_erase_kstack
21696 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21697 + call pax_erase_kstack
21698 +#endif
21699 + .endm
21700 +
21701 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21702 +ENTRY(pax_erase_kstack)
21703 + pushq %rdi
21704 + pushq %rcx
21705 + pushq %rax
21706 + pushq %r11
21707 +
21708 + GET_THREAD_INFO(%r11)
21709 + mov TI_lowest_stack(%r11), %rdi
21710 + mov $-0xBEEF, %rax
21711 + std
21712 +
21713 +1: mov %edi, %ecx
21714 + and $THREAD_SIZE_asm - 1, %ecx
21715 + shr $3, %ecx
21716 + repne scasq
21717 + jecxz 2f
21718 +
21719 + cmp $2*8, %ecx
21720 + jc 2f
21721 +
21722 + mov $2*8, %ecx
21723 + repe scasq
21724 + jecxz 2f
21725 + jne 1b
21726 +
21727 +2: cld
21728 + mov %esp, %ecx
21729 + sub %edi, %ecx
21730 +
21731 + cmp $THREAD_SIZE_asm, %rcx
21732 + jb 3f
21733 + ud2
21734 +3:
21735 +
21736 + shr $3, %ecx
21737 + rep stosq
21738 +
21739 + mov TI_task_thread_sp0(%r11), %rdi
21740 + sub $256, %rdi
21741 + mov %rdi, TI_lowest_stack(%r11)
21742 +
21743 + popq %r11
21744 + popq %rax
21745 + popq %rcx
21746 + popq %rdi
21747 + pax_force_retaddr
21748 + ret
21749 +ENDPROC(pax_erase_kstack)
21750 +#endif
21751
21752 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21753 #ifdef CONFIG_TRACE_IRQFLAGS
21754 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21755 .endm
21756
21757 .macro UNFAKE_STACK_FRAME
21758 - addq $8*6, %rsp
21759 - CFI_ADJUST_CFA_OFFSET -(6*8)
21760 + addq $8*6 + ARG_SKIP, %rsp
21761 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21762 .endm
21763
21764 /*
21765 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21766 movq %rsp, %rsi
21767
21768 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21769 - testl $3, CS-RBP(%rsi)
21770 + testb $3, CS-RBP(%rsi)
21771 je 1f
21772 SWAPGS
21773 /*
21774 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21775 movq_cfi r15, R15+16
21776 movq %r11, 8(%rsp) /* return address */
21777 FIXUP_TOP_OF_STACK %r11, 16
21778 + pax_force_retaddr
21779 ret
21780 CFI_ENDPROC
21781 -END(save_rest)
21782 +ENDPROC(save_rest)
21783
21784 /* save complete stack frame */
21785 .pushsection .kprobes.text, "ax"
21786 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21787 js 1f /* negative -> in kernel */
21788 SWAPGS
21789 xorl %ebx,%ebx
21790 -1: ret
21791 +1: pax_force_retaddr_bts
21792 + ret
21793 CFI_ENDPROC
21794 -END(save_paranoid)
21795 +ENDPROC(save_paranoid)
21796 .popsection
21797
21798 /*
21799 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21800
21801 RESTORE_REST
21802
21803 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21804 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21805 jz 1f
21806
21807 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21808 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21809 RESTORE_REST
21810 jmp int_ret_from_sys_call
21811 CFI_ENDPROC
21812 -END(ret_from_fork)
21813 +ENDPROC(ret_from_fork)
21814
21815 /*
21816 * System call entry. Up to 6 arguments in registers are supported.
21817 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21818 ENTRY(system_call)
21819 CFI_STARTPROC simple
21820 CFI_SIGNAL_FRAME
21821 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21822 + CFI_DEF_CFA rsp,0
21823 CFI_REGISTER rip,rcx
21824 /*CFI_REGISTER rflags,r11*/
21825 SWAPGS_UNSAFE_STACK
21826 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21827
21828 movq %rsp,PER_CPU_VAR(old_rsp)
21829 movq PER_CPU_VAR(kernel_stack),%rsp
21830 + SAVE_ARGS 8*6,0
21831 + pax_enter_kernel_user
21832 +
21833 +#ifdef CONFIG_PAX_RANDKSTACK
21834 + pax_erase_kstack
21835 +#endif
21836 +
21837 /*
21838 * No need to follow this irqs off/on section - it's straight
21839 * and short:
21840 */
21841 ENABLE_INTERRUPTS(CLBR_NONE)
21842 - SAVE_ARGS 8,0
21843 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21844 movq %rcx,RIP-ARGOFFSET(%rsp)
21845 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21846 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21847 + GET_THREAD_INFO(%rcx)
21848 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21849 jnz tracesys
21850 system_call_fastpath:
21851 #if __SYSCALL_MASK == ~0
21852 @@ -640,7 +1082,7 @@ system_call_fastpath:
21853 cmpl $__NR_syscall_max,%eax
21854 #endif
21855 ja badsys
21856 - movq %r10,%rcx
21857 + movq R10-ARGOFFSET(%rsp),%rcx
21858 call *sys_call_table(,%rax,8) # XXX: rip relative
21859 movq %rax,RAX-ARGOFFSET(%rsp)
21860 /*
21861 @@ -654,10 +1096,13 @@ sysret_check:
21862 LOCKDEP_SYS_EXIT
21863 DISABLE_INTERRUPTS(CLBR_NONE)
21864 TRACE_IRQS_OFF
21865 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21866 + GET_THREAD_INFO(%rcx)
21867 + movl TI_flags(%rcx),%edx
21868 andl %edi,%edx
21869 jnz sysret_careful
21870 CFI_REMEMBER_STATE
21871 + pax_exit_kernel_user
21872 + pax_erase_kstack
21873 /*
21874 * sysretq will re-enable interrupts:
21875 */
21876 @@ -709,14 +1154,18 @@ badsys:
21877 * jump back to the normal fast path.
21878 */
21879 auditsys:
21880 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21881 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21882 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21883 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21884 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21885 movq %rax,%rsi /* 2nd arg: syscall number */
21886 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21887 call __audit_syscall_entry
21888 +
21889 + pax_erase_kstack
21890 +
21891 LOAD_ARGS 0 /* reload call-clobbered registers */
21892 + pax_set_fptr_mask
21893 jmp system_call_fastpath
21894
21895 /*
21896 @@ -737,7 +1186,7 @@ sysret_audit:
21897 /* Do syscall tracing */
21898 tracesys:
21899 #ifdef CONFIG_AUDITSYSCALL
21900 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21901 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21902 jz auditsys
21903 #endif
21904 SAVE_REST
21905 @@ -745,12 +1194,16 @@ tracesys:
21906 FIXUP_TOP_OF_STACK %rdi
21907 movq %rsp,%rdi
21908 call syscall_trace_enter
21909 +
21910 + pax_erase_kstack
21911 +
21912 /*
21913 * Reload arg registers from stack in case ptrace changed them.
21914 * We don't reload %rax because syscall_trace_enter() returned
21915 * the value it wants us to use in the table lookup.
21916 */
21917 LOAD_ARGS ARGOFFSET, 1
21918 + pax_set_fptr_mask
21919 RESTORE_REST
21920 #if __SYSCALL_MASK == ~0
21921 cmpq $__NR_syscall_max,%rax
21922 @@ -759,7 +1212,7 @@ tracesys:
21923 cmpl $__NR_syscall_max,%eax
21924 #endif
21925 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21926 - movq %r10,%rcx /* fixup for C */
21927 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21928 call *sys_call_table(,%rax,8)
21929 movq %rax,RAX-ARGOFFSET(%rsp)
21930 /* Use IRET because user could have changed frame */
21931 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
21932 andl %edi,%edx
21933 jnz int_careful
21934 andl $~TS_COMPAT,TI_status(%rcx)
21935 - jmp retint_swapgs
21936 + pax_exit_kernel_user
21937 + pax_erase_kstack
21938 + jmp retint_swapgs_pax
21939
21940 /* Either reschedule or signal or syscall exit tracking needed. */
21941 /* First do a reschedule test. */
21942 @@ -826,7 +1281,7 @@ int_restore_rest:
21943 TRACE_IRQS_OFF
21944 jmp int_with_check
21945 CFI_ENDPROC
21946 -END(system_call)
21947 +ENDPROC(system_call)
21948
21949 .macro FORK_LIKE func
21950 ENTRY(stub_\func)
21951 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
21952 DEFAULT_FRAME 0 8 /* offset 8: return address */
21953 call sys_\func
21954 RESTORE_TOP_OF_STACK %r11, 8
21955 + pax_force_retaddr
21956 ret $REST_SKIP /* pop extended registers */
21957 CFI_ENDPROC
21958 -END(stub_\func)
21959 +ENDPROC(stub_\func)
21960 .endm
21961
21962 .macro FIXED_FRAME label,func
21963 @@ -851,9 +1307,10 @@ ENTRY(\label)
21964 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
21965 call \func
21966 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
21967 + pax_force_retaddr
21968 ret
21969 CFI_ENDPROC
21970 -END(\label)
21971 +ENDPROC(\label)
21972 .endm
21973
21974 FORK_LIKE clone
21975 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
21976 movq_cfi_restore R12+8, r12
21977 movq_cfi_restore RBP+8, rbp
21978 movq_cfi_restore RBX+8, rbx
21979 + pax_force_retaddr
21980 ret $REST_SKIP /* pop extended registers */
21981 CFI_ENDPROC
21982 -END(ptregscall_common)
21983 +ENDPROC(ptregscall_common)
21984
21985 ENTRY(stub_execve)
21986 CFI_STARTPROC
21987 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
21988 RESTORE_REST
21989 jmp int_ret_from_sys_call
21990 CFI_ENDPROC
21991 -END(stub_execve)
21992 +ENDPROC(stub_execve)
21993
21994 /*
21995 * sigreturn is special because it needs to restore all registers on return.
21996 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
21997 RESTORE_REST
21998 jmp int_ret_from_sys_call
21999 CFI_ENDPROC
22000 -END(stub_rt_sigreturn)
22001 +ENDPROC(stub_rt_sigreturn)
22002
22003 #ifdef CONFIG_X86_X32_ABI
22004 ENTRY(stub_x32_rt_sigreturn)
22005 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22006 RESTORE_REST
22007 jmp int_ret_from_sys_call
22008 CFI_ENDPROC
22009 -END(stub_x32_rt_sigreturn)
22010 +ENDPROC(stub_x32_rt_sigreturn)
22011
22012 ENTRY(stub_x32_execve)
22013 CFI_STARTPROC
22014 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22015 RESTORE_REST
22016 jmp int_ret_from_sys_call
22017 CFI_ENDPROC
22018 -END(stub_x32_execve)
22019 +ENDPROC(stub_x32_execve)
22020
22021 #endif
22022
22023 @@ -967,7 +1425,7 @@ vector=vector+1
22024 2: jmp common_interrupt
22025 .endr
22026 CFI_ENDPROC
22027 -END(irq_entries_start)
22028 +ENDPROC(irq_entries_start)
22029
22030 .previous
22031 END(interrupt)
22032 @@ -987,6 +1445,16 @@ END(interrupt)
22033 subq $ORIG_RAX-RBP, %rsp
22034 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22035 SAVE_ARGS_IRQ
22036 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22037 + testb $3, CS(%rdi)
22038 + jnz 1f
22039 + pax_enter_kernel
22040 + jmp 2f
22041 +1: pax_enter_kernel_user
22042 +2:
22043 +#else
22044 + pax_enter_kernel
22045 +#endif
22046 call \func
22047 .endm
22048
22049 @@ -1019,7 +1487,7 @@ ret_from_intr:
22050
22051 exit_intr:
22052 GET_THREAD_INFO(%rcx)
22053 - testl $3,CS-ARGOFFSET(%rsp)
22054 + testb $3,CS-ARGOFFSET(%rsp)
22055 je retint_kernel
22056
22057 /* Interrupt came from user space */
22058 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22059 * The iretq could re-enable interrupts:
22060 */
22061 DISABLE_INTERRUPTS(CLBR_ANY)
22062 + pax_exit_kernel_user
22063 +retint_swapgs_pax:
22064 TRACE_IRQS_IRETQ
22065 SWAPGS
22066 jmp restore_args
22067
22068 retint_restore_args: /* return to kernel space */
22069 DISABLE_INTERRUPTS(CLBR_ANY)
22070 + pax_exit_kernel
22071 + pax_force_retaddr (RIP-ARGOFFSET)
22072 /*
22073 * The iretq could re-enable interrupts:
22074 */
22075 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22076 #endif
22077
22078 CFI_ENDPROC
22079 -END(common_interrupt)
22080 +ENDPROC(common_interrupt)
22081 /*
22082 * End of kprobes section
22083 */
22084 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22085 interrupt \do_sym
22086 jmp ret_from_intr
22087 CFI_ENDPROC
22088 -END(\sym)
22089 +ENDPROC(\sym)
22090 .endm
22091
22092 #ifdef CONFIG_TRACING
22093 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22094 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22095 call error_entry
22096 DEFAULT_FRAME 0
22097 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22098 + testb $3, CS(%rsp)
22099 + jnz 1f
22100 + pax_enter_kernel
22101 + jmp 2f
22102 +1: pax_enter_kernel_user
22103 +2:
22104 +#else
22105 + pax_enter_kernel
22106 +#endif
22107 movq %rsp,%rdi /* pt_regs pointer */
22108 xorl %esi,%esi /* no error code */
22109 call \do_sym
22110 jmp error_exit /* %ebx: no swapgs flag */
22111 CFI_ENDPROC
22112 -END(\sym)
22113 +ENDPROC(\sym)
22114 .endm
22115
22116 .macro paranoidzeroentry sym do_sym
22117 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22118 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22119 call save_paranoid
22120 TRACE_IRQS_OFF
22121 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22122 + testb $3, CS(%rsp)
22123 + jnz 1f
22124 + pax_enter_kernel
22125 + jmp 2f
22126 +1: pax_enter_kernel_user
22127 +2:
22128 +#else
22129 + pax_enter_kernel
22130 +#endif
22131 movq %rsp,%rdi /* pt_regs pointer */
22132 xorl %esi,%esi /* no error code */
22133 call \do_sym
22134 jmp paranoid_exit /* %ebx: no swapgs flag */
22135 CFI_ENDPROC
22136 -END(\sym)
22137 +ENDPROC(\sym)
22138 .endm
22139
22140 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22141 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22142 .macro paranoidzeroentry_ist sym do_sym ist
22143 ENTRY(\sym)
22144 INTR_FRAME
22145 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22146 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22147 call save_paranoid
22148 TRACE_IRQS_OFF_DEBUG
22149 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22150 + testb $3, CS(%rsp)
22151 + jnz 1f
22152 + pax_enter_kernel
22153 + jmp 2f
22154 +1: pax_enter_kernel_user
22155 +2:
22156 +#else
22157 + pax_enter_kernel
22158 +#endif
22159 movq %rsp,%rdi /* pt_regs pointer */
22160 xorl %esi,%esi /* no error code */
22161 +#ifdef CONFIG_SMP
22162 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22163 + lea init_tss(%r12), %r12
22164 +#else
22165 + lea init_tss(%rip), %r12
22166 +#endif
22167 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22168 call \do_sym
22169 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22170 jmp paranoid_exit /* %ebx: no swapgs flag */
22171 CFI_ENDPROC
22172 -END(\sym)
22173 +ENDPROC(\sym)
22174 .endm
22175
22176 .macro errorentry sym do_sym
22177 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22178 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22179 call error_entry
22180 DEFAULT_FRAME 0
22181 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22182 + testb $3, CS(%rsp)
22183 + jnz 1f
22184 + pax_enter_kernel
22185 + jmp 2f
22186 +1: pax_enter_kernel_user
22187 +2:
22188 +#else
22189 + pax_enter_kernel
22190 +#endif
22191 movq %rsp,%rdi /* pt_regs pointer */
22192 movq ORIG_RAX(%rsp),%rsi /* get error code */
22193 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22194 call \do_sym
22195 jmp error_exit /* %ebx: no swapgs flag */
22196 CFI_ENDPROC
22197 -END(\sym)
22198 +ENDPROC(\sym)
22199 .endm
22200
22201 /* error code is on the stack already */
22202 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22203 call save_paranoid
22204 DEFAULT_FRAME 0
22205 TRACE_IRQS_OFF
22206 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22207 + testb $3, CS(%rsp)
22208 + jnz 1f
22209 + pax_enter_kernel
22210 + jmp 2f
22211 +1: pax_enter_kernel_user
22212 +2:
22213 +#else
22214 + pax_enter_kernel
22215 +#endif
22216 movq %rsp,%rdi /* pt_regs pointer */
22217 movq ORIG_RAX(%rsp),%rsi /* get error code */
22218 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22219 call \do_sym
22220 jmp paranoid_exit /* %ebx: no swapgs flag */
22221 CFI_ENDPROC
22222 -END(\sym)
22223 +ENDPROC(\sym)
22224 .endm
22225
22226 zeroentry divide_error do_divide_error
22227 @@ -1342,9 +1870,10 @@ gs_change:
22228 2: mfence /* workaround */
22229 SWAPGS
22230 popfq_cfi
22231 + pax_force_retaddr
22232 ret
22233 CFI_ENDPROC
22234 -END(native_load_gs_index)
22235 +ENDPROC(native_load_gs_index)
22236
22237 _ASM_EXTABLE(gs_change,bad_gs)
22238 .section .fixup,"ax"
22239 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22240 CFI_DEF_CFA_REGISTER rsp
22241 CFI_ADJUST_CFA_OFFSET -8
22242 decl PER_CPU_VAR(irq_count)
22243 + pax_force_retaddr
22244 ret
22245 CFI_ENDPROC
22246 -END(call_softirq)
22247 +ENDPROC(call_softirq)
22248
22249 #ifdef CONFIG_XEN
22250 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22251 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22252 decl PER_CPU_VAR(irq_count)
22253 jmp error_exit
22254 CFI_ENDPROC
22255 -END(xen_do_hypervisor_callback)
22256 +ENDPROC(xen_do_hypervisor_callback)
22257
22258 /*
22259 * Hypervisor uses this for application faults while it executes.
22260 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22261 SAVE_ALL
22262 jmp error_exit
22263 CFI_ENDPROC
22264 -END(xen_failsafe_callback)
22265 +ENDPROC(xen_failsafe_callback)
22266
22267 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22268 xen_hvm_callback_vector xen_evtchn_do_upcall
22269 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22270 DEFAULT_FRAME
22271 DISABLE_INTERRUPTS(CLBR_NONE)
22272 TRACE_IRQS_OFF_DEBUG
22273 - testl %ebx,%ebx /* swapgs needed? */
22274 + testl $1,%ebx /* swapgs needed? */
22275 jnz paranoid_restore
22276 - testl $3,CS(%rsp)
22277 + testb $3,CS(%rsp)
22278 jnz paranoid_userspace
22279 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22280 + pax_exit_kernel
22281 + TRACE_IRQS_IRETQ 0
22282 + SWAPGS_UNSAFE_STACK
22283 + RESTORE_ALL 8
22284 + pax_force_retaddr_bts
22285 + jmp irq_return
22286 +#endif
22287 paranoid_swapgs:
22288 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22289 + pax_exit_kernel_user
22290 +#else
22291 + pax_exit_kernel
22292 +#endif
22293 TRACE_IRQS_IRETQ 0
22294 SWAPGS_UNSAFE_STACK
22295 RESTORE_ALL 8
22296 jmp irq_return
22297 paranoid_restore:
22298 + pax_exit_kernel
22299 TRACE_IRQS_IRETQ_DEBUG 0
22300 RESTORE_ALL 8
22301 + pax_force_retaddr_bts
22302 jmp irq_return
22303 paranoid_userspace:
22304 GET_THREAD_INFO(%rcx)
22305 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22306 TRACE_IRQS_OFF
22307 jmp paranoid_userspace
22308 CFI_ENDPROC
22309 -END(paranoid_exit)
22310 +ENDPROC(paranoid_exit)
22311
22312 /*
22313 * Exception entry point. This expects an error code/orig_rax on the stack.
22314 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22315 movq_cfi r14, R14+8
22316 movq_cfi r15, R15+8
22317 xorl %ebx,%ebx
22318 - testl $3,CS+8(%rsp)
22319 + testb $3,CS+8(%rsp)
22320 je error_kernelspace
22321 error_swapgs:
22322 SWAPGS
22323 error_sti:
22324 TRACE_IRQS_OFF
22325 + pax_force_retaddr_bts
22326 ret
22327
22328 /*
22329 @@ -1622,7 +2168,7 @@ bstep_iret:
22330 movq %rcx,RIP+8(%rsp)
22331 jmp error_swapgs
22332 CFI_ENDPROC
22333 -END(error_entry)
22334 +ENDPROC(error_entry)
22335
22336
22337 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22338 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22339 DISABLE_INTERRUPTS(CLBR_NONE)
22340 TRACE_IRQS_OFF
22341 GET_THREAD_INFO(%rcx)
22342 - testl %eax,%eax
22343 + testl $1,%eax
22344 jne retint_kernel
22345 LOCKDEP_SYS_EXIT_IRQ
22346 movl TI_flags(%rcx),%edx
22347 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22348 jnz retint_careful
22349 jmp retint_swapgs
22350 CFI_ENDPROC
22351 -END(error_exit)
22352 +ENDPROC(error_exit)
22353
22354 /*
22355 * Test if a given stack is an NMI stack or not.
22356 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22357 * If %cs was not the kernel segment, then the NMI triggered in user
22358 * space, which means it is definitely not nested.
22359 */
22360 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22361 + je 1f
22362 cmpl $__KERNEL_CS, 16(%rsp)
22363 jne first_nmi
22364 -
22365 +1:
22366 /*
22367 * Check the special variable on the stack to see if NMIs are
22368 * executing.
22369 @@ -1736,8 +2284,7 @@ nested_nmi:
22370
22371 1:
22372 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22373 - leaq -1*8(%rsp), %rdx
22374 - movq %rdx, %rsp
22375 + subq $8, %rsp
22376 CFI_ADJUST_CFA_OFFSET 1*8
22377 leaq -10*8(%rsp), %rdx
22378 pushq_cfi $__KERNEL_DS
22379 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22380 CFI_RESTORE rdx
22381
22382 /* No need to check faults here */
22383 +# pax_force_retaddr_bts
22384 INTERRUPT_RETURN
22385
22386 CFI_RESTORE_STATE
22387 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22388 */
22389 movq %cr2, %r12
22390
22391 + pax_enter_kernel_nmi
22392 +
22393 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22394 movq %rsp,%rdi
22395 movq $-1,%rsi
22396 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22397 movq %r12, %cr2
22398 1:
22399
22400 - testl %ebx,%ebx /* swapgs needed? */
22401 + testl $1,%ebx /* swapgs needed? */
22402 jnz nmi_restore
22403 nmi_swapgs:
22404 SWAPGS_UNSAFE_STACK
22405 nmi_restore:
22406 + pax_exit_kernel_nmi
22407 /* Pop the extra iret frame at once */
22408 RESTORE_ALL 6*8
22409 + testb $3, 8(%rsp)
22410 + jnz 1f
22411 + pax_force_retaddr_bts
22412 +1:
22413
22414 /* Clear the NMI executing stack variable */
22415 movq $0, 5*8(%rsp)
22416 jmp irq_return
22417 CFI_ENDPROC
22418 -END(nmi)
22419 +ENDPROC(nmi)
22420
22421 ENTRY(ignore_sysret)
22422 CFI_STARTPROC
22423 mov $-ENOSYS,%eax
22424 sysret
22425 CFI_ENDPROC
22426 -END(ignore_sysret)
22427 +ENDPROC(ignore_sysret)
22428
22429 /*
22430 * End of kprobes section
22431 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22432 index 42a392a..fbbd930 100644
22433 --- a/arch/x86/kernel/ftrace.c
22434 +++ b/arch/x86/kernel/ftrace.c
22435 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22436 {
22437 unsigned char replaced[MCOUNT_INSN_SIZE];
22438
22439 + ip = ktla_ktva(ip);
22440 +
22441 /*
22442 * Note: Due to modules and __init, code can
22443 * disappear and change, we need to protect against faulting
22444 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22445 unsigned char old[MCOUNT_INSN_SIZE], *new;
22446 int ret;
22447
22448 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22449 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22450 new = ftrace_call_replace(ip, (unsigned long)func);
22451
22452 /* See comment above by declaration of modifying_ftrace_code */
22453 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22454 /* Also update the regs callback function */
22455 if (!ret) {
22456 ip = (unsigned long)(&ftrace_regs_call);
22457 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22458 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22459 new = ftrace_call_replace(ip, (unsigned long)func);
22460 ret = ftrace_modify_code(ip, old, new);
22461 }
22462 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22463 * kernel identity mapping to modify code.
22464 */
22465 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22466 - ip = (unsigned long)__va(__pa_symbol(ip));
22467 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22468
22469 return probe_kernel_write((void *)ip, val, size);
22470 }
22471 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22472 unsigned char replaced[MCOUNT_INSN_SIZE];
22473 unsigned char brk = BREAKPOINT_INSTRUCTION;
22474
22475 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22476 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22477 return -EFAULT;
22478
22479 /* Make sure it is what we expect it to be */
22480 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22481 return ret;
22482
22483 fail_update:
22484 - probe_kernel_write((void *)ip, &old_code[0], 1);
22485 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22486 goto out;
22487 }
22488
22489 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22490 {
22491 unsigned char code[MCOUNT_INSN_SIZE];
22492
22493 + ip = ktla_ktva(ip);
22494 +
22495 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22496 return -EFAULT;
22497
22498 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22499 index 55b6761..a6456fc 100644
22500 --- a/arch/x86/kernel/head64.c
22501 +++ b/arch/x86/kernel/head64.c
22502 @@ -67,12 +67,12 @@ again:
22503 pgd = *pgd_p;
22504
22505 /*
22506 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22507 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22508 + * The use of __early_va rather than __va here is critical:
22509 + * __va would point us back into the dynamic
22510 * range and we might end up looping forever...
22511 */
22512 if (pgd)
22513 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22514 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22515 else {
22516 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22517 reset_early_page_tables();
22518 @@ -82,13 +82,13 @@ again:
22519 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22520 for (i = 0; i < PTRS_PER_PUD; i++)
22521 pud_p[i] = 0;
22522 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22523 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22524 }
22525 pud_p += pud_index(address);
22526 pud = *pud_p;
22527
22528 if (pud)
22529 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22530 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22531 else {
22532 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22533 reset_early_page_tables();
22534 @@ -98,7 +98,7 @@ again:
22535 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22536 for (i = 0; i < PTRS_PER_PMD; i++)
22537 pmd_p[i] = 0;
22538 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22539 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22540 }
22541 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22542 pmd_p[pmd_index(address)] = pmd;
22543 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22544 if (console_loglevel == 10)
22545 early_printk("Kernel alive\n");
22546
22547 - clear_page(init_level4_pgt);
22548 /* set init_level4_pgt kernel high mapping*/
22549 init_level4_pgt[511] = early_level4_pgt[511];
22550
22551 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22552 index 5dd87a8..d68b3f4 100644
22553 --- a/arch/x86/kernel/head_32.S
22554 +++ b/arch/x86/kernel/head_32.S
22555 @@ -26,6 +26,12 @@
22556 /* Physical address */
22557 #define pa(X) ((X) - __PAGE_OFFSET)
22558
22559 +#ifdef CONFIG_PAX_KERNEXEC
22560 +#define ta(X) (X)
22561 +#else
22562 +#define ta(X) ((X) - __PAGE_OFFSET)
22563 +#endif
22564 +
22565 /*
22566 * References to members of the new_cpu_data structure.
22567 */
22568 @@ -55,11 +61,7 @@
22569 * and small than max_low_pfn, otherwise will waste some page table entries
22570 */
22571
22572 -#if PTRS_PER_PMD > 1
22573 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22574 -#else
22575 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22576 -#endif
22577 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22578
22579 /* Number of possible pages in the lowmem region */
22580 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22581 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22582 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22583
22584 /*
22585 + * Real beginning of normal "text" segment
22586 + */
22587 +ENTRY(stext)
22588 +ENTRY(_stext)
22589 +
22590 +/*
22591 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22592 * %esi points to the real-mode code as a 32-bit pointer.
22593 * CS and DS must be 4 GB flat segments, but we don't depend on
22594 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22595 * can.
22596 */
22597 __HEAD
22598 +
22599 +#ifdef CONFIG_PAX_KERNEXEC
22600 + jmp startup_32
22601 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22602 +.fill PAGE_SIZE-5,1,0xcc
22603 +#endif
22604 +
22605 ENTRY(startup_32)
22606 movl pa(stack_start),%ecx
22607
22608 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22609 2:
22610 leal -__PAGE_OFFSET(%ecx),%esp
22611
22612 +#ifdef CONFIG_SMP
22613 + movl $pa(cpu_gdt_table),%edi
22614 + movl $__per_cpu_load,%eax
22615 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22616 + rorl $16,%eax
22617 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22618 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22619 + movl $__per_cpu_end - 1,%eax
22620 + subl $__per_cpu_start,%eax
22621 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22622 +#endif
22623 +
22624 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22625 + movl $NR_CPUS,%ecx
22626 + movl $pa(cpu_gdt_table),%edi
22627 +1:
22628 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22629 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22630 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22631 + addl $PAGE_SIZE_asm,%edi
22632 + loop 1b
22633 +#endif
22634 +
22635 +#ifdef CONFIG_PAX_KERNEXEC
22636 + movl $pa(boot_gdt),%edi
22637 + movl $__LOAD_PHYSICAL_ADDR,%eax
22638 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22639 + rorl $16,%eax
22640 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22641 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22642 + rorl $16,%eax
22643 +
22644 + ljmp $(__BOOT_CS),$1f
22645 +1:
22646 +
22647 + movl $NR_CPUS,%ecx
22648 + movl $pa(cpu_gdt_table),%edi
22649 + addl $__PAGE_OFFSET,%eax
22650 +1:
22651 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22652 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22653 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22654 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22655 + rorl $16,%eax
22656 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22657 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22658 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22659 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22660 + rorl $16,%eax
22661 + addl $PAGE_SIZE_asm,%edi
22662 + loop 1b
22663 +#endif
22664 +
22665 /*
22666 * Clear BSS first so that there are no surprises...
22667 */
22668 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22669 movl %eax, pa(max_pfn_mapped)
22670
22671 /* Do early initialization of the fixmap area */
22672 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22673 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22674 +#ifdef CONFIG_COMPAT_VDSO
22675 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22676 +#else
22677 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22678 +#endif
22679 #else /* Not PAE */
22680
22681 page_pde_offset = (__PAGE_OFFSET >> 20);
22682 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22683 movl %eax, pa(max_pfn_mapped)
22684
22685 /* Do early initialization of the fixmap area */
22686 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22687 - movl %eax,pa(initial_page_table+0xffc)
22688 +#ifdef CONFIG_COMPAT_VDSO
22689 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22690 +#else
22691 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22692 +#endif
22693 #endif
22694
22695 #ifdef CONFIG_PARAVIRT
22696 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22697 cmpl $num_subarch_entries, %eax
22698 jae bad_subarch
22699
22700 - movl pa(subarch_entries)(,%eax,4), %eax
22701 - subl $__PAGE_OFFSET, %eax
22702 - jmp *%eax
22703 + jmp *pa(subarch_entries)(,%eax,4)
22704
22705 bad_subarch:
22706 WEAK(lguest_entry)
22707 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22708 __INITDATA
22709
22710 subarch_entries:
22711 - .long default_entry /* normal x86/PC */
22712 - .long lguest_entry /* lguest hypervisor */
22713 - .long xen_entry /* Xen hypervisor */
22714 - .long default_entry /* Moorestown MID */
22715 + .long ta(default_entry) /* normal x86/PC */
22716 + .long ta(lguest_entry) /* lguest hypervisor */
22717 + .long ta(xen_entry) /* Xen hypervisor */
22718 + .long ta(default_entry) /* Moorestown MID */
22719 num_subarch_entries = (. - subarch_entries) / 4
22720 .previous
22721 #else
22722 @@ -354,6 +426,7 @@ default_entry:
22723 movl pa(mmu_cr4_features),%eax
22724 movl %eax,%cr4
22725
22726 +#ifdef CONFIG_X86_PAE
22727 testb $X86_CR4_PAE, %al # check if PAE is enabled
22728 jz enable_paging
22729
22730 @@ -382,6 +455,9 @@ default_entry:
22731 /* Make changes effective */
22732 wrmsr
22733
22734 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22735 +#endif
22736 +
22737 enable_paging:
22738
22739 /*
22740 @@ -449,14 +525,20 @@ is486:
22741 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22742 movl %eax,%ss # after changing gdt.
22743
22744 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22745 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22746 movl %eax,%ds
22747 movl %eax,%es
22748
22749 movl $(__KERNEL_PERCPU), %eax
22750 movl %eax,%fs # set this cpu's percpu
22751
22752 +#ifdef CONFIG_CC_STACKPROTECTOR
22753 movl $(__KERNEL_STACK_CANARY),%eax
22754 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22755 + movl $(__USER_DS),%eax
22756 +#else
22757 + xorl %eax,%eax
22758 +#endif
22759 movl %eax,%gs
22760
22761 xorl %eax,%eax # Clear LDT
22762 @@ -512,8 +594,11 @@ setup_once:
22763 * relocation. Manually set base address in stack canary
22764 * segment descriptor.
22765 */
22766 - movl $gdt_page,%eax
22767 + movl $cpu_gdt_table,%eax
22768 movl $stack_canary,%ecx
22769 +#ifdef CONFIG_SMP
22770 + addl $__per_cpu_load,%ecx
22771 +#endif
22772 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22773 shrl $16, %ecx
22774 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22775 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22776 /* This is global to keep gas from relaxing the jumps */
22777 ENTRY(early_idt_handler)
22778 cld
22779 - cmpl $2,%ss:early_recursion_flag
22780 + cmpl $1,%ss:early_recursion_flag
22781 je hlt_loop
22782 incl %ss:early_recursion_flag
22783
22784 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22785 pushl (20+6*4)(%esp) /* trapno */
22786 pushl $fault_msg
22787 call printk
22788 -#endif
22789 call dump_stack
22790 +#endif
22791 hlt_loop:
22792 hlt
22793 jmp hlt_loop
22794 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22795 /* This is the default interrupt "handler" :-) */
22796 ALIGN
22797 ignore_int:
22798 - cld
22799 #ifdef CONFIG_PRINTK
22800 + cmpl $2,%ss:early_recursion_flag
22801 + je hlt_loop
22802 + incl %ss:early_recursion_flag
22803 + cld
22804 pushl %eax
22805 pushl %ecx
22806 pushl %edx
22807 @@ -612,9 +700,6 @@ ignore_int:
22808 movl $(__KERNEL_DS),%eax
22809 movl %eax,%ds
22810 movl %eax,%es
22811 - cmpl $2,early_recursion_flag
22812 - je hlt_loop
22813 - incl early_recursion_flag
22814 pushl 16(%esp)
22815 pushl 24(%esp)
22816 pushl 32(%esp)
22817 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22818 /*
22819 * BSS section
22820 */
22821 -__PAGE_ALIGNED_BSS
22822 - .align PAGE_SIZE
22823 #ifdef CONFIG_X86_PAE
22824 +.section .initial_pg_pmd,"a",@progbits
22825 initial_pg_pmd:
22826 .fill 1024*KPMDS,4,0
22827 #else
22828 +.section .initial_page_table,"a",@progbits
22829 ENTRY(initial_page_table)
22830 .fill 1024,4,0
22831 #endif
22832 +.section .initial_pg_fixmap,"a",@progbits
22833 initial_pg_fixmap:
22834 .fill 1024,4,0
22835 +.section .empty_zero_page,"a",@progbits
22836 ENTRY(empty_zero_page)
22837 .fill 4096,1,0
22838 +.section .swapper_pg_dir,"a",@progbits
22839 ENTRY(swapper_pg_dir)
22840 +#ifdef CONFIG_X86_PAE
22841 + .fill 4,8,0
22842 +#else
22843 .fill 1024,4,0
22844 +#endif
22845
22846 /*
22847 * This starts the data section.
22848 */
22849 #ifdef CONFIG_X86_PAE
22850 -__PAGE_ALIGNED_DATA
22851 - /* Page-aligned for the benefit of paravirt? */
22852 - .align PAGE_SIZE
22853 +.section .initial_page_table,"a",@progbits
22854 ENTRY(initial_page_table)
22855 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22856 # if KPMDS == 3
22857 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22858 # error "Kernel PMDs should be 1, 2 or 3"
22859 # endif
22860 .align PAGE_SIZE /* needs to be page-sized too */
22861 +
22862 +#ifdef CONFIG_PAX_PER_CPU_PGD
22863 +ENTRY(cpu_pgd)
22864 + .rept 2*NR_CPUS
22865 + .fill 4,8,0
22866 + .endr
22867 +#endif
22868 +
22869 #endif
22870
22871 .data
22872 .balign 4
22873 ENTRY(stack_start)
22874 - .long init_thread_union+THREAD_SIZE
22875 + .long init_thread_union+THREAD_SIZE-8
22876
22877 __INITRODATA
22878 int_msg:
22879 @@ -722,7 +820,7 @@ fault_msg:
22880 * segment size, and 32-bit linear address value:
22881 */
22882
22883 - .data
22884 +.section .rodata,"a",@progbits
22885 .globl boot_gdt_descr
22886 .globl idt_descr
22887
22888 @@ -731,7 +829,7 @@ fault_msg:
22889 .word 0 # 32 bit align gdt_desc.address
22890 boot_gdt_descr:
22891 .word __BOOT_DS+7
22892 - .long boot_gdt - __PAGE_OFFSET
22893 + .long pa(boot_gdt)
22894
22895 .word 0 # 32-bit align idt_desc.address
22896 idt_descr:
22897 @@ -742,7 +840,7 @@ idt_descr:
22898 .word 0 # 32 bit align gdt_desc.address
22899 ENTRY(early_gdt_descr)
22900 .word GDT_ENTRIES*8-1
22901 - .long gdt_page /* Overwritten for secondary CPUs */
22902 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22903
22904 /*
22905 * The boot_gdt must mirror the equivalent in setup.S and is
22906 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22907 .align L1_CACHE_BYTES
22908 ENTRY(boot_gdt)
22909 .fill GDT_ENTRY_BOOT_CS,8,0
22910 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22911 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22912 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22913 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22914 +
22915 + .align PAGE_SIZE_asm
22916 +ENTRY(cpu_gdt_table)
22917 + .rept NR_CPUS
22918 + .quad 0x0000000000000000 /* NULL descriptor */
22919 + .quad 0x0000000000000000 /* 0x0b reserved */
22920 + .quad 0x0000000000000000 /* 0x13 reserved */
22921 + .quad 0x0000000000000000 /* 0x1b reserved */
22922 +
22923 +#ifdef CONFIG_PAX_KERNEXEC
22924 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22925 +#else
22926 + .quad 0x0000000000000000 /* 0x20 unused */
22927 +#endif
22928 +
22929 + .quad 0x0000000000000000 /* 0x28 unused */
22930 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22931 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22932 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22933 + .quad 0x0000000000000000 /* 0x4b reserved */
22934 + .quad 0x0000000000000000 /* 0x53 reserved */
22935 + .quad 0x0000000000000000 /* 0x5b reserved */
22936 +
22937 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
22938 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
22939 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
22940 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
22941 +
22942 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
22943 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
22944 +
22945 + /*
22946 + * Segments used for calling PnP BIOS have byte granularity.
22947 + * The code segments and data segments have fixed 64k limits,
22948 + * the transfer segment sizes are set at run time.
22949 + */
22950 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
22951 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
22952 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
22953 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
22954 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
22955 +
22956 + /*
22957 + * The APM segments have byte granularity and their bases
22958 + * are set at run time. All have 64k limits.
22959 + */
22960 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
22961 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
22962 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
22963 +
22964 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
22965 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
22966 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
22967 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
22968 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
22969 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
22970 +
22971 + /* Be sure this is zeroed to avoid false validations in Xen */
22972 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
22973 + .endr
22974 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
22975 index e1aabdb..73dcad8 100644
22976 --- a/arch/x86/kernel/head_64.S
22977 +++ b/arch/x86/kernel/head_64.S
22978 @@ -20,6 +20,8 @@
22979 #include <asm/processor-flags.h>
22980 #include <asm/percpu.h>
22981 #include <asm/nops.h>
22982 +#include <asm/cpufeature.h>
22983 +#include <asm/alternative-asm.h>
22984
22985 #ifdef CONFIG_PARAVIRT
22986 #include <asm/asm-offsets.h>
22987 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
22988 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
22989 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
22990 L3_START_KERNEL = pud_index(__START_KERNEL_map)
22991 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
22992 +L3_VMALLOC_START = pud_index(VMALLOC_START)
22993 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
22994 +L3_VMALLOC_END = pud_index(VMALLOC_END)
22995 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
22996 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
22997
22998 .text
22999 __HEAD
23000 @@ -89,11 +97,23 @@ startup_64:
23001 * Fixup the physical addresses in the page table
23002 */
23003 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23004 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23005 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23006 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23007 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23008 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23009
23010 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23011 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23012 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23013 +#ifndef CONFIG_XEN
23014 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23015 +#endif
23016
23017 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23018 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23019 +
23020 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23021 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23022 +
23023 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23024
23025 /*
23026 * Set up the identity mapping for the switchover. These
23027 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23028 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23029 1:
23030
23031 - /* Enable PAE mode and PGE */
23032 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23033 + /* Enable PAE mode and PSE/PGE */
23034 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23035 movq %rcx, %cr4
23036
23037 /* Setup early boot stage 4 level pagetables. */
23038 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23039 movl $MSR_EFER, %ecx
23040 rdmsr
23041 btsl $_EFER_SCE, %eax /* Enable System Call */
23042 - btl $20,%edi /* No Execute supported? */
23043 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23044 jnc 1f
23045 btsl $_EFER_NX, %eax
23046 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23047 + leaq init_level4_pgt(%rip), %rdi
23048 +#ifndef CONFIG_EFI
23049 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23050 +#endif
23051 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23052 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23053 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23054 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23055 1: wrmsr /* Make changes effective */
23056
23057 /* Setup cr0 */
23058 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23059 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23060 * address given in m16:64.
23061 */
23062 + pax_set_fptr_mask
23063 movq initial_code(%rip),%rax
23064 pushq $0 # fake return address to stop unwinder
23065 pushq $__KERNEL_CS # set correct cs
23066 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23067 call dump_stack
23068 #ifdef CONFIG_KALLSYMS
23069 leaq early_idt_ripmsg(%rip),%rdi
23070 - movq 40(%rsp),%rsi # %rip again
23071 + movq 88(%rsp),%rsi # %rip again
23072 call __print_symbol
23073 #endif
23074 #endif /* EARLY_PRINTK */
23075 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23076 early_recursion_flag:
23077 .long 0
23078
23079 + .section .rodata,"a",@progbits
23080 #ifdef CONFIG_EARLY_PRINTK
23081 early_idt_msg:
23082 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23083 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23084 NEXT_PAGE(early_dynamic_pgts)
23085 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23086
23087 - .data
23088 + .section .rodata,"a",@progbits
23089
23090 -#ifndef CONFIG_XEN
23091 NEXT_PAGE(init_level4_pgt)
23092 - .fill 512,8,0
23093 -#else
23094 -NEXT_PAGE(init_level4_pgt)
23095 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23096 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23097 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23098 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23099 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23100 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23101 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23102 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23103 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23104 .org init_level4_pgt + L4_START_KERNEL*8, 0
23105 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23106 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23107
23108 +#ifdef CONFIG_PAX_PER_CPU_PGD
23109 +NEXT_PAGE(cpu_pgd)
23110 + .rept 2*NR_CPUS
23111 + .fill 512,8,0
23112 + .endr
23113 +#endif
23114 +
23115 NEXT_PAGE(level3_ident_pgt)
23116 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23117 +#ifdef CONFIG_XEN
23118 .fill 511, 8, 0
23119 +#else
23120 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23121 + .fill 510,8,0
23122 +#endif
23123 +
23124 +NEXT_PAGE(level3_vmalloc_start_pgt)
23125 + .fill 512,8,0
23126 +
23127 +NEXT_PAGE(level3_vmalloc_end_pgt)
23128 + .fill 512,8,0
23129 +
23130 +NEXT_PAGE(level3_vmemmap_pgt)
23131 + .fill L3_VMEMMAP_START,8,0
23132 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23133 +
23134 NEXT_PAGE(level2_ident_pgt)
23135 - /* Since I easily can, map the first 1G.
23136 + /* Since I easily can, map the first 2G.
23137 * Don't set NX because code runs from these pages.
23138 */
23139 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23140 -#endif
23141 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23142
23143 NEXT_PAGE(level3_kernel_pgt)
23144 .fill L3_START_KERNEL,8,0
23145 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23146 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23147 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23148
23149 +NEXT_PAGE(level2_vmemmap_pgt)
23150 + .fill 512,8,0
23151 +
23152 NEXT_PAGE(level2_kernel_pgt)
23153 /*
23154 * 512 MB kernel mapping. We spend a full page on this pagetable
23155 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23156 KERNEL_IMAGE_SIZE/PMD_SIZE)
23157
23158 NEXT_PAGE(level2_fixmap_pgt)
23159 - .fill 506,8,0
23160 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23161 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23162 - .fill 5,8,0
23163 + .fill 507,8,0
23164 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23165 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23166 + .fill 4,8,0
23167
23168 -NEXT_PAGE(level1_fixmap_pgt)
23169 +NEXT_PAGE(level1_vsyscall_pgt)
23170 .fill 512,8,0
23171
23172 #undef PMDS
23173
23174 - .data
23175 + .align PAGE_SIZE
23176 +ENTRY(cpu_gdt_table)
23177 + .rept NR_CPUS
23178 + .quad 0x0000000000000000 /* NULL descriptor */
23179 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23180 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23181 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23182 + .quad 0x00cffb000000ffff /* __USER32_CS */
23183 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23184 + .quad 0x00affb000000ffff /* __USER_CS */
23185 +
23186 +#ifdef CONFIG_PAX_KERNEXEC
23187 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23188 +#else
23189 + .quad 0x0 /* unused */
23190 +#endif
23191 +
23192 + .quad 0,0 /* TSS */
23193 + .quad 0,0 /* LDT */
23194 + .quad 0,0,0 /* three TLS descriptors */
23195 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23196 + /* asm/segment.h:GDT_ENTRIES must match this */
23197 +
23198 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23199 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23200 +#else
23201 + .quad 0x0 /* unused */
23202 +#endif
23203 +
23204 + /* zero the remaining page */
23205 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23206 + .endr
23207 +
23208 .align 16
23209 .globl early_gdt_descr
23210 early_gdt_descr:
23211 .word GDT_ENTRIES*8-1
23212 early_gdt_descr_base:
23213 - .quad INIT_PER_CPU_VAR(gdt_page)
23214 + .quad cpu_gdt_table
23215
23216 ENTRY(phys_base)
23217 /* This must match the first entry in level2_kernel_pgt */
23218 .quad 0x0000000000000000
23219
23220 #include "../../x86/xen/xen-head.S"
23221 -
23222 - __PAGE_ALIGNED_BSS
23223 +
23224 + .section .rodata,"a",@progbits
23225 NEXT_PAGE(empty_zero_page)
23226 .skip PAGE_SIZE
23227 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23228 index 0fa6912..b37438b 100644
23229 --- a/arch/x86/kernel/i386_ksyms_32.c
23230 +++ b/arch/x86/kernel/i386_ksyms_32.c
23231 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23232 EXPORT_SYMBOL(cmpxchg8b_emu);
23233 #endif
23234
23235 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23236 +
23237 /* Networking helper routines. */
23238 EXPORT_SYMBOL(csum_partial_copy_generic);
23239 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23240 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23241
23242 EXPORT_SYMBOL(__get_user_1);
23243 EXPORT_SYMBOL(__get_user_2);
23244 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23245
23246 EXPORT_SYMBOL(csum_partial);
23247 EXPORT_SYMBOL(empty_zero_page);
23248 +
23249 +#ifdef CONFIG_PAX_KERNEXEC
23250 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23251 +#endif
23252 +
23253 +#ifdef CONFIG_PAX_PER_CPU_PGD
23254 +EXPORT_SYMBOL(cpu_pgd);
23255 +#endif
23256 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23257 index 5d576ab..1403a03 100644
23258 --- a/arch/x86/kernel/i387.c
23259 +++ b/arch/x86/kernel/i387.c
23260 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23261 static inline bool interrupted_user_mode(void)
23262 {
23263 struct pt_regs *regs = get_irq_regs();
23264 - return regs && user_mode_vm(regs);
23265 + return regs && user_mode(regs);
23266 }
23267
23268 /*
23269 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23270 index 9a5c460..84868423 100644
23271 --- a/arch/x86/kernel/i8259.c
23272 +++ b/arch/x86/kernel/i8259.c
23273 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23274 static void make_8259A_irq(unsigned int irq)
23275 {
23276 disable_irq_nosync(irq);
23277 - io_apic_irqs &= ~(1<<irq);
23278 + io_apic_irqs &= ~(1UL<<irq);
23279 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23280 i8259A_chip.name);
23281 enable_irq(irq);
23282 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23283 "spurious 8259A interrupt: IRQ%d.\n", irq);
23284 spurious_irq_mask |= irqmask;
23285 }
23286 - atomic_inc(&irq_err_count);
23287 + atomic_inc_unchecked(&irq_err_count);
23288 /*
23289 * Theoretically we do not have to handle this IRQ,
23290 * but in Linux this does not cause problems and is
23291 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23292 /* (slave's support for AEOI in flat mode is to be investigated) */
23293 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23294
23295 + pax_open_kernel();
23296 if (auto_eoi)
23297 /*
23298 * In AEOI mode we just have to mask the interrupt
23299 * when acking.
23300 */
23301 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23302 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23303 else
23304 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23305 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23306 + pax_close_kernel();
23307
23308 udelay(100); /* wait for 8259A to initialize */
23309
23310 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23311 index a979b5b..1d6db75 100644
23312 --- a/arch/x86/kernel/io_delay.c
23313 +++ b/arch/x86/kernel/io_delay.c
23314 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23315 * Quirk table for systems that misbehave (lock up, etc.) if port
23316 * 0x80 is used:
23317 */
23318 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23319 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23320 {
23321 .callback = dmi_io_delay_0xed_port,
23322 .ident = "Compaq Presario V6000",
23323 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23324 index 4ddaf66..6292f4e 100644
23325 --- a/arch/x86/kernel/ioport.c
23326 +++ b/arch/x86/kernel/ioport.c
23327 @@ -6,6 +6,7 @@
23328 #include <linux/sched.h>
23329 #include <linux/kernel.h>
23330 #include <linux/capability.h>
23331 +#include <linux/security.h>
23332 #include <linux/errno.h>
23333 #include <linux/types.h>
23334 #include <linux/ioport.h>
23335 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23336
23337 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23338 return -EINVAL;
23339 +#ifdef CONFIG_GRKERNSEC_IO
23340 + if (turn_on && grsec_disable_privio) {
23341 + gr_handle_ioperm();
23342 + return -EPERM;
23343 + }
23344 +#endif
23345 if (turn_on && !capable(CAP_SYS_RAWIO))
23346 return -EPERM;
23347
23348 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23349 * because the ->io_bitmap_max value must match the bitmap
23350 * contents:
23351 */
23352 - tss = &per_cpu(init_tss, get_cpu());
23353 + tss = init_tss + get_cpu();
23354
23355 if (turn_on)
23356 bitmap_clear(t->io_bitmap_ptr, from, num);
23357 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23358 return -EINVAL;
23359 /* Trying to gain more privileges? */
23360 if (level > old) {
23361 +#ifdef CONFIG_GRKERNSEC_IO
23362 + if (grsec_disable_privio) {
23363 + gr_handle_iopl();
23364 + return -EPERM;
23365 + }
23366 +#endif
23367 if (!capable(CAP_SYS_RAWIO))
23368 return -EPERM;
23369 }
23370 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23371 index 3a8185c..3c042ee 100644
23372 --- a/arch/x86/kernel/irq.c
23373 +++ b/arch/x86/kernel/irq.c
23374 @@ -21,7 +21,7 @@
23375 #define CREATE_TRACE_POINTS
23376 #include <asm/trace/irq_vectors.h>
23377
23378 -atomic_t irq_err_count;
23379 +atomic_unchecked_t irq_err_count;
23380
23381 /* Function pointer for generic interrupt vector handling */
23382 void (*x86_platform_ipi_callback)(void) = NULL;
23383 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23384 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23385 seq_printf(p, " Machine check polls\n");
23386 #endif
23387 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23388 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23389 #if defined(CONFIG_X86_IO_APIC)
23390 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23391 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23392 #endif
23393 return 0;
23394 }
23395 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23396
23397 u64 arch_irq_stat(void)
23398 {
23399 - u64 sum = atomic_read(&irq_err_count);
23400 + u64 sum = atomic_read_unchecked(&irq_err_count);
23401 return sum;
23402 }
23403
23404 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23405 index 4186755..784efa0 100644
23406 --- a/arch/x86/kernel/irq_32.c
23407 +++ b/arch/x86/kernel/irq_32.c
23408 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23409 __asm__ __volatile__("andl %%esp,%0" :
23410 "=r" (sp) : "0" (THREAD_SIZE - 1));
23411
23412 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23413 + return sp < STACK_WARN;
23414 }
23415
23416 static void print_stack_overflow(void)
23417 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23418 * per-CPU IRQ handling contexts (thread information and stack)
23419 */
23420 union irq_ctx {
23421 - struct thread_info tinfo;
23422 - u32 stack[THREAD_SIZE/sizeof(u32)];
23423 + unsigned long previous_esp;
23424 + u32 stack[THREAD_SIZE/sizeof(u32)];
23425 } __attribute__((aligned(THREAD_SIZE)));
23426
23427 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23428 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23429 static inline int
23430 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23431 {
23432 - union irq_ctx *curctx, *irqctx;
23433 + union irq_ctx *irqctx;
23434 u32 *isp, arg1, arg2;
23435
23436 - curctx = (union irq_ctx *) current_thread_info();
23437 irqctx = __this_cpu_read(hardirq_ctx);
23438
23439 /*
23440 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23441 * handler) we can't do that and just have to keep using the
23442 * current stack (which is the irq stack already after all)
23443 */
23444 - if (unlikely(curctx == irqctx))
23445 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23446 return 0;
23447
23448 /* build the stack frame on the IRQ stack */
23449 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23450 - irqctx->tinfo.task = curctx->tinfo.task;
23451 - irqctx->tinfo.previous_esp = current_stack_pointer;
23452 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23453 + irqctx->previous_esp = current_stack_pointer;
23454
23455 - /* Copy the preempt_count so that the [soft]irq checks work. */
23456 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23457 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23458 + __set_fs(MAKE_MM_SEG(0));
23459 +#endif
23460
23461 if (unlikely(overflow))
23462 call_on_stack(print_stack_overflow, isp);
23463 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23464 : "0" (irq), "1" (desc), "2" (isp),
23465 "D" (desc->handle_irq)
23466 : "memory", "cc", "ecx");
23467 +
23468 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23469 + __set_fs(current_thread_info()->addr_limit);
23470 +#endif
23471 +
23472 return 1;
23473 }
23474
23475 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23476 */
23477 void irq_ctx_init(int cpu)
23478 {
23479 - union irq_ctx *irqctx;
23480 -
23481 if (per_cpu(hardirq_ctx, cpu))
23482 return;
23483
23484 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23485 - THREADINFO_GFP,
23486 - THREAD_SIZE_ORDER));
23487 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23488 - irqctx->tinfo.cpu = cpu;
23489 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23490 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23491 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23492 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23493
23494 - per_cpu(hardirq_ctx, cpu) = irqctx;
23495 -
23496 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23497 - THREADINFO_GFP,
23498 - THREAD_SIZE_ORDER));
23499 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23500 - irqctx->tinfo.cpu = cpu;
23501 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23502 -
23503 - per_cpu(softirq_ctx, cpu) = irqctx;
23504 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23505 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23506
23507 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23508 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23509 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23510 asmlinkage void do_softirq(void)
23511 {
23512 unsigned long flags;
23513 - struct thread_info *curctx;
23514 union irq_ctx *irqctx;
23515 u32 *isp;
23516
23517 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23518 local_irq_save(flags);
23519
23520 if (local_softirq_pending()) {
23521 - curctx = current_thread_info();
23522 irqctx = __this_cpu_read(softirq_ctx);
23523 - irqctx->tinfo.task = curctx->task;
23524 - irqctx->tinfo.previous_esp = current_stack_pointer;
23525 + irqctx->previous_esp = current_stack_pointer;
23526
23527 /* build the stack frame on the softirq stack */
23528 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23529 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23530 +
23531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23532 + __set_fs(MAKE_MM_SEG(0));
23533 +#endif
23534
23535 call_on_stack(__do_softirq, isp);
23536 +
23537 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23538 + __set_fs(current_thread_info()->addr_limit);
23539 +#endif
23540 +
23541 /*
23542 * Shouldn't happen, we returned above if in_interrupt():
23543 */
23544 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23545 if (unlikely(!desc))
23546 return false;
23547
23548 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23549 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23550 if (unlikely(overflow))
23551 print_stack_overflow();
23552 desc->handle_irq(irq, desc);
23553 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23554 index d04d3ec..ea4b374 100644
23555 --- a/arch/x86/kernel/irq_64.c
23556 +++ b/arch/x86/kernel/irq_64.c
23557 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23558 u64 estack_top, estack_bottom;
23559 u64 curbase = (u64)task_stack_page(current);
23560
23561 - if (user_mode_vm(regs))
23562 + if (user_mode(regs))
23563 return;
23564
23565 if (regs->sp >= curbase + sizeof(struct thread_info) +
23566 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23567 index dc1404b..bbc43e7 100644
23568 --- a/arch/x86/kernel/kdebugfs.c
23569 +++ b/arch/x86/kernel/kdebugfs.c
23570 @@ -27,7 +27,7 @@ struct setup_data_node {
23571 u32 len;
23572 };
23573
23574 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23575 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23576 size_t count, loff_t *ppos)
23577 {
23578 struct setup_data_node *node = file->private_data;
23579 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23580 index 836f832..a8bda67 100644
23581 --- a/arch/x86/kernel/kgdb.c
23582 +++ b/arch/x86/kernel/kgdb.c
23583 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23584 #ifdef CONFIG_X86_32
23585 switch (regno) {
23586 case GDB_SS:
23587 - if (!user_mode_vm(regs))
23588 + if (!user_mode(regs))
23589 *(unsigned long *)mem = __KERNEL_DS;
23590 break;
23591 case GDB_SP:
23592 - if (!user_mode_vm(regs))
23593 + if (!user_mode(regs))
23594 *(unsigned long *)mem = kernel_stack_pointer(regs);
23595 break;
23596 case GDB_GS:
23597 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23598 bp->attr.bp_addr = breakinfo[breakno].addr;
23599 bp->attr.bp_len = breakinfo[breakno].len;
23600 bp->attr.bp_type = breakinfo[breakno].type;
23601 - info->address = breakinfo[breakno].addr;
23602 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23603 + info->address = ktla_ktva(breakinfo[breakno].addr);
23604 + else
23605 + info->address = breakinfo[breakno].addr;
23606 info->len = breakinfo[breakno].len;
23607 info->type = breakinfo[breakno].type;
23608 val = arch_install_hw_breakpoint(bp);
23609 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23610 case 'k':
23611 /* clear the trace bit */
23612 linux_regs->flags &= ~X86_EFLAGS_TF;
23613 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23614 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23615
23616 /* set the trace bit if we're stepping */
23617 if (remcomInBuffer[0] == 's') {
23618 linux_regs->flags |= X86_EFLAGS_TF;
23619 - atomic_set(&kgdb_cpu_doing_single_step,
23620 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23621 raw_smp_processor_id());
23622 }
23623
23624 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23625
23626 switch (cmd) {
23627 case DIE_DEBUG:
23628 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23629 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23630 if (user_mode(regs))
23631 return single_step_cont(regs, args);
23632 break;
23633 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23634 #endif /* CONFIG_DEBUG_RODATA */
23635
23636 bpt->type = BP_BREAKPOINT;
23637 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23638 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23639 BREAK_INSTR_SIZE);
23640 if (err)
23641 return err;
23642 - err = probe_kernel_write((char *)bpt->bpt_addr,
23643 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23644 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23645 #ifdef CONFIG_DEBUG_RODATA
23646 if (!err)
23647 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23648 return -EBUSY;
23649 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23650 BREAK_INSTR_SIZE);
23651 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23652 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23653 if (err)
23654 return err;
23655 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23656 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23657 if (mutex_is_locked(&text_mutex))
23658 goto knl_write;
23659 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23660 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23661 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23662 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23663 goto knl_write;
23664 return err;
23665 knl_write:
23666 #endif /* CONFIG_DEBUG_RODATA */
23667 - return probe_kernel_write((char *)bpt->bpt_addr,
23668 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23669 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23670 }
23671
23672 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23673 index 211bce4..6e2580a 100644
23674 --- a/arch/x86/kernel/kprobes/core.c
23675 +++ b/arch/x86/kernel/kprobes/core.c
23676 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23677 s32 raddr;
23678 } __packed *insn;
23679
23680 - insn = (struct __arch_relative_insn *)from;
23681 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23682 +
23683 + pax_open_kernel();
23684 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23685 insn->op = op;
23686 + pax_close_kernel();
23687 }
23688
23689 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23690 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23691 kprobe_opcode_t opcode;
23692 kprobe_opcode_t *orig_opcodes = opcodes;
23693
23694 - if (search_exception_tables((unsigned long)opcodes))
23695 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23696 return 0; /* Page fault may occur on this address. */
23697
23698 retry:
23699 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23700 * for the first byte, we can recover the original instruction
23701 * from it and kp->opcode.
23702 */
23703 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23704 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23705 buf[0] = kp->opcode;
23706 - return (unsigned long)buf;
23707 + return ktva_ktla((unsigned long)buf);
23708 }
23709
23710 /*
23711 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23712 /* Another subsystem puts a breakpoint, failed to recover */
23713 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23714 return 0;
23715 + pax_open_kernel();
23716 memcpy(dest, insn.kaddr, insn.length);
23717 + pax_close_kernel();
23718
23719 #ifdef CONFIG_X86_64
23720 if (insn_rip_relative(&insn)) {
23721 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23722 return 0;
23723 }
23724 disp = (u8 *) dest + insn_offset_displacement(&insn);
23725 + pax_open_kernel();
23726 *(s32 *) disp = (s32) newdisp;
23727 + pax_close_kernel();
23728 }
23729 #endif
23730 return insn.length;
23731 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23732 * nor set current_kprobe, because it doesn't use single
23733 * stepping.
23734 */
23735 - regs->ip = (unsigned long)p->ainsn.insn;
23736 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23737 preempt_enable_no_resched();
23738 return;
23739 }
23740 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23741 regs->flags &= ~X86_EFLAGS_IF;
23742 /* single step inline if the instruction is an int3 */
23743 if (p->opcode == BREAKPOINT_INSTRUCTION)
23744 - regs->ip = (unsigned long)p->addr;
23745 + regs->ip = ktla_ktva((unsigned long)p->addr);
23746 else
23747 - regs->ip = (unsigned long)p->ainsn.insn;
23748 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23749 }
23750
23751 /*
23752 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23753 setup_singlestep(p, regs, kcb, 0);
23754 return 1;
23755 }
23756 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23757 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23758 /*
23759 * The breakpoint instruction was removed right
23760 * after we hit it. Another cpu has removed
23761 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23762 " movq %rax, 152(%rsp)\n"
23763 RESTORE_REGS_STRING
23764 " popfq\n"
23765 +#ifdef KERNEXEC_PLUGIN
23766 + " btsq $63,(%rsp)\n"
23767 +#endif
23768 #else
23769 " pushf\n"
23770 SAVE_REGS_STRING
23771 @@ -779,7 +789,7 @@ static void __kprobes
23772 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23773 {
23774 unsigned long *tos = stack_addr(regs);
23775 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23776 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23777 unsigned long orig_ip = (unsigned long)p->addr;
23778 kprobe_opcode_t *insn = p->ainsn.insn;
23779
23780 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23781 struct die_args *args = data;
23782 int ret = NOTIFY_DONE;
23783
23784 - if (args->regs && user_mode_vm(args->regs))
23785 + if (args->regs && user_mode(args->regs))
23786 return ret;
23787
23788 switch (val) {
23789 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23790 index 76dc6f0..66bdfc3 100644
23791 --- a/arch/x86/kernel/kprobes/opt.c
23792 +++ b/arch/x86/kernel/kprobes/opt.c
23793 @@ -79,6 +79,7 @@ found:
23794 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23795 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23796 {
23797 + pax_open_kernel();
23798 #ifdef CONFIG_X86_64
23799 *addr++ = 0x48;
23800 *addr++ = 0xbf;
23801 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23802 *addr++ = 0xb8;
23803 #endif
23804 *(unsigned long *)addr = val;
23805 + pax_close_kernel();
23806 }
23807
23808 static void __used __kprobes kprobes_optinsn_template_holder(void)
23809 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23810 * Verify if the address gap is in 2GB range, because this uses
23811 * a relative jump.
23812 */
23813 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23814 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23815 if (abs(rel) > 0x7fffffff)
23816 return -ERANGE;
23817
23818 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23819 op->optinsn.size = ret;
23820
23821 /* Copy arch-dep-instance from template */
23822 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23823 + pax_open_kernel();
23824 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23825 + pax_close_kernel();
23826
23827 /* Set probe information */
23828 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23829
23830 /* Set probe function call */
23831 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23832 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23833
23834 /* Set returning jmp instruction at the tail of out-of-line buffer */
23835 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23836 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23837 (u8 *)op->kp.addr + op->optinsn.size);
23838
23839 flush_icache_range((unsigned long) buf,
23840 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23841 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23842
23843 /* Backup instructions which will be replaced by jump address */
23844 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23845 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23846 RELATIVE_ADDR_SIZE);
23847
23848 insn_buf[0] = RELATIVEJUMP_OPCODE;
23849 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23850 /* This kprobe is really able to run optimized path. */
23851 op = container_of(p, struct optimized_kprobe, kp);
23852 /* Detour through copied instructions */
23853 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23854 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23855 if (!reenter)
23856 reset_current_kprobe();
23857 preempt_enable_no_resched();
23858 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23859 index ebc9873..1b9724b 100644
23860 --- a/arch/x86/kernel/ldt.c
23861 +++ b/arch/x86/kernel/ldt.c
23862 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23863 if (reload) {
23864 #ifdef CONFIG_SMP
23865 preempt_disable();
23866 - load_LDT(pc);
23867 + load_LDT_nolock(pc);
23868 if (!cpumask_equal(mm_cpumask(current->mm),
23869 cpumask_of(smp_processor_id())))
23870 smp_call_function(flush_ldt, current->mm, 1);
23871 preempt_enable();
23872 #else
23873 - load_LDT(pc);
23874 + load_LDT_nolock(pc);
23875 #endif
23876 }
23877 if (oldsize) {
23878 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23879 return err;
23880
23881 for (i = 0; i < old->size; i++)
23882 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23883 + write_ldt_entry(new->ldt, i, old->ldt + i);
23884 return 0;
23885 }
23886
23887 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23888 retval = copy_ldt(&mm->context, &old_mm->context);
23889 mutex_unlock(&old_mm->context.lock);
23890 }
23891 +
23892 + if (tsk == current) {
23893 + mm->context.vdso = 0;
23894 +
23895 +#ifdef CONFIG_X86_32
23896 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23897 + mm->context.user_cs_base = 0UL;
23898 + mm->context.user_cs_limit = ~0UL;
23899 +
23900 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23901 + cpus_clear(mm->context.cpu_user_cs_mask);
23902 +#endif
23903 +
23904 +#endif
23905 +#endif
23906 +
23907 + }
23908 +
23909 return retval;
23910 }
23911
23912 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23913 }
23914 }
23915
23916 +#ifdef CONFIG_PAX_SEGMEXEC
23917 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23918 + error = -EINVAL;
23919 + goto out_unlock;
23920 + }
23921 +#endif
23922 +
23923 fill_ldt(&ldt, &ldt_info);
23924 if (oldmode)
23925 ldt.avl = 0;
23926 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23927 index 5b19e4d..6476a76 100644
23928 --- a/arch/x86/kernel/machine_kexec_32.c
23929 +++ b/arch/x86/kernel/machine_kexec_32.c
23930 @@ -26,7 +26,7 @@
23931 #include <asm/cacheflush.h>
23932 #include <asm/debugreg.h>
23933
23934 -static void set_idt(void *newidt, __u16 limit)
23935 +static void set_idt(struct desc_struct *newidt, __u16 limit)
23936 {
23937 struct desc_ptr curidt;
23938
23939 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
23940 }
23941
23942
23943 -static void set_gdt(void *newgdt, __u16 limit)
23944 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
23945 {
23946 struct desc_ptr curgdt;
23947
23948 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
23949 }
23950
23951 control_page = page_address(image->control_code_page);
23952 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
23953 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
23954
23955 relocate_kernel_ptr = control_page;
23956 page_list[PA_CONTROL_PAGE] = __pa(control_page);
23957 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
23958 index 15c9876..0a43909 100644
23959 --- a/arch/x86/kernel/microcode_core.c
23960 +++ b/arch/x86/kernel/microcode_core.c
23961 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
23962 return NOTIFY_OK;
23963 }
23964
23965 -static struct notifier_block __refdata mc_cpu_notifier = {
23966 +static struct notifier_block mc_cpu_notifier = {
23967 .notifier_call = mc_cpu_callback,
23968 };
23969
23970 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
23971 index 5fb2ceb..3ae90bb 100644
23972 --- a/arch/x86/kernel/microcode_intel.c
23973 +++ b/arch/x86/kernel/microcode_intel.c
23974 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
23975
23976 static int get_ucode_user(void *to, const void *from, size_t n)
23977 {
23978 - return copy_from_user(to, from, n);
23979 + return copy_from_user(to, (const void __force_user *)from, n);
23980 }
23981
23982 static enum ucode_state
23983 request_microcode_user(int cpu, const void __user *buf, size_t size)
23984 {
23985 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
23986 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
23987 }
23988
23989 static void microcode_fini_cpu(int cpu)
23990 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
23991 index 216a4d7..228255a 100644
23992 --- a/arch/x86/kernel/module.c
23993 +++ b/arch/x86/kernel/module.c
23994 @@ -43,15 +43,60 @@ do { \
23995 } while (0)
23996 #endif
23997
23998 -void *module_alloc(unsigned long size)
23999 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24000 {
24001 - if (PAGE_ALIGN(size) > MODULES_LEN)
24002 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24003 return NULL;
24004 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24005 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24006 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24007 -1, __builtin_return_address(0));
24008 }
24009
24010 +void *module_alloc(unsigned long size)
24011 +{
24012 +
24013 +#ifdef CONFIG_PAX_KERNEXEC
24014 + return __module_alloc(size, PAGE_KERNEL);
24015 +#else
24016 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24017 +#endif
24018 +
24019 +}
24020 +
24021 +#ifdef CONFIG_PAX_KERNEXEC
24022 +#ifdef CONFIG_X86_32
24023 +void *module_alloc_exec(unsigned long size)
24024 +{
24025 + struct vm_struct *area;
24026 +
24027 + if (size == 0)
24028 + return NULL;
24029 +
24030 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24031 + return area ? area->addr : NULL;
24032 +}
24033 +EXPORT_SYMBOL(module_alloc_exec);
24034 +
24035 +void module_free_exec(struct module *mod, void *module_region)
24036 +{
24037 + vunmap(module_region);
24038 +}
24039 +EXPORT_SYMBOL(module_free_exec);
24040 +#else
24041 +void module_free_exec(struct module *mod, void *module_region)
24042 +{
24043 + module_free(mod, module_region);
24044 +}
24045 +EXPORT_SYMBOL(module_free_exec);
24046 +
24047 +void *module_alloc_exec(unsigned long size)
24048 +{
24049 + return __module_alloc(size, PAGE_KERNEL_RX);
24050 +}
24051 +EXPORT_SYMBOL(module_alloc_exec);
24052 +#endif
24053 +#endif
24054 +
24055 #ifdef CONFIG_X86_32
24056 int apply_relocate(Elf32_Shdr *sechdrs,
24057 const char *strtab,
24058 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24059 unsigned int i;
24060 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24061 Elf32_Sym *sym;
24062 - uint32_t *location;
24063 + uint32_t *plocation, location;
24064
24065 DEBUGP("Applying relocate section %u to %u\n",
24066 relsec, sechdrs[relsec].sh_info);
24067 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24068 /* This is where to make the change */
24069 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24070 - + rel[i].r_offset;
24071 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24072 + location = (uint32_t)plocation;
24073 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24074 + plocation = ktla_ktva((void *)plocation);
24075 /* This is the symbol it is referring to. Note that all
24076 undefined symbols have been resolved. */
24077 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24078 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24079 switch (ELF32_R_TYPE(rel[i].r_info)) {
24080 case R_386_32:
24081 /* We add the value into the location given */
24082 - *location += sym->st_value;
24083 + pax_open_kernel();
24084 + *plocation += sym->st_value;
24085 + pax_close_kernel();
24086 break;
24087 case R_386_PC32:
24088 /* Add the value, subtract its position */
24089 - *location += sym->st_value - (uint32_t)location;
24090 + pax_open_kernel();
24091 + *plocation += sym->st_value - location;
24092 + pax_close_kernel();
24093 break;
24094 default:
24095 pr_err("%s: Unknown relocation: %u\n",
24096 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24097 case R_X86_64_NONE:
24098 break;
24099 case R_X86_64_64:
24100 + pax_open_kernel();
24101 *(u64 *)loc = val;
24102 + pax_close_kernel();
24103 break;
24104 case R_X86_64_32:
24105 + pax_open_kernel();
24106 *(u32 *)loc = val;
24107 + pax_close_kernel();
24108 if (val != *(u32 *)loc)
24109 goto overflow;
24110 break;
24111 case R_X86_64_32S:
24112 + pax_open_kernel();
24113 *(s32 *)loc = val;
24114 + pax_close_kernel();
24115 if ((s64)val != *(s32 *)loc)
24116 goto overflow;
24117 break;
24118 case R_X86_64_PC32:
24119 val -= (u64)loc;
24120 + pax_open_kernel();
24121 *(u32 *)loc = val;
24122 + pax_close_kernel();
24123 +
24124 #if 0
24125 if ((s64)val != *(s32 *)loc)
24126 goto overflow;
24127 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24128 index 88458fa..349f7a4 100644
24129 --- a/arch/x86/kernel/msr.c
24130 +++ b/arch/x86/kernel/msr.c
24131 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24132 return notifier_from_errno(err);
24133 }
24134
24135 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24136 +static struct notifier_block msr_class_cpu_notifier = {
24137 .notifier_call = msr_class_cpu_callback,
24138 };
24139
24140 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24141 index ba77ebc..65da999 100644
24142 --- a/arch/x86/kernel/nmi.c
24143 +++ b/arch/x86/kernel/nmi.c
24144 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24145 return handled;
24146 }
24147
24148 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24149 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24150 {
24151 struct nmi_desc *desc = nmi_to_desc(type);
24152 unsigned long flags;
24153 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24154 * event confuses some handlers (kdump uses this flag)
24155 */
24156 if (action->flags & NMI_FLAG_FIRST)
24157 - list_add_rcu(&action->list, &desc->head);
24158 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24159 else
24160 - list_add_tail_rcu(&action->list, &desc->head);
24161 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24162
24163 spin_unlock_irqrestore(&desc->lock, flags);
24164 return 0;
24165 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24166 if (!strcmp(n->name, name)) {
24167 WARN(in_nmi(),
24168 "Trying to free NMI (%s) from NMI context!\n", n->name);
24169 - list_del_rcu(&n->list);
24170 + pax_list_del_rcu((struct list_head *)&n->list);
24171 break;
24172 }
24173 }
24174 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24175 dotraplinkage notrace __kprobes void
24176 do_nmi(struct pt_regs *regs, long error_code)
24177 {
24178 +
24179 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24180 + if (!user_mode(regs)) {
24181 + unsigned long cs = regs->cs & 0xFFFF;
24182 + unsigned long ip = ktva_ktla(regs->ip);
24183 +
24184 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24185 + regs->ip = ip;
24186 + }
24187 +#endif
24188 +
24189 nmi_nesting_preprocess(regs);
24190
24191 nmi_enter();
24192 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24193 index 6d9582e..f746287 100644
24194 --- a/arch/x86/kernel/nmi_selftest.c
24195 +++ b/arch/x86/kernel/nmi_selftest.c
24196 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24197 {
24198 /* trap all the unknown NMIs we may generate */
24199 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24200 - __initdata);
24201 + __initconst);
24202 }
24203
24204 static void __init cleanup_nmi_testsuite(void)
24205 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24206 unsigned long timeout;
24207
24208 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24209 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24210 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24211 nmi_fail = FAILURE;
24212 return;
24213 }
24214 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24215 index 676b8c7..870ba04 100644
24216 --- a/arch/x86/kernel/paravirt-spinlocks.c
24217 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24218 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24219 arch_spin_lock(lock);
24220 }
24221
24222 -struct pv_lock_ops pv_lock_ops = {
24223 +struct pv_lock_ops pv_lock_ops __read_only = {
24224 #ifdef CONFIG_SMP
24225 .spin_is_locked = __ticket_spin_is_locked,
24226 .spin_is_contended = __ticket_spin_is_contended,
24227 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24228 index cd6de64..27c6af0 100644
24229 --- a/arch/x86/kernel/paravirt.c
24230 +++ b/arch/x86/kernel/paravirt.c
24231 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24232 {
24233 return x;
24234 }
24235 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24236 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24237 +#endif
24238
24239 void __init default_banner(void)
24240 {
24241 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24242 if (opfunc == NULL)
24243 /* If there's no function, patch it with a ud2a (BUG) */
24244 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24245 - else if (opfunc == _paravirt_nop)
24246 + else if (opfunc == (void *)_paravirt_nop)
24247 /* If the operation is a nop, then nop the callsite */
24248 ret = paravirt_patch_nop();
24249
24250 /* identity functions just return their single argument */
24251 - else if (opfunc == _paravirt_ident_32)
24252 + else if (opfunc == (void *)_paravirt_ident_32)
24253 ret = paravirt_patch_ident_32(insnbuf, len);
24254 - else if (opfunc == _paravirt_ident_64)
24255 + else if (opfunc == (void *)_paravirt_ident_64)
24256 ret = paravirt_patch_ident_64(insnbuf, len);
24257 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24258 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24259 + ret = paravirt_patch_ident_64(insnbuf, len);
24260 +#endif
24261
24262 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24263 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24264 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24265 if (insn_len > len || start == NULL)
24266 insn_len = len;
24267 else
24268 - memcpy(insnbuf, start, insn_len);
24269 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24270
24271 return insn_len;
24272 }
24273 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24274 return this_cpu_read(paravirt_lazy_mode);
24275 }
24276
24277 -struct pv_info pv_info = {
24278 +struct pv_info pv_info __read_only = {
24279 .name = "bare hardware",
24280 .paravirt_enabled = 0,
24281 .kernel_rpl = 0,
24282 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24283 #endif
24284 };
24285
24286 -struct pv_init_ops pv_init_ops = {
24287 +struct pv_init_ops pv_init_ops __read_only = {
24288 .patch = native_patch,
24289 };
24290
24291 -struct pv_time_ops pv_time_ops = {
24292 +struct pv_time_ops pv_time_ops __read_only = {
24293 .sched_clock = native_sched_clock,
24294 .steal_clock = native_steal_clock,
24295 };
24296
24297 -struct pv_irq_ops pv_irq_ops = {
24298 +struct pv_irq_ops pv_irq_ops __read_only = {
24299 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24300 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24301 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24302 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24303 #endif
24304 };
24305
24306 -struct pv_cpu_ops pv_cpu_ops = {
24307 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24308 .cpuid = native_cpuid,
24309 .get_debugreg = native_get_debugreg,
24310 .set_debugreg = native_set_debugreg,
24311 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24312 .end_context_switch = paravirt_nop,
24313 };
24314
24315 -struct pv_apic_ops pv_apic_ops = {
24316 +struct pv_apic_ops pv_apic_ops __read_only= {
24317 #ifdef CONFIG_X86_LOCAL_APIC
24318 .startup_ipi_hook = paravirt_nop,
24319 #endif
24320 };
24321
24322 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24323 +#ifdef CONFIG_X86_32
24324 +#ifdef CONFIG_X86_PAE
24325 +/* 64-bit pagetable entries */
24326 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24327 +#else
24328 /* 32-bit pagetable entries */
24329 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24330 +#endif
24331 #else
24332 /* 64-bit pagetable entries */
24333 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24334 #endif
24335
24336 -struct pv_mmu_ops pv_mmu_ops = {
24337 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24338
24339 .read_cr2 = native_read_cr2,
24340 .write_cr2 = native_write_cr2,
24341 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24342 .make_pud = PTE_IDENT,
24343
24344 .set_pgd = native_set_pgd,
24345 + .set_pgd_batched = native_set_pgd_batched,
24346 #endif
24347 #endif /* PAGETABLE_LEVELS >= 3 */
24348
24349 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24350 },
24351
24352 .set_fixmap = native_set_fixmap,
24353 +
24354 +#ifdef CONFIG_PAX_KERNEXEC
24355 + .pax_open_kernel = native_pax_open_kernel,
24356 + .pax_close_kernel = native_pax_close_kernel,
24357 +#endif
24358 +
24359 };
24360
24361 EXPORT_SYMBOL_GPL(pv_time_ops);
24362 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24363 index 299d493..2ccb0ee 100644
24364 --- a/arch/x86/kernel/pci-calgary_64.c
24365 +++ b/arch/x86/kernel/pci-calgary_64.c
24366 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24367 tce_space = be64_to_cpu(readq(target));
24368 tce_space = tce_space & TAR_SW_BITS;
24369
24370 - tce_space = tce_space & (~specified_table_size);
24371 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24372 info->tce_space = (u64 *)__va(tce_space);
24373 }
24374 }
24375 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24376 index 35ccf75..7a15747 100644
24377 --- a/arch/x86/kernel/pci-iommu_table.c
24378 +++ b/arch/x86/kernel/pci-iommu_table.c
24379 @@ -2,7 +2,7 @@
24380 #include <asm/iommu_table.h>
24381 #include <linux/string.h>
24382 #include <linux/kallsyms.h>
24383 -
24384 +#include <linux/sched.h>
24385
24386 #define DEBUG 1
24387
24388 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24389 index 6c483ba..d10ce2f 100644
24390 --- a/arch/x86/kernel/pci-swiotlb.c
24391 +++ b/arch/x86/kernel/pci-swiotlb.c
24392 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24393 void *vaddr, dma_addr_t dma_addr,
24394 struct dma_attrs *attrs)
24395 {
24396 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24397 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24398 }
24399
24400 static struct dma_map_ops swiotlb_dma_ops = {
24401 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24402 index 83369e5..52b93f0 100644
24403 --- a/arch/x86/kernel/process.c
24404 +++ b/arch/x86/kernel/process.c
24405 @@ -36,7 +36,8 @@
24406 * section. Since TSS's are completely CPU-local, we want them
24407 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24408 */
24409 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24410 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24411 +EXPORT_SYMBOL(init_tss);
24412
24413 #ifdef CONFIG_X86_64
24414 static DEFINE_PER_CPU(unsigned char, is_idle);
24415 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24416 task_xstate_cachep =
24417 kmem_cache_create("task_xstate", xstate_size,
24418 __alignof__(union thread_xstate),
24419 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24420 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24421 }
24422
24423 /*
24424 @@ -105,7 +106,7 @@ void exit_thread(void)
24425 unsigned long *bp = t->io_bitmap_ptr;
24426
24427 if (bp) {
24428 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24429 + struct tss_struct *tss = init_tss + get_cpu();
24430
24431 t->io_bitmap_ptr = NULL;
24432 clear_thread_flag(TIF_IO_BITMAP);
24433 @@ -125,6 +126,9 @@ void flush_thread(void)
24434 {
24435 struct task_struct *tsk = current;
24436
24437 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24438 + loadsegment(gs, 0);
24439 +#endif
24440 flush_ptrace_hw_breakpoint(tsk);
24441 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24442 drop_init_fpu(tsk);
24443 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24444 void exit_idle(void)
24445 {
24446 /* idle loop has pid 0 */
24447 - if (current->pid)
24448 + if (task_pid_nr(current))
24449 return;
24450 __exit_idle();
24451 }
24452 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24453 return ret;
24454 }
24455 #endif
24456 -void stop_this_cpu(void *dummy)
24457 +__noreturn void stop_this_cpu(void *dummy)
24458 {
24459 local_irq_disable();
24460 /*
24461 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24462 }
24463 early_param("idle", idle_setup);
24464
24465 -unsigned long arch_align_stack(unsigned long sp)
24466 +#ifdef CONFIG_PAX_RANDKSTACK
24467 +void pax_randomize_kstack(struct pt_regs *regs)
24468 {
24469 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24470 - sp -= get_random_int() % 8192;
24471 - return sp & ~0xf;
24472 -}
24473 + struct thread_struct *thread = &current->thread;
24474 + unsigned long time;
24475
24476 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24477 -{
24478 - unsigned long range_end = mm->brk + 0x02000000;
24479 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24480 -}
24481 + if (!randomize_va_space)
24482 + return;
24483 +
24484 + if (v8086_mode(regs))
24485 + return;
24486
24487 + rdtscl(time);
24488 +
24489 + /* P4 seems to return a 0 LSB, ignore it */
24490 +#ifdef CONFIG_MPENTIUM4
24491 + time &= 0x3EUL;
24492 + time <<= 2;
24493 +#elif defined(CONFIG_X86_64)
24494 + time &= 0xFUL;
24495 + time <<= 4;
24496 +#else
24497 + time &= 0x1FUL;
24498 + time <<= 3;
24499 +#endif
24500 +
24501 + thread->sp0 ^= time;
24502 + load_sp0(init_tss + smp_processor_id(), thread);
24503 +
24504 +#ifdef CONFIG_X86_64
24505 + this_cpu_write(kernel_stack, thread->sp0);
24506 +#endif
24507 +}
24508 +#endif
24509 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24510 index f8adefc..4bce3d6 100644
24511 --- a/arch/x86/kernel/process_32.c
24512 +++ b/arch/x86/kernel/process_32.c
24513 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24514 unsigned long thread_saved_pc(struct task_struct *tsk)
24515 {
24516 return ((unsigned long *)tsk->thread.sp)[3];
24517 +//XXX return tsk->thread.eip;
24518 }
24519
24520 void __show_regs(struct pt_regs *regs, int all)
24521 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24522 unsigned long sp;
24523 unsigned short ss, gs;
24524
24525 - if (user_mode_vm(regs)) {
24526 + if (user_mode(regs)) {
24527 sp = regs->sp;
24528 ss = regs->ss & 0xffff;
24529 - gs = get_user_gs(regs);
24530 } else {
24531 sp = kernel_stack_pointer(regs);
24532 savesegment(ss, ss);
24533 - savesegment(gs, gs);
24534 }
24535 + gs = get_user_gs(regs);
24536
24537 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24538 (u16)regs->cs, regs->ip, regs->flags,
24539 - smp_processor_id());
24540 + raw_smp_processor_id());
24541 print_symbol("EIP is at %s\n", regs->ip);
24542
24543 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24544 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24545 int copy_thread(unsigned long clone_flags, unsigned long sp,
24546 unsigned long arg, struct task_struct *p)
24547 {
24548 - struct pt_regs *childregs = task_pt_regs(p);
24549 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24550 struct task_struct *tsk;
24551 int err;
24552
24553 p->thread.sp = (unsigned long) childregs;
24554 p->thread.sp0 = (unsigned long) (childregs+1);
24555 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24556
24557 if (unlikely(p->flags & PF_KTHREAD)) {
24558 /* kernel thread */
24559 memset(childregs, 0, sizeof(struct pt_regs));
24560 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24561 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24562 - childregs->ds = __USER_DS;
24563 - childregs->es = __USER_DS;
24564 + savesegment(gs, childregs->gs);
24565 + childregs->ds = __KERNEL_DS;
24566 + childregs->es = __KERNEL_DS;
24567 childregs->fs = __KERNEL_PERCPU;
24568 childregs->bx = sp; /* function */
24569 childregs->bp = arg;
24570 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24571 struct thread_struct *prev = &prev_p->thread,
24572 *next = &next_p->thread;
24573 int cpu = smp_processor_id();
24574 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24575 + struct tss_struct *tss = init_tss + cpu;
24576 fpu_switch_t fpu;
24577
24578 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24579 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24580 */
24581 lazy_save_gs(prev->gs);
24582
24583 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24584 + __set_fs(task_thread_info(next_p)->addr_limit);
24585 +#endif
24586 +
24587 /*
24588 * Load the per-thread Thread-Local Storage descriptor.
24589 */
24590 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24591 */
24592 arch_end_context_switch(next_p);
24593
24594 + this_cpu_write(current_task, next_p);
24595 + this_cpu_write(current_tinfo, &next_p->tinfo);
24596 +
24597 /*
24598 * Restore %gs if needed (which is common)
24599 */
24600 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24601
24602 switch_fpu_finish(next_p, fpu);
24603
24604 - this_cpu_write(current_task, next_p);
24605 -
24606 return prev_p;
24607 }
24608
24609 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24610 } while (count++ < 16);
24611 return 0;
24612 }
24613 -
24614 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24615 index 05646ba..0c2906d 100644
24616 --- a/arch/x86/kernel/process_64.c
24617 +++ b/arch/x86/kernel/process_64.c
24618 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24619 struct pt_regs *childregs;
24620 struct task_struct *me = current;
24621
24622 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24623 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24624 childregs = task_pt_regs(p);
24625 p->thread.sp = (unsigned long) childregs;
24626 p->thread.usersp = me->thread.usersp;
24627 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24628 set_tsk_thread_flag(p, TIF_FORK);
24629 p->fpu_counter = 0;
24630 p->thread.io_bitmap_ptr = NULL;
24631 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24632 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24633 savesegment(es, p->thread.es);
24634 savesegment(ds, p->thread.ds);
24635 + savesegment(ss, p->thread.ss);
24636 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24637 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24638
24639 if (unlikely(p->flags & PF_KTHREAD)) {
24640 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24641 struct thread_struct *prev = &prev_p->thread;
24642 struct thread_struct *next = &next_p->thread;
24643 int cpu = smp_processor_id();
24644 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24645 + struct tss_struct *tss = init_tss + cpu;
24646 unsigned fsindex, gsindex;
24647 fpu_switch_t fpu;
24648
24649 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24650 if (unlikely(next->ds | prev->ds))
24651 loadsegment(ds, next->ds);
24652
24653 + savesegment(ss, prev->ss);
24654 + if (unlikely(next->ss != prev->ss))
24655 + loadsegment(ss, next->ss);
24656
24657 /* We must save %fs and %gs before load_TLS() because
24658 * %fs and %gs may be cleared by load_TLS().
24659 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24660 prev->usersp = this_cpu_read(old_rsp);
24661 this_cpu_write(old_rsp, next->usersp);
24662 this_cpu_write(current_task, next_p);
24663 + this_cpu_write(current_tinfo, &next_p->tinfo);
24664
24665 - this_cpu_write(kernel_stack,
24666 - (unsigned long)task_stack_page(next_p) +
24667 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24668 + this_cpu_write(kernel_stack, next->sp0);
24669
24670 /*
24671 * Now maybe reload the debug registers and handle I/O bitmaps
24672 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24673 if (!p || p == current || p->state == TASK_RUNNING)
24674 return 0;
24675 stack = (unsigned long)task_stack_page(p);
24676 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24677 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24678 return 0;
24679 fp = *(u64 *)(p->thread.sp);
24680 do {
24681 - if (fp < (unsigned long)stack ||
24682 - fp >= (unsigned long)stack+THREAD_SIZE)
24683 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24684 return 0;
24685 ip = *(u64 *)(fp+8);
24686 if (!in_sched_functions(ip))
24687 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24688 index 7461f50..1334029 100644
24689 --- a/arch/x86/kernel/ptrace.c
24690 +++ b/arch/x86/kernel/ptrace.c
24691 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24692 {
24693 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24694 unsigned long sp = (unsigned long)&regs->sp;
24695 - struct thread_info *tinfo;
24696
24697 - if (context == (sp & ~(THREAD_SIZE - 1)))
24698 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24699 return sp;
24700
24701 - tinfo = (struct thread_info *)context;
24702 - if (tinfo->previous_esp)
24703 - return tinfo->previous_esp;
24704 + sp = *(unsigned long *)context;
24705 + if (sp)
24706 + return sp;
24707
24708 return (unsigned long)regs;
24709 }
24710 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24711 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24712 {
24713 int i;
24714 - int dr7 = 0;
24715 + unsigned long dr7 = 0;
24716 struct arch_hw_breakpoint *info;
24717
24718 for (i = 0; i < HBP_NUM; i++) {
24719 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24720 unsigned long addr, unsigned long data)
24721 {
24722 int ret;
24723 - unsigned long __user *datap = (unsigned long __user *)data;
24724 + unsigned long __user *datap = (__force unsigned long __user *)data;
24725
24726 switch (request) {
24727 /* read the word at location addr in the USER area. */
24728 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24729 if ((int) addr < 0)
24730 return -EIO;
24731 ret = do_get_thread_area(child, addr,
24732 - (struct user_desc __user *)data);
24733 + (__force struct user_desc __user *) data);
24734 break;
24735
24736 case PTRACE_SET_THREAD_AREA:
24737 if ((int) addr < 0)
24738 return -EIO;
24739 ret = do_set_thread_area(child, addr,
24740 - (struct user_desc __user *)data, 0);
24741 + (__force struct user_desc __user *) data, 0);
24742 break;
24743 #endif
24744
24745 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24746
24747 #ifdef CONFIG_X86_64
24748
24749 -static struct user_regset x86_64_regsets[] __read_mostly = {
24750 +static user_regset_no_const x86_64_regsets[] __read_only = {
24751 [REGSET_GENERAL] = {
24752 .core_note_type = NT_PRSTATUS,
24753 .n = sizeof(struct user_regs_struct) / sizeof(long),
24754 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24755 #endif /* CONFIG_X86_64 */
24756
24757 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24758 -static struct user_regset x86_32_regsets[] __read_mostly = {
24759 +static user_regset_no_const x86_32_regsets[] __read_only = {
24760 [REGSET_GENERAL] = {
24761 .core_note_type = NT_PRSTATUS,
24762 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24763 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24764 */
24765 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24766
24767 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24768 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24769 {
24770 #ifdef CONFIG_X86_64
24771 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24772 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24773 memset(info, 0, sizeof(*info));
24774 info->si_signo = SIGTRAP;
24775 info->si_code = si_code;
24776 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24777 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24778 }
24779
24780 void user_single_step_siginfo(struct task_struct *tsk,
24781 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24782 # define IS_IA32 0
24783 #endif
24784
24785 +#ifdef CONFIG_GRKERNSEC_SETXID
24786 +extern void gr_delayed_cred_worker(void);
24787 +#endif
24788 +
24789 /*
24790 * We must return the syscall number to actually look up in the table.
24791 * This can be -1L to skip running any syscall at all.
24792 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24793
24794 user_exit();
24795
24796 +#ifdef CONFIG_GRKERNSEC_SETXID
24797 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24798 + gr_delayed_cred_worker();
24799 +#endif
24800 +
24801 /*
24802 * If we stepped into a sysenter/syscall insn, it trapped in
24803 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24804 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24805 */
24806 user_exit();
24807
24808 +#ifdef CONFIG_GRKERNSEC_SETXID
24809 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24810 + gr_delayed_cred_worker();
24811 +#endif
24812 +
24813 audit_syscall_exit(regs);
24814
24815 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24816 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24817 index 2cb9470..ff1fd80 100644
24818 --- a/arch/x86/kernel/pvclock.c
24819 +++ b/arch/x86/kernel/pvclock.c
24820 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24821 return pv_tsc_khz;
24822 }
24823
24824 -static atomic64_t last_value = ATOMIC64_INIT(0);
24825 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24826
24827 void pvclock_resume(void)
24828 {
24829 - atomic64_set(&last_value, 0);
24830 + atomic64_set_unchecked(&last_value, 0);
24831 }
24832
24833 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24834 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24835 * updating at the same time, and one of them could be slightly behind,
24836 * making the assumption that last_value always go forward fail to hold.
24837 */
24838 - last = atomic64_read(&last_value);
24839 + last = atomic64_read_unchecked(&last_value);
24840 do {
24841 if (ret < last)
24842 return last;
24843 - last = atomic64_cmpxchg(&last_value, last, ret);
24844 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24845 } while (unlikely(last != ret));
24846
24847 return ret;
24848 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24849 index 563ed91..b9c3313 100644
24850 --- a/arch/x86/kernel/reboot.c
24851 +++ b/arch/x86/kernel/reboot.c
24852 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24853
24854 void __noreturn machine_real_restart(unsigned int type)
24855 {
24856 +
24857 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24858 + struct desc_struct *gdt;
24859 +#endif
24860 +
24861 local_irq_disable();
24862
24863 /*
24864 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24865
24866 /* Jump to the identity-mapped low memory code */
24867 #ifdef CONFIG_X86_32
24868 - asm volatile("jmpl *%0" : :
24869 +
24870 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24871 + gdt = get_cpu_gdt_table(smp_processor_id());
24872 + pax_open_kernel();
24873 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24874 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24875 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24876 + loadsegment(ds, __KERNEL_DS);
24877 + loadsegment(es, __KERNEL_DS);
24878 + loadsegment(ss, __KERNEL_DS);
24879 +#endif
24880 +#ifdef CONFIG_PAX_KERNEXEC
24881 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24882 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24883 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24884 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24885 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24886 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24887 +#endif
24888 + pax_close_kernel();
24889 +#endif
24890 +
24891 + asm volatile("ljmpl *%0" : :
24892 "rm" (real_mode_header->machine_real_restart_asm),
24893 "a" (type));
24894 #else
24895 @@ -442,7 +469,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24896 * try to force a triple fault and then cycle between hitting the keyboard
24897 * controller and doing that
24898 */
24899 -static void native_machine_emergency_restart(void)
24900 +static void __noreturn native_machine_emergency_restart(void)
24901 {
24902 int i;
24903 int attempt = 0;
24904 @@ -551,13 +578,13 @@ void native_machine_shutdown(void)
24905 #endif
24906 }
24907
24908 -static void __machine_emergency_restart(int emergency)
24909 +static void __noreturn __machine_emergency_restart(int emergency)
24910 {
24911 reboot_emergency = emergency;
24912 machine_ops.emergency_restart();
24913 }
24914
24915 -static void native_machine_restart(char *__unused)
24916 +static void __noreturn native_machine_restart(char *__unused)
24917 {
24918 pr_notice("machine restart\n");
24919
24920 @@ -566,7 +593,7 @@ static void native_machine_restart(char *__unused)
24921 __machine_emergency_restart(0);
24922 }
24923
24924 -static void native_machine_halt(void)
24925 +static void __noreturn native_machine_halt(void)
24926 {
24927 /* Stop other cpus and apics */
24928 machine_shutdown();
24929 @@ -576,7 +603,7 @@ static void native_machine_halt(void)
24930 stop_this_cpu(NULL);
24931 }
24932
24933 -static void native_machine_power_off(void)
24934 +static void __noreturn native_machine_power_off(void)
24935 {
24936 if (pm_power_off) {
24937 if (!reboot_force)
24938 @@ -585,9 +612,10 @@ static void native_machine_power_off(void)
24939 }
24940 /* A fallback in case there is no PM info available */
24941 tboot_shutdown(TB_SHUTDOWN_HALT);
24942 + unreachable();
24943 }
24944
24945 -struct machine_ops machine_ops = {
24946 +struct machine_ops machine_ops __read_only = {
24947 .power_off = native_machine_power_off,
24948 .shutdown = native_machine_shutdown,
24949 .emergency_restart = native_machine_emergency_restart,
24950 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
24951 index c8e41e9..64049ef 100644
24952 --- a/arch/x86/kernel/reboot_fixups_32.c
24953 +++ b/arch/x86/kernel/reboot_fixups_32.c
24954 @@ -57,7 +57,7 @@ struct device_fixup {
24955 unsigned int vendor;
24956 unsigned int device;
24957 void (*reboot_fixup)(struct pci_dev *);
24958 -};
24959 +} __do_const;
24960
24961 /*
24962 * PCI ids solely used for fixups_table go here
24963 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
24964 index 3fd2c69..16ef367 100644
24965 --- a/arch/x86/kernel/relocate_kernel_64.S
24966 +++ b/arch/x86/kernel/relocate_kernel_64.S
24967 @@ -11,6 +11,7 @@
24968 #include <asm/kexec.h>
24969 #include <asm/processor-flags.h>
24970 #include <asm/pgtable_types.h>
24971 +#include <asm/alternative-asm.h>
24972
24973 /*
24974 * Must be relocatable PIC code callable as a C function
24975 @@ -96,8 +97,7 @@ relocate_kernel:
24976
24977 /* jump to identity mapped page */
24978 addq $(identity_mapped - relocate_kernel), %r8
24979 - pushq %r8
24980 - ret
24981 + jmp *%r8
24982
24983 identity_mapped:
24984 /* set return address to 0 if not preserving context */
24985 @@ -167,6 +167,7 @@ identity_mapped:
24986 xorl %r14d, %r14d
24987 xorl %r15d, %r15d
24988
24989 + pax_force_retaddr 0, 1
24990 ret
24991
24992 1:
24993 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
24994 index f8ec578..0cc110a 100644
24995 --- a/arch/x86/kernel/setup.c
24996 +++ b/arch/x86/kernel/setup.c
24997 @@ -110,6 +110,7 @@
24998 #include <asm/mce.h>
24999 #include <asm/alternative.h>
25000 #include <asm/prom.h>
25001 +#include <asm/boot.h>
25002
25003 /*
25004 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25005 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25006 #endif
25007
25008
25009 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25010 -unsigned long mmu_cr4_features;
25011 +#ifdef CONFIG_X86_64
25012 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25013 +#elif defined(CONFIG_X86_PAE)
25014 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25015 #else
25016 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25017 +unsigned long mmu_cr4_features __read_only;
25018 #endif
25019
25020 +void set_in_cr4(unsigned long mask)
25021 +{
25022 + unsigned long cr4 = read_cr4();
25023 +
25024 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25025 + return;
25026 +
25027 + pax_open_kernel();
25028 + mmu_cr4_features |= mask;
25029 + pax_close_kernel();
25030 +
25031 + if (trampoline_cr4_features)
25032 + *trampoline_cr4_features = mmu_cr4_features;
25033 + cr4 |= mask;
25034 + write_cr4(cr4);
25035 +}
25036 +EXPORT_SYMBOL(set_in_cr4);
25037 +
25038 +void clear_in_cr4(unsigned long mask)
25039 +{
25040 + unsigned long cr4 = read_cr4();
25041 +
25042 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25043 + return;
25044 +
25045 + pax_open_kernel();
25046 + mmu_cr4_features &= ~mask;
25047 + pax_close_kernel();
25048 +
25049 + if (trampoline_cr4_features)
25050 + *trampoline_cr4_features = mmu_cr4_features;
25051 + cr4 &= ~mask;
25052 + write_cr4(cr4);
25053 +}
25054 +EXPORT_SYMBOL(clear_in_cr4);
25055 +
25056 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25057 int bootloader_type, bootloader_version;
25058
25059 @@ -444,7 +483,7 @@ static void __init parse_setup_data(void)
25060
25061 switch (data->type) {
25062 case SETUP_E820_EXT:
25063 - parse_e820_ext(data);
25064 + parse_e820_ext((struct setup_data __force_kernel *)data);
25065 break;
25066 case SETUP_DTB:
25067 add_dtb(pa_data);
25068 @@ -771,7 +810,7 @@ static void __init trim_bios_range(void)
25069 * area (640->1Mb) as ram even though it is not.
25070 * take them out.
25071 */
25072 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25073 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25074
25075 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25076 }
25077 @@ -779,7 +818,7 @@ static void __init trim_bios_range(void)
25078 /* called before trim_bios_range() to spare extra sanitize */
25079 static void __init e820_add_kernel_range(void)
25080 {
25081 - u64 start = __pa_symbol(_text);
25082 + u64 start = __pa_symbol(ktla_ktva(_text));
25083 u64 size = __pa_symbol(_end) - start;
25084
25085 /*
25086 @@ -841,8 +880,12 @@ static void __init trim_low_memory_range(void)
25087
25088 void __init setup_arch(char **cmdline_p)
25089 {
25090 +#ifdef CONFIG_X86_32
25091 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25092 +#else
25093 memblock_reserve(__pa_symbol(_text),
25094 (unsigned long)__bss_stop - (unsigned long)_text);
25095 +#endif
25096
25097 early_reserve_initrd();
25098
25099 @@ -934,14 +977,14 @@ void __init setup_arch(char **cmdline_p)
25100
25101 if (!boot_params.hdr.root_flags)
25102 root_mountflags &= ~MS_RDONLY;
25103 - init_mm.start_code = (unsigned long) _text;
25104 - init_mm.end_code = (unsigned long) _etext;
25105 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25106 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25107 init_mm.end_data = (unsigned long) _edata;
25108 init_mm.brk = _brk_end;
25109
25110 - code_resource.start = __pa_symbol(_text);
25111 - code_resource.end = __pa_symbol(_etext)-1;
25112 - data_resource.start = __pa_symbol(_etext);
25113 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25114 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25115 + data_resource.start = __pa_symbol(_sdata);
25116 data_resource.end = __pa_symbol(_edata)-1;
25117 bss_resource.start = __pa_symbol(__bss_start);
25118 bss_resource.end = __pa_symbol(__bss_stop)-1;
25119 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25120 index 5cdff03..80fa283 100644
25121 --- a/arch/x86/kernel/setup_percpu.c
25122 +++ b/arch/x86/kernel/setup_percpu.c
25123 @@ -21,19 +21,17 @@
25124 #include <asm/cpu.h>
25125 #include <asm/stackprotector.h>
25126
25127 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25128 +#ifdef CONFIG_SMP
25129 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25130 EXPORT_PER_CPU_SYMBOL(cpu_number);
25131 +#endif
25132
25133 -#ifdef CONFIG_X86_64
25134 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25135 -#else
25136 -#define BOOT_PERCPU_OFFSET 0
25137 -#endif
25138
25139 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25140 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25141
25142 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25143 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25144 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25145 };
25146 EXPORT_SYMBOL(__per_cpu_offset);
25147 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25148 {
25149 #ifdef CONFIG_NEED_MULTIPLE_NODES
25150 pg_data_t *last = NULL;
25151 - unsigned int cpu;
25152 + int cpu;
25153
25154 for_each_possible_cpu(cpu) {
25155 int node = early_cpu_to_node(cpu);
25156 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25157 {
25158 #ifdef CONFIG_X86_32
25159 struct desc_struct gdt;
25160 + unsigned long base = per_cpu_offset(cpu);
25161
25162 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25163 - 0x2 | DESCTYPE_S, 0x8);
25164 - gdt.s = 1;
25165 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25166 + 0x83 | DESCTYPE_S, 0xC);
25167 write_gdt_entry(get_cpu_gdt_table(cpu),
25168 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25169 #endif
25170 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25171 /* alrighty, percpu areas up and running */
25172 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25173 for_each_possible_cpu(cpu) {
25174 +#ifdef CONFIG_CC_STACKPROTECTOR
25175 +#ifdef CONFIG_X86_32
25176 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25177 +#endif
25178 +#endif
25179 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25180 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25181 per_cpu(cpu_number, cpu) = cpu;
25182 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25183 */
25184 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25185 #endif
25186 +#ifdef CONFIG_CC_STACKPROTECTOR
25187 +#ifdef CONFIG_X86_32
25188 + if (!cpu)
25189 + per_cpu(stack_canary.canary, cpu) = canary;
25190 +#endif
25191 +#endif
25192 /*
25193 * Up to this point, the boot CPU has been using .init.data
25194 * area. Reload any changed state for the boot CPU.
25195 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25196 index cf91358..a7081ea 100644
25197 --- a/arch/x86/kernel/signal.c
25198 +++ b/arch/x86/kernel/signal.c
25199 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25200 * Align the stack pointer according to the i386 ABI,
25201 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25202 */
25203 - sp = ((sp + 4) & -16ul) - 4;
25204 + sp = ((sp - 12) & -16ul) - 4;
25205 #else /* !CONFIG_X86_32 */
25206 sp = round_down(sp, 16) - 8;
25207 #endif
25208 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25209 }
25210
25211 if (current->mm->context.vdso)
25212 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25213 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25214 else
25215 - restorer = &frame->retcode;
25216 + restorer = (void __user *)&frame->retcode;
25217 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25218 restorer = ksig->ka.sa.sa_restorer;
25219
25220 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25221 * reasons and because gdb uses it as a signature to notice
25222 * signal handler stack frames.
25223 */
25224 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25225 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25226
25227 if (err)
25228 return -EFAULT;
25229 @@ -358,10 +358,13 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25230 else
25231 put_user_ex(0, &frame->uc.uc_flags);
25232 put_user_ex(0, &frame->uc.uc_link);
25233 - err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
25234 + __save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25235
25236 /* Set up to return from userspace. */
25237 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25238 + if (current->mm->context.vdso)
25239 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25240 + else
25241 + restorer = (void __user *)&frame->retcode;
25242 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25243 restorer = ksig->ka.sa.sa_restorer;
25244 put_user_ex(restorer, &frame->pretcode);
25245 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25246 * reasons and because gdb uses it as a signature to notice
25247 * signal handler stack frames.
25248 */
25249 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25250 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25251 } put_user_catch(err);
25252
25253 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25254 @@ -423,7 +426,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25255 else
25256 put_user_ex(0, &frame->uc.uc_flags);
25257 put_user_ex(0, &frame->uc.uc_link);
25258 - err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
25259 + __save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25260
25261 /* Set up to return from userspace. If provided, use a stub
25262 already in userspace. */
25263 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25264 {
25265 int usig = signr_convert(ksig->sig);
25266 sigset_t *set = sigmask_to_save();
25267 - compat_sigset_t *cset = (compat_sigset_t *) set;
25268 + sigset_t sigcopy;
25269 + compat_sigset_t *cset;
25270 +
25271 + sigcopy = *set;
25272 +
25273 + cset = (compat_sigset_t *) &sigcopy;
25274
25275 /* Set up the stack frame */
25276 if (is_ia32_frame()) {
25277 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25278 } else if (is_x32_frame()) {
25279 return x32_setup_rt_frame(ksig, cset, regs);
25280 } else {
25281 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25282 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25283 }
25284 }
25285
25286 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25287 index cdaa347..f5af55d 100644
25288 --- a/arch/x86/kernel/smp.c
25289 +++ b/arch/x86/kernel/smp.c
25290 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25291
25292 __setup("nonmi_ipi", nonmi_ipi_setup);
25293
25294 -struct smp_ops smp_ops = {
25295 +struct smp_ops smp_ops __read_only = {
25296 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25297 .smp_prepare_cpus = native_smp_prepare_cpus,
25298 .smp_cpus_done = native_smp_cpus_done,
25299 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25300 index aecc98a..0244a53 100644
25301 --- a/arch/x86/kernel/smpboot.c
25302 +++ b/arch/x86/kernel/smpboot.c
25303 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25304
25305 enable_start_cpu0 = 0;
25306
25307 -#ifdef CONFIG_X86_32
25308 - /* switch away from the initial page table */
25309 - load_cr3(swapper_pg_dir);
25310 - __flush_tlb_all();
25311 -#endif
25312 -
25313 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25314 barrier();
25315 +
25316 + /* switch away from the initial page table */
25317 +#ifdef CONFIG_PAX_PER_CPU_PGD
25318 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25319 + __flush_tlb_all();
25320 +#elif defined(CONFIG_X86_32)
25321 + load_cr3(swapper_pg_dir);
25322 + __flush_tlb_all();
25323 +#endif
25324 +
25325 /*
25326 * Check TSC synchronization with the BP:
25327 */
25328 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25329 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25330 (THREAD_SIZE + task_stack_page(idle))) - 1);
25331 per_cpu(current_task, cpu) = idle;
25332 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25333
25334 #ifdef CONFIG_X86_32
25335 /* Stack for startup_32 can be just as for start_secondary onwards */
25336 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25337 #else
25338 clear_tsk_thread_flag(idle, TIF_FORK);
25339 initial_gs = per_cpu_offset(cpu);
25340 - per_cpu(kernel_stack, cpu) =
25341 - (unsigned long)task_stack_page(idle) -
25342 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25343 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25344 #endif
25345 +
25346 + pax_open_kernel();
25347 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25348 + pax_close_kernel();
25349 +
25350 initial_code = (unsigned long)start_secondary;
25351 stack_start = idle->thread.sp;
25352
25353 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25354 /* the FPU context is blank, nobody can own it */
25355 __cpu_disable_lazy_restore(cpu);
25356
25357 +#ifdef CONFIG_PAX_PER_CPU_PGD
25358 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25359 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25360 + KERNEL_PGD_PTRS);
25361 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25362 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25363 + KERNEL_PGD_PTRS);
25364 +#endif
25365 +
25366 err = do_boot_cpu(apicid, cpu, tidle);
25367 if (err) {
25368 pr_debug("do_boot_cpu failed %d\n", err);
25369 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25370 index 9b4d51d..5d28b58 100644
25371 --- a/arch/x86/kernel/step.c
25372 +++ b/arch/x86/kernel/step.c
25373 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25374 struct desc_struct *desc;
25375 unsigned long base;
25376
25377 - seg &= ~7UL;
25378 + seg >>= 3;
25379
25380 mutex_lock(&child->mm->context.lock);
25381 - if (unlikely((seg >> 3) >= child->mm->context.size))
25382 + if (unlikely(seg >= child->mm->context.size))
25383 addr = -1L; /* bogus selector, access would fault */
25384 else {
25385 desc = child->mm->context.ldt + seg;
25386 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25387 addr += base;
25388 }
25389 mutex_unlock(&child->mm->context.lock);
25390 - }
25391 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25392 + addr = ktla_ktva(addr);
25393
25394 return addr;
25395 }
25396 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25397 unsigned char opcode[15];
25398 unsigned long addr = convert_ip_to_linear(child, regs);
25399
25400 + if (addr == -EINVAL)
25401 + return 0;
25402 +
25403 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25404 for (i = 0; i < copied; i++) {
25405 switch (opcode[i]) {
25406 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25407 new file mode 100644
25408 index 0000000..5877189
25409 --- /dev/null
25410 +++ b/arch/x86/kernel/sys_i386_32.c
25411 @@ -0,0 +1,189 @@
25412 +/*
25413 + * This file contains various random system calls that
25414 + * have a non-standard calling sequence on the Linux/i386
25415 + * platform.
25416 + */
25417 +
25418 +#include <linux/errno.h>
25419 +#include <linux/sched.h>
25420 +#include <linux/mm.h>
25421 +#include <linux/fs.h>
25422 +#include <linux/smp.h>
25423 +#include <linux/sem.h>
25424 +#include <linux/msg.h>
25425 +#include <linux/shm.h>
25426 +#include <linux/stat.h>
25427 +#include <linux/syscalls.h>
25428 +#include <linux/mman.h>
25429 +#include <linux/file.h>
25430 +#include <linux/utsname.h>
25431 +#include <linux/ipc.h>
25432 +#include <linux/elf.h>
25433 +
25434 +#include <linux/uaccess.h>
25435 +#include <linux/unistd.h>
25436 +
25437 +#include <asm/syscalls.h>
25438 +
25439 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25440 +{
25441 + unsigned long pax_task_size = TASK_SIZE;
25442 +
25443 +#ifdef CONFIG_PAX_SEGMEXEC
25444 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25445 + pax_task_size = SEGMEXEC_TASK_SIZE;
25446 +#endif
25447 +
25448 + if (flags & MAP_FIXED)
25449 + if (len > pax_task_size || addr > pax_task_size - len)
25450 + return -EINVAL;
25451 +
25452 + return 0;
25453 +}
25454 +
25455 +/*
25456 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25457 + */
25458 +static unsigned long get_align_mask(void)
25459 +{
25460 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25461 + return 0;
25462 +
25463 + if (!(current->flags & PF_RANDOMIZE))
25464 + return 0;
25465 +
25466 + return va_align.mask;
25467 +}
25468 +
25469 +unsigned long
25470 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25471 + unsigned long len, unsigned long pgoff, unsigned long flags)
25472 +{
25473 + struct mm_struct *mm = current->mm;
25474 + struct vm_area_struct *vma;
25475 + unsigned long pax_task_size = TASK_SIZE;
25476 + struct vm_unmapped_area_info info;
25477 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25478 +
25479 +#ifdef CONFIG_PAX_SEGMEXEC
25480 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25481 + pax_task_size = SEGMEXEC_TASK_SIZE;
25482 +#endif
25483 +
25484 + pax_task_size -= PAGE_SIZE;
25485 +
25486 + if (len > pax_task_size)
25487 + return -ENOMEM;
25488 +
25489 + if (flags & MAP_FIXED)
25490 + return addr;
25491 +
25492 +#ifdef CONFIG_PAX_RANDMMAP
25493 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25494 +#endif
25495 +
25496 + if (addr) {
25497 + addr = PAGE_ALIGN(addr);
25498 + if (pax_task_size - len >= addr) {
25499 + vma = find_vma(mm, addr);
25500 + if (check_heap_stack_gap(vma, addr, len, offset))
25501 + return addr;
25502 + }
25503 + }
25504 +
25505 + info.flags = 0;
25506 + info.length = len;
25507 + info.align_mask = filp ? get_align_mask() : 0;
25508 + info.align_offset = pgoff << PAGE_SHIFT;
25509 + info.threadstack_offset = offset;
25510 +
25511 +#ifdef CONFIG_PAX_PAGEEXEC
25512 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25513 + info.low_limit = 0x00110000UL;
25514 + info.high_limit = mm->start_code;
25515 +
25516 +#ifdef CONFIG_PAX_RANDMMAP
25517 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25518 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25519 +#endif
25520 +
25521 + if (info.low_limit < info.high_limit) {
25522 + addr = vm_unmapped_area(&info);
25523 + if (!IS_ERR_VALUE(addr))
25524 + return addr;
25525 + }
25526 + } else
25527 +#endif
25528 +
25529 + info.low_limit = mm->mmap_base;
25530 + info.high_limit = pax_task_size;
25531 +
25532 + return vm_unmapped_area(&info);
25533 +}
25534 +
25535 +unsigned long
25536 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25537 + const unsigned long len, const unsigned long pgoff,
25538 + const unsigned long flags)
25539 +{
25540 + struct vm_area_struct *vma;
25541 + struct mm_struct *mm = current->mm;
25542 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25543 + struct vm_unmapped_area_info info;
25544 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25545 +
25546 +#ifdef CONFIG_PAX_SEGMEXEC
25547 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25548 + pax_task_size = SEGMEXEC_TASK_SIZE;
25549 +#endif
25550 +
25551 + pax_task_size -= PAGE_SIZE;
25552 +
25553 + /* requested length too big for entire address space */
25554 + if (len > pax_task_size)
25555 + return -ENOMEM;
25556 +
25557 + if (flags & MAP_FIXED)
25558 + return addr;
25559 +
25560 +#ifdef CONFIG_PAX_PAGEEXEC
25561 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25562 + goto bottomup;
25563 +#endif
25564 +
25565 +#ifdef CONFIG_PAX_RANDMMAP
25566 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25567 +#endif
25568 +
25569 + /* requesting a specific address */
25570 + if (addr) {
25571 + addr = PAGE_ALIGN(addr);
25572 + if (pax_task_size - len >= addr) {
25573 + vma = find_vma(mm, addr);
25574 + if (check_heap_stack_gap(vma, addr, len, offset))
25575 + return addr;
25576 + }
25577 + }
25578 +
25579 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25580 + info.length = len;
25581 + info.low_limit = PAGE_SIZE;
25582 + info.high_limit = mm->mmap_base;
25583 + info.align_mask = filp ? get_align_mask() : 0;
25584 + info.align_offset = pgoff << PAGE_SHIFT;
25585 + info.threadstack_offset = offset;
25586 +
25587 + addr = vm_unmapped_area(&info);
25588 + if (!(addr & ~PAGE_MASK))
25589 + return addr;
25590 + VM_BUG_ON(addr != -ENOMEM);
25591 +
25592 +bottomup:
25593 + /*
25594 + * A failed mmap() very likely causes application failure,
25595 + * so fall back to the bottom-up function here. This scenario
25596 + * can happen with large stack limits and large mmap()
25597 + * allocations.
25598 + */
25599 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25600 +}
25601 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25602 index 30277e2..5664a29 100644
25603 --- a/arch/x86/kernel/sys_x86_64.c
25604 +++ b/arch/x86/kernel/sys_x86_64.c
25605 @@ -81,8 +81,8 @@ out:
25606 return error;
25607 }
25608
25609 -static void find_start_end(unsigned long flags, unsigned long *begin,
25610 - unsigned long *end)
25611 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25612 + unsigned long *begin, unsigned long *end)
25613 {
25614 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25615 unsigned long new_begin;
25616 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25617 *begin = new_begin;
25618 }
25619 } else {
25620 - *begin = current->mm->mmap_legacy_base;
25621 + *begin = mm->mmap_legacy_base;
25622 *end = TASK_SIZE;
25623 }
25624 }
25625 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25626 struct vm_area_struct *vma;
25627 struct vm_unmapped_area_info info;
25628 unsigned long begin, end;
25629 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25630
25631 if (flags & MAP_FIXED)
25632 return addr;
25633
25634 - find_start_end(flags, &begin, &end);
25635 + find_start_end(mm, flags, &begin, &end);
25636
25637 if (len > end)
25638 return -ENOMEM;
25639
25640 +#ifdef CONFIG_PAX_RANDMMAP
25641 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25642 +#endif
25643 +
25644 if (addr) {
25645 addr = PAGE_ALIGN(addr);
25646 vma = find_vma(mm, addr);
25647 - if (end - len >= addr &&
25648 - (!vma || addr + len <= vma->vm_start))
25649 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25650 return addr;
25651 }
25652
25653 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25654 info.high_limit = end;
25655 info.align_mask = filp ? get_align_mask() : 0;
25656 info.align_offset = pgoff << PAGE_SHIFT;
25657 + info.threadstack_offset = offset;
25658 return vm_unmapped_area(&info);
25659 }
25660
25661 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25662 struct mm_struct *mm = current->mm;
25663 unsigned long addr = addr0;
25664 struct vm_unmapped_area_info info;
25665 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25666
25667 /* requested length too big for entire address space */
25668 if (len > TASK_SIZE)
25669 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25670 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25671 goto bottomup;
25672
25673 +#ifdef CONFIG_PAX_RANDMMAP
25674 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25675 +#endif
25676 +
25677 /* requesting a specific address */
25678 if (addr) {
25679 addr = PAGE_ALIGN(addr);
25680 vma = find_vma(mm, addr);
25681 - if (TASK_SIZE - len >= addr &&
25682 - (!vma || addr + len <= vma->vm_start))
25683 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25684 return addr;
25685 }
25686
25687 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25688 info.high_limit = mm->mmap_base;
25689 info.align_mask = filp ? get_align_mask() : 0;
25690 info.align_offset = pgoff << PAGE_SHIFT;
25691 + info.threadstack_offset = offset;
25692 addr = vm_unmapped_area(&info);
25693 if (!(addr & ~PAGE_MASK))
25694 return addr;
25695 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25696 index addf7b5..f960685 100644
25697 --- a/arch/x86/kernel/tboot.c
25698 +++ b/arch/x86/kernel/tboot.c
25699 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25700
25701 void tboot_shutdown(u32 shutdown_type)
25702 {
25703 - void (*shutdown)(void);
25704 + void (* __noreturn shutdown)(void);
25705
25706 if (!tboot_enabled())
25707 return;
25708 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25709
25710 switch_to_tboot_pt();
25711
25712 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25713 + shutdown = (void *)tboot->shutdown_entry;
25714 shutdown();
25715
25716 /* should not reach here */
25717 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25718 return 0;
25719 }
25720
25721 -static atomic_t ap_wfs_count;
25722 +static atomic_unchecked_t ap_wfs_count;
25723
25724 static int tboot_wait_for_aps(int num_aps)
25725 {
25726 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25727 {
25728 switch (action) {
25729 case CPU_DYING:
25730 - atomic_inc(&ap_wfs_count);
25731 + atomic_inc_unchecked(&ap_wfs_count);
25732 if (num_online_cpus() == 1)
25733 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25734 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25735 return NOTIFY_BAD;
25736 break;
25737 }
25738 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25739
25740 tboot_create_trampoline();
25741
25742 - atomic_set(&ap_wfs_count, 0);
25743 + atomic_set_unchecked(&ap_wfs_count, 0);
25744 register_hotcpu_notifier(&tboot_cpu_notifier);
25745
25746 #ifdef CONFIG_DEBUG_FS
25747 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25748 index 24d3c91..d06b473 100644
25749 --- a/arch/x86/kernel/time.c
25750 +++ b/arch/x86/kernel/time.c
25751 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25752 {
25753 unsigned long pc = instruction_pointer(regs);
25754
25755 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25756 + if (!user_mode(regs) && in_lock_functions(pc)) {
25757 #ifdef CONFIG_FRAME_POINTER
25758 - return *(unsigned long *)(regs->bp + sizeof(long));
25759 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25760 #else
25761 unsigned long *sp =
25762 (unsigned long *)kernel_stack_pointer(regs);
25763 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25764 * or above a saved flags. Eflags has bits 22-31 zero,
25765 * kernel addresses don't.
25766 */
25767 +
25768 +#ifdef CONFIG_PAX_KERNEXEC
25769 + return ktla_ktva(sp[0]);
25770 +#else
25771 if (sp[0] >> 22)
25772 return sp[0];
25773 if (sp[1] >> 22)
25774 return sp[1];
25775 #endif
25776 +
25777 +#endif
25778 }
25779 return pc;
25780 }
25781 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25782 index f7fec09..9991981 100644
25783 --- a/arch/x86/kernel/tls.c
25784 +++ b/arch/x86/kernel/tls.c
25785 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25786 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25787 return -EINVAL;
25788
25789 +#ifdef CONFIG_PAX_SEGMEXEC
25790 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25791 + return -EINVAL;
25792 +#endif
25793 +
25794 set_tls_desc(p, idx, &info, 1);
25795
25796 return 0;
25797 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25798
25799 if (kbuf)
25800 info = kbuf;
25801 - else if (__copy_from_user(infobuf, ubuf, count))
25802 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25803 return -EFAULT;
25804 else
25805 info = infobuf;
25806 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25807 index 1c113db..287b42e 100644
25808 --- a/arch/x86/kernel/tracepoint.c
25809 +++ b/arch/x86/kernel/tracepoint.c
25810 @@ -9,11 +9,11 @@
25811 #include <linux/atomic.h>
25812
25813 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25814 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25815 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25816 (unsigned long) trace_idt_table };
25817
25818 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25819 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25820 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25821
25822 static int trace_irq_vector_refcount;
25823 static DEFINE_MUTEX(irq_vector_mutex);
25824 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25825 index 1b23a1c..910de0d 100644
25826 --- a/arch/x86/kernel/traps.c
25827 +++ b/arch/x86/kernel/traps.c
25828 @@ -65,7 +65,7 @@
25829 #include <asm/proto.h>
25830
25831 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25832 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25833 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25834 #else
25835 #include <asm/processor-flags.h>
25836 #include <asm/setup.h>
25837 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25838 #endif
25839
25840 /* Must be page-aligned because the real IDT is used in a fixmap. */
25841 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25842 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25843
25844 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25845 EXPORT_SYMBOL_GPL(used_vectors);
25846 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25847 }
25848
25849 static int __kprobes
25850 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25851 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25852 struct pt_regs *regs, long error_code)
25853 {
25854 #ifdef CONFIG_X86_32
25855 - if (regs->flags & X86_VM_MASK) {
25856 + if (v8086_mode(regs)) {
25857 /*
25858 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25859 * On nmi (interrupt 2), do_trap should not be called.
25860 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25861 return -1;
25862 }
25863 #endif
25864 - if (!user_mode(regs)) {
25865 + if (!user_mode_novm(regs)) {
25866 if (!fixup_exception(regs)) {
25867 tsk->thread.error_code = error_code;
25868 tsk->thread.trap_nr = trapnr;
25869 +
25870 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25871 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25872 + str = "PAX: suspicious stack segment fault";
25873 +#endif
25874 +
25875 die(str, regs, error_code);
25876 }
25877 +
25878 +#ifdef CONFIG_PAX_REFCOUNT
25879 + if (trapnr == 4)
25880 + pax_report_refcount_overflow(regs);
25881 +#endif
25882 +
25883 return 0;
25884 }
25885
25886 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25887 }
25888
25889 static void __kprobes
25890 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25891 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25892 long error_code, siginfo_t *info)
25893 {
25894 struct task_struct *tsk = current;
25895 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25896 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25897 printk_ratelimit()) {
25898 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25899 - tsk->comm, tsk->pid, str,
25900 + tsk->comm, task_pid_nr(tsk), str,
25901 regs->ip, regs->sp, error_code);
25902 print_vma_addr(" in ", regs->ip);
25903 pr_cont("\n");
25904 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25905 conditional_sti(regs);
25906
25907 #ifdef CONFIG_X86_32
25908 - if (regs->flags & X86_VM_MASK) {
25909 + if (v8086_mode(regs)) {
25910 local_irq_enable();
25911 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25912 goto exit;
25913 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25914 #endif
25915
25916 tsk = current;
25917 - if (!user_mode(regs)) {
25918 + if (!user_mode_novm(regs)) {
25919 if (fixup_exception(regs))
25920 goto exit;
25921
25922 tsk->thread.error_code = error_code;
25923 tsk->thread.trap_nr = X86_TRAP_GP;
25924 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25925 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25926 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25927 +
25928 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25929 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25930 + die("PAX: suspicious general protection fault", regs, error_code);
25931 + else
25932 +#endif
25933 +
25934 die("general protection fault", regs, error_code);
25935 + }
25936 goto exit;
25937 }
25938
25939 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25940 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25941 + struct mm_struct *mm = tsk->mm;
25942 + unsigned long limit;
25943 +
25944 + down_write(&mm->mmap_sem);
25945 + limit = mm->context.user_cs_limit;
25946 + if (limit < TASK_SIZE) {
25947 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25948 + up_write(&mm->mmap_sem);
25949 + return;
25950 + }
25951 + up_write(&mm->mmap_sem);
25952 + }
25953 +#endif
25954 +
25955 tsk->thread.error_code = error_code;
25956 tsk->thread.trap_nr = X86_TRAP_GP;
25957
25958 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25959 /* It's safe to allow irq's after DR6 has been saved */
25960 preempt_conditional_sti(regs);
25961
25962 - if (regs->flags & X86_VM_MASK) {
25963 + if (v8086_mode(regs)) {
25964 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
25965 X86_TRAP_DB);
25966 preempt_conditional_cli(regs);
25967 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25968 * We already checked v86 mode above, so we can check for kernel mode
25969 * by just checking the CPL of CS.
25970 */
25971 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
25972 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
25973 tsk->thread.debugreg6 &= ~DR_STEP;
25974 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
25975 regs->flags &= ~X86_EFLAGS_TF;
25976 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
25977 return;
25978 conditional_sti(regs);
25979
25980 - if (!user_mode_vm(regs))
25981 + if (!user_mode(regs))
25982 {
25983 if (!fixup_exception(regs)) {
25984 task->thread.error_code = error_code;
25985 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
25986 index 2ed8459..7cf329f 100644
25987 --- a/arch/x86/kernel/uprobes.c
25988 +++ b/arch/x86/kernel/uprobes.c
25989 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
25990 int ret = NOTIFY_DONE;
25991
25992 /* We are only interested in userspace traps */
25993 - if (regs && !user_mode_vm(regs))
25994 + if (regs && !user_mode(regs))
25995 return NOTIFY_DONE;
25996
25997 switch (val) {
25998 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
25999
26000 if (ncopied != rasize) {
26001 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26002 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26003 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26004
26005 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26006 }
26007 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26008 index b9242ba..50c5edd 100644
26009 --- a/arch/x86/kernel/verify_cpu.S
26010 +++ b/arch/x86/kernel/verify_cpu.S
26011 @@ -20,6 +20,7 @@
26012 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26013 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26014 * arch/x86/kernel/head_32.S: processor startup
26015 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26016 *
26017 * verify_cpu, returns the status of longmode and SSE in register %eax.
26018 * 0: Success 1: Failure
26019 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26020 index e8edcf5..27f9344 100644
26021 --- a/arch/x86/kernel/vm86_32.c
26022 +++ b/arch/x86/kernel/vm86_32.c
26023 @@ -44,6 +44,7 @@
26024 #include <linux/ptrace.h>
26025 #include <linux/audit.h>
26026 #include <linux/stddef.h>
26027 +#include <linux/grsecurity.h>
26028
26029 #include <asm/uaccess.h>
26030 #include <asm/io.h>
26031 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26032 do_exit(SIGSEGV);
26033 }
26034
26035 - tss = &per_cpu(init_tss, get_cpu());
26036 + tss = init_tss + get_cpu();
26037 current->thread.sp0 = current->thread.saved_sp0;
26038 current->thread.sysenter_cs = __KERNEL_CS;
26039 load_sp0(tss, &current->thread);
26040 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26041
26042 if (tsk->thread.saved_sp0)
26043 return -EPERM;
26044 +
26045 +#ifdef CONFIG_GRKERNSEC_VM86
26046 + if (!capable(CAP_SYS_RAWIO)) {
26047 + gr_handle_vm86();
26048 + return -EPERM;
26049 + }
26050 +#endif
26051 +
26052 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26053 offsetof(struct kernel_vm86_struct, vm86plus) -
26054 sizeof(info.regs));
26055 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26056 int tmp;
26057 struct vm86plus_struct __user *v86;
26058
26059 +#ifdef CONFIG_GRKERNSEC_VM86
26060 + if (!capable(CAP_SYS_RAWIO)) {
26061 + gr_handle_vm86();
26062 + return -EPERM;
26063 + }
26064 +#endif
26065 +
26066 tsk = current;
26067 switch (cmd) {
26068 case VM86_REQUEST_IRQ:
26069 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26070 tsk->thread.saved_fs = info->regs32->fs;
26071 tsk->thread.saved_gs = get_user_gs(info->regs32);
26072
26073 - tss = &per_cpu(init_tss, get_cpu());
26074 + tss = init_tss + get_cpu();
26075 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26076 if (cpu_has_sep)
26077 tsk->thread.sysenter_cs = 0;
26078 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26079 goto cannot_handle;
26080 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26081 goto cannot_handle;
26082 - intr_ptr = (unsigned long __user *) (i << 2);
26083 + intr_ptr = (__force unsigned long __user *) (i << 2);
26084 if (get_user(segoffs, intr_ptr))
26085 goto cannot_handle;
26086 if ((segoffs >> 16) == BIOSSEG)
26087 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26088 index 10c4f30..65408b9 100644
26089 --- a/arch/x86/kernel/vmlinux.lds.S
26090 +++ b/arch/x86/kernel/vmlinux.lds.S
26091 @@ -26,6 +26,13 @@
26092 #include <asm/page_types.h>
26093 #include <asm/cache.h>
26094 #include <asm/boot.h>
26095 +#include <asm/segment.h>
26096 +
26097 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26098 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26099 +#else
26100 +#define __KERNEL_TEXT_OFFSET 0
26101 +#endif
26102
26103 #undef i386 /* in case the preprocessor is a 32bit one */
26104
26105 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26106
26107 PHDRS {
26108 text PT_LOAD FLAGS(5); /* R_E */
26109 +#ifdef CONFIG_X86_32
26110 + module PT_LOAD FLAGS(5); /* R_E */
26111 +#endif
26112 +#ifdef CONFIG_XEN
26113 + rodata PT_LOAD FLAGS(5); /* R_E */
26114 +#else
26115 + rodata PT_LOAD FLAGS(4); /* R__ */
26116 +#endif
26117 data PT_LOAD FLAGS(6); /* RW_ */
26118 -#ifdef CONFIG_X86_64
26119 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26120 #ifdef CONFIG_SMP
26121 percpu PT_LOAD FLAGS(6); /* RW_ */
26122 #endif
26123 + text.init PT_LOAD FLAGS(5); /* R_E */
26124 + text.exit PT_LOAD FLAGS(5); /* R_E */
26125 init PT_LOAD FLAGS(7); /* RWE */
26126 -#endif
26127 note PT_NOTE FLAGS(0); /* ___ */
26128 }
26129
26130 SECTIONS
26131 {
26132 #ifdef CONFIG_X86_32
26133 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26134 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26135 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26136 #else
26137 - . = __START_KERNEL;
26138 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26139 + . = __START_KERNEL;
26140 #endif
26141
26142 /* Text and read-only data */
26143 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26144 - _text = .;
26145 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26146 /* bootstrapping code */
26147 +#ifdef CONFIG_X86_32
26148 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26149 +#else
26150 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26151 +#endif
26152 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26153 + _text = .;
26154 HEAD_TEXT
26155 . = ALIGN(8);
26156 _stext = .;
26157 @@ -104,13 +124,47 @@ SECTIONS
26158 IRQENTRY_TEXT
26159 *(.fixup)
26160 *(.gnu.warning)
26161 - /* End of text section */
26162 - _etext = .;
26163 } :text = 0x9090
26164
26165 - NOTES :text :note
26166 + . += __KERNEL_TEXT_OFFSET;
26167
26168 - EXCEPTION_TABLE(16) :text = 0x9090
26169 +#ifdef CONFIG_X86_32
26170 + . = ALIGN(PAGE_SIZE);
26171 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26172 +
26173 +#ifdef CONFIG_PAX_KERNEXEC
26174 + MODULES_EXEC_VADDR = .;
26175 + BYTE(0)
26176 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26177 + . = ALIGN(HPAGE_SIZE) - 1;
26178 + MODULES_EXEC_END = .;
26179 +#endif
26180 +
26181 + } :module
26182 +#endif
26183 +
26184 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26185 + /* End of text section */
26186 + BYTE(0)
26187 + _etext = . - __KERNEL_TEXT_OFFSET;
26188 + }
26189 +
26190 +#ifdef CONFIG_X86_32
26191 + . = ALIGN(PAGE_SIZE);
26192 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26193 + . = ALIGN(PAGE_SIZE);
26194 + *(.empty_zero_page)
26195 + *(.initial_pg_fixmap)
26196 + *(.initial_pg_pmd)
26197 + *(.initial_page_table)
26198 + *(.swapper_pg_dir)
26199 + } :rodata
26200 +#endif
26201 +
26202 + . = ALIGN(PAGE_SIZE);
26203 + NOTES :rodata :note
26204 +
26205 + EXCEPTION_TABLE(16) :rodata
26206
26207 #if defined(CONFIG_DEBUG_RODATA)
26208 /* .text should occupy whole number of pages */
26209 @@ -122,16 +176,20 @@ SECTIONS
26210
26211 /* Data */
26212 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26213 +
26214 +#ifdef CONFIG_PAX_KERNEXEC
26215 + . = ALIGN(HPAGE_SIZE);
26216 +#else
26217 + . = ALIGN(PAGE_SIZE);
26218 +#endif
26219 +
26220 /* Start of data section */
26221 _sdata = .;
26222
26223 /* init_task */
26224 INIT_TASK_DATA(THREAD_SIZE)
26225
26226 -#ifdef CONFIG_X86_32
26227 - /* 32 bit has nosave before _edata */
26228 NOSAVE_DATA
26229 -#endif
26230
26231 PAGE_ALIGNED_DATA(PAGE_SIZE)
26232
26233 @@ -172,12 +230,19 @@ SECTIONS
26234 #endif /* CONFIG_X86_64 */
26235
26236 /* Init code and data - will be freed after init */
26237 - . = ALIGN(PAGE_SIZE);
26238 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26239 + BYTE(0)
26240 +
26241 +#ifdef CONFIG_PAX_KERNEXEC
26242 + . = ALIGN(HPAGE_SIZE);
26243 +#else
26244 + . = ALIGN(PAGE_SIZE);
26245 +#endif
26246 +
26247 __init_begin = .; /* paired with __init_end */
26248 - }
26249 + } :init.begin
26250
26251 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26252 +#ifdef CONFIG_SMP
26253 /*
26254 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26255 * output PHDR, so the next output section - .init.text - should
26256 @@ -186,12 +251,27 @@ SECTIONS
26257 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26258 #endif
26259
26260 - INIT_TEXT_SECTION(PAGE_SIZE)
26261 -#ifdef CONFIG_X86_64
26262 - :init
26263 -#endif
26264 + . = ALIGN(PAGE_SIZE);
26265 + init_begin = .;
26266 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26267 + VMLINUX_SYMBOL(_sinittext) = .;
26268 + INIT_TEXT
26269 + VMLINUX_SYMBOL(_einittext) = .;
26270 + . = ALIGN(PAGE_SIZE);
26271 + } :text.init
26272
26273 - INIT_DATA_SECTION(16)
26274 + /*
26275 + * .exit.text is discard at runtime, not link time, to deal with
26276 + * references from .altinstructions and .eh_frame
26277 + */
26278 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26279 + EXIT_TEXT
26280 + . = ALIGN(16);
26281 + } :text.exit
26282 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26283 +
26284 + . = ALIGN(PAGE_SIZE);
26285 + INIT_DATA_SECTION(16) :init
26286
26287 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26288 __x86_cpu_dev_start = .;
26289 @@ -253,19 +333,12 @@ SECTIONS
26290 }
26291
26292 . = ALIGN(8);
26293 - /*
26294 - * .exit.text is discard at runtime, not link time, to deal with
26295 - * references from .altinstructions and .eh_frame
26296 - */
26297 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26298 - EXIT_TEXT
26299 - }
26300
26301 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26302 EXIT_DATA
26303 }
26304
26305 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26306 +#ifndef CONFIG_SMP
26307 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26308 #endif
26309
26310 @@ -284,16 +357,10 @@ SECTIONS
26311 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26312 __smp_locks = .;
26313 *(.smp_locks)
26314 - . = ALIGN(PAGE_SIZE);
26315 __smp_locks_end = .;
26316 + . = ALIGN(PAGE_SIZE);
26317 }
26318
26319 -#ifdef CONFIG_X86_64
26320 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26321 - NOSAVE_DATA
26322 - }
26323 -#endif
26324 -
26325 /* BSS */
26326 . = ALIGN(PAGE_SIZE);
26327 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26328 @@ -309,6 +376,7 @@ SECTIONS
26329 __brk_base = .;
26330 . += 64 * 1024; /* 64k alignment slop space */
26331 *(.brk_reservation) /* areas brk users have reserved */
26332 + . = ALIGN(HPAGE_SIZE);
26333 __brk_limit = .;
26334 }
26335
26336 @@ -335,13 +403,12 @@ SECTIONS
26337 * for the boot processor.
26338 */
26339 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26340 -INIT_PER_CPU(gdt_page);
26341 INIT_PER_CPU(irq_stack_union);
26342
26343 /*
26344 * Build-time check on the image size:
26345 */
26346 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26347 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26348 "kernel image bigger than KERNEL_IMAGE_SIZE");
26349
26350 #ifdef CONFIG_SMP
26351 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26352 index 1f96f93..d5c8f7a 100644
26353 --- a/arch/x86/kernel/vsyscall_64.c
26354 +++ b/arch/x86/kernel/vsyscall_64.c
26355 @@ -56,15 +56,13 @@
26356 DEFINE_VVAR(int, vgetcpu_mode);
26357 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26358
26359 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26360 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26361
26362 static int __init vsyscall_setup(char *str)
26363 {
26364 if (str) {
26365 if (!strcmp("emulate", str))
26366 vsyscall_mode = EMULATE;
26367 - else if (!strcmp("native", str))
26368 - vsyscall_mode = NATIVE;
26369 else if (!strcmp("none", str))
26370 vsyscall_mode = NONE;
26371 else
26372 @@ -323,8 +321,7 @@ do_ret:
26373 return true;
26374
26375 sigsegv:
26376 - force_sig(SIGSEGV, current);
26377 - return true;
26378 + do_group_exit(SIGKILL);
26379 }
26380
26381 /*
26382 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26383 extern char __vvar_page;
26384 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26385
26386 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26387 - vsyscall_mode == NATIVE
26388 - ? PAGE_KERNEL_VSYSCALL
26389 - : PAGE_KERNEL_VVAR);
26390 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26391 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26392 (unsigned long)VSYSCALL_START);
26393
26394 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26395 index b014d94..e775258 100644
26396 --- a/arch/x86/kernel/x8664_ksyms_64.c
26397 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26398 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26399 EXPORT_SYMBOL(copy_user_generic_unrolled);
26400 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26401 EXPORT_SYMBOL(__copy_user_nocache);
26402 -EXPORT_SYMBOL(_copy_from_user);
26403 -EXPORT_SYMBOL(_copy_to_user);
26404
26405 EXPORT_SYMBOL(copy_page);
26406 EXPORT_SYMBOL(clear_page);
26407 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26408 #ifndef CONFIG_PARAVIRT
26409 EXPORT_SYMBOL(native_load_gs_index);
26410 #endif
26411 +
26412 +#ifdef CONFIG_PAX_PER_CPU_PGD
26413 +EXPORT_SYMBOL(cpu_pgd);
26414 +#endif
26415 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26416 index 5f24c71..1dadf09 100644
26417 --- a/arch/x86/kernel/x86_init.c
26418 +++ b/arch/x86/kernel/x86_init.c
26419 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26420 static void default_nmi_init(void) { };
26421 static int default_i8042_detect(void) { return 1; };
26422
26423 -struct x86_platform_ops x86_platform = {
26424 +struct x86_platform_ops x86_platform __read_only = {
26425 .calibrate_tsc = native_calibrate_tsc,
26426 .get_wallclock = mach_get_cmos_time,
26427 .set_wallclock = mach_set_rtc_mmss,
26428 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26429 };
26430
26431 EXPORT_SYMBOL_GPL(x86_platform);
26432 -struct x86_msi_ops x86_msi = {
26433 +struct x86_msi_ops x86_msi __read_only = {
26434 .setup_msi_irqs = native_setup_msi_irqs,
26435 .compose_msi_msg = native_compose_msi_msg,
26436 .teardown_msi_irq = native_teardown_msi_irq,
26437 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26438 .setup_hpet_msi = default_setup_hpet_msi,
26439 };
26440
26441 -struct x86_io_apic_ops x86_io_apic_ops = {
26442 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26443 .init = native_io_apic_init_mappings,
26444 .read = native_io_apic_read,
26445 .write = native_io_apic_write,
26446 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26447 index 422fd82..c3687ca 100644
26448 --- a/arch/x86/kernel/xsave.c
26449 +++ b/arch/x86/kernel/xsave.c
26450 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26451 {
26452 int err;
26453
26454 + buf = (struct xsave_struct __user *)____m(buf);
26455 if (use_xsave())
26456 err = xsave_user(buf);
26457 else if (use_fxsr())
26458 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26459 */
26460 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26461 {
26462 + buf = (void __user *)____m(buf);
26463 if (use_xsave()) {
26464 if ((unsigned long)buf % 64 || fx_only) {
26465 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26466 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26467 index a20ecb5..d0e2194 100644
26468 --- a/arch/x86/kvm/cpuid.c
26469 +++ b/arch/x86/kvm/cpuid.c
26470 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26471 struct kvm_cpuid2 *cpuid,
26472 struct kvm_cpuid_entry2 __user *entries)
26473 {
26474 - int r;
26475 + int r, i;
26476
26477 r = -E2BIG;
26478 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26479 goto out;
26480 r = -EFAULT;
26481 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26482 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26483 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26484 goto out;
26485 + for (i = 0; i < cpuid->nent; ++i) {
26486 + struct kvm_cpuid_entry2 cpuid_entry;
26487 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26488 + goto out;
26489 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26490 + }
26491 vcpu->arch.cpuid_nent = cpuid->nent;
26492 kvm_apic_set_version(vcpu);
26493 kvm_x86_ops->cpuid_update(vcpu);
26494 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26495 struct kvm_cpuid2 *cpuid,
26496 struct kvm_cpuid_entry2 __user *entries)
26497 {
26498 - int r;
26499 + int r, i;
26500
26501 r = -E2BIG;
26502 if (cpuid->nent < vcpu->arch.cpuid_nent)
26503 goto out;
26504 r = -EFAULT;
26505 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26506 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26507 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26508 goto out;
26509 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26510 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26511 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26512 + goto out;
26513 + }
26514 return 0;
26515
26516 out:
26517 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26518 index afc1124..3e431f2 100644
26519 --- a/arch/x86/kvm/lapic.c
26520 +++ b/arch/x86/kvm/lapic.c
26521 @@ -55,7 +55,7 @@
26522 #define APIC_BUS_CYCLE_NS 1
26523
26524 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26525 -#define apic_debug(fmt, arg...)
26526 +#define apic_debug(fmt, arg...) do {} while (0)
26527
26528 #define APIC_LVT_NUM 6
26529 /* 14 is the version for Xeon and Pentium 8.4.8*/
26530 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26531 index 7769699..c8aca4a7f 100644
26532 --- a/arch/x86/kvm/paging_tmpl.h
26533 +++ b/arch/x86/kvm/paging_tmpl.h
26534 @@ -208,7 +208,7 @@ retry_walk:
26535 if (unlikely(kvm_is_error_hva(host_addr)))
26536 goto error;
26537
26538 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26539 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26540 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26541 goto error;
26542 walker->ptep_user[walker->level - 1] = ptep_user;
26543 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26544 index c0bc803..6837a50 100644
26545 --- a/arch/x86/kvm/svm.c
26546 +++ b/arch/x86/kvm/svm.c
26547 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26548 int cpu = raw_smp_processor_id();
26549
26550 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26551 +
26552 + pax_open_kernel();
26553 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26554 + pax_close_kernel();
26555 +
26556 load_TR_desc();
26557 }
26558
26559 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26560 #endif
26561 #endif
26562
26563 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26564 + __set_fs(current_thread_info()->addr_limit);
26565 +#endif
26566 +
26567 reload_tss(vcpu);
26568
26569 local_irq_disable();
26570 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26571 index 064d0be..f5f758e 100644
26572 --- a/arch/x86/kvm/vmx.c
26573 +++ b/arch/x86/kvm/vmx.c
26574 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26575 #endif
26576 }
26577
26578 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26579 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26580 {
26581 vmcs_writel(field, vmcs_readl(field) & ~mask);
26582 }
26583
26584 -static void vmcs_set_bits(unsigned long field, u32 mask)
26585 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26586 {
26587 vmcs_writel(field, vmcs_readl(field) | mask);
26588 }
26589 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26590 struct desc_struct *descs;
26591
26592 descs = (void *)gdt->address;
26593 +
26594 + pax_open_kernel();
26595 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26596 + pax_close_kernel();
26597 +
26598 load_TR_desc();
26599 }
26600
26601 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26602 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26603 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26604
26605 +#ifdef CONFIG_PAX_PER_CPU_PGD
26606 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26607 +#endif
26608 +
26609 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26610 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26611 vmx->loaded_vmcs->cpu = cpu;
26612 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26613 if (!cpu_has_vmx_flexpriority())
26614 flexpriority_enabled = 0;
26615
26616 - if (!cpu_has_vmx_tpr_shadow())
26617 - kvm_x86_ops->update_cr8_intercept = NULL;
26618 + if (!cpu_has_vmx_tpr_shadow()) {
26619 + pax_open_kernel();
26620 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26621 + pax_close_kernel();
26622 + }
26623
26624 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26625 kvm_disable_largepages();
26626 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26627 if (!cpu_has_vmx_apicv())
26628 enable_apicv = 0;
26629
26630 + pax_open_kernel();
26631 if (enable_apicv)
26632 - kvm_x86_ops->update_cr8_intercept = NULL;
26633 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26634 else {
26635 - kvm_x86_ops->hwapic_irr_update = NULL;
26636 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26637 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26638 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26639 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26640 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26641 }
26642 + pax_close_kernel();
26643
26644 if (nested)
26645 nested_vmx_setup_ctls_msrs();
26646 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26647
26648 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26649 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26650 +
26651 +#ifndef CONFIG_PAX_PER_CPU_PGD
26652 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26653 +#endif
26654
26655 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26656 #ifdef CONFIG_X86_64
26657 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26658 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26659 vmx->host_idt_base = dt.address;
26660
26661 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26662 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26663
26664 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26665 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26666 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26667 "jmp 2f \n\t"
26668 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26669 "2: "
26670 +
26671 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26672 + "ljmp %[cs],$3f\n\t"
26673 + "3: "
26674 +#endif
26675 +
26676 /* Save guest registers, load host registers, keep flags */
26677 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26678 "pop %0 \n\t"
26679 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26680 #endif
26681 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26682 [wordsize]"i"(sizeof(ulong))
26683 +
26684 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26685 + ,[cs]"i"(__KERNEL_CS)
26686 +#endif
26687 +
26688 : "cc", "memory"
26689 #ifdef CONFIG_X86_64
26690 , "rax", "rbx", "rdi", "rsi"
26691 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26692 if (debugctlmsr)
26693 update_debugctlmsr(debugctlmsr);
26694
26695 -#ifndef CONFIG_X86_64
26696 +#ifdef CONFIG_X86_32
26697 /*
26698 * The sysexit path does not restore ds/es, so we must set them to
26699 * a reasonable value ourselves.
26700 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26701 * may be executed in interrupt context, which saves and restore segments
26702 * around it, nullifying its effect.
26703 */
26704 - loadsegment(ds, __USER_DS);
26705 - loadsegment(es, __USER_DS);
26706 + loadsegment(ds, __KERNEL_DS);
26707 + loadsegment(es, __KERNEL_DS);
26708 + loadsegment(ss, __KERNEL_DS);
26709 +
26710 +#ifdef CONFIG_PAX_KERNEXEC
26711 + loadsegment(fs, __KERNEL_PERCPU);
26712 +#endif
26713 +
26714 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26715 + __set_fs(current_thread_info()->addr_limit);
26716 +#endif
26717 +
26718 #endif
26719
26720 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26721 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26722 index d21bce5..fdae9f1 100644
26723 --- a/arch/x86/kvm/x86.c
26724 +++ b/arch/x86/kvm/x86.c
26725 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26726 {
26727 struct kvm *kvm = vcpu->kvm;
26728 int lm = is_long_mode(vcpu);
26729 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26730 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26731 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26732 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26733 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26734 : kvm->arch.xen_hvm_config.blob_size_32;
26735 u32 page_num = data & ~PAGE_MASK;
26736 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26737 if (n < msr_list.nmsrs)
26738 goto out;
26739 r = -EFAULT;
26740 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26741 + goto out;
26742 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26743 num_msrs_to_save * sizeof(u32)))
26744 goto out;
26745 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26746 };
26747 #endif
26748
26749 -int kvm_arch_init(void *opaque)
26750 +int kvm_arch_init(const void *opaque)
26751 {
26752 int r;
26753 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26754 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26755 index 6a22c19..1763f04 100644
26756 --- a/arch/x86/lguest/boot.c
26757 +++ b/arch/x86/lguest/boot.c
26758 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26759 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26760 * Launcher to reboot us.
26761 */
26762 -static void lguest_restart(char *reason)
26763 +static __noreturn void lguest_restart(char *reason)
26764 {
26765 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26766 + BUG();
26767 }
26768
26769 /*G:050
26770 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26771 index 00933d5..3a64af9 100644
26772 --- a/arch/x86/lib/atomic64_386_32.S
26773 +++ b/arch/x86/lib/atomic64_386_32.S
26774 @@ -48,6 +48,10 @@ BEGIN(read)
26775 movl (v), %eax
26776 movl 4(v), %edx
26777 RET_ENDP
26778 +BEGIN(read_unchecked)
26779 + movl (v), %eax
26780 + movl 4(v), %edx
26781 +RET_ENDP
26782 #undef v
26783
26784 #define v %esi
26785 @@ -55,6 +59,10 @@ BEGIN(set)
26786 movl %ebx, (v)
26787 movl %ecx, 4(v)
26788 RET_ENDP
26789 +BEGIN(set_unchecked)
26790 + movl %ebx, (v)
26791 + movl %ecx, 4(v)
26792 +RET_ENDP
26793 #undef v
26794
26795 #define v %esi
26796 @@ -70,6 +78,20 @@ RET_ENDP
26797 BEGIN(add)
26798 addl %eax, (v)
26799 adcl %edx, 4(v)
26800 +
26801 +#ifdef CONFIG_PAX_REFCOUNT
26802 + jno 0f
26803 + subl %eax, (v)
26804 + sbbl %edx, 4(v)
26805 + int $4
26806 +0:
26807 + _ASM_EXTABLE(0b, 0b)
26808 +#endif
26809 +
26810 +RET_ENDP
26811 +BEGIN(add_unchecked)
26812 + addl %eax, (v)
26813 + adcl %edx, 4(v)
26814 RET_ENDP
26815 #undef v
26816
26817 @@ -77,6 +99,24 @@ RET_ENDP
26818 BEGIN(add_return)
26819 addl (v), %eax
26820 adcl 4(v), %edx
26821 +
26822 +#ifdef CONFIG_PAX_REFCOUNT
26823 + into
26824 +1234:
26825 + _ASM_EXTABLE(1234b, 2f)
26826 +#endif
26827 +
26828 + movl %eax, (v)
26829 + movl %edx, 4(v)
26830 +
26831 +#ifdef CONFIG_PAX_REFCOUNT
26832 +2:
26833 +#endif
26834 +
26835 +RET_ENDP
26836 +BEGIN(add_return_unchecked)
26837 + addl (v), %eax
26838 + adcl 4(v), %edx
26839 movl %eax, (v)
26840 movl %edx, 4(v)
26841 RET_ENDP
26842 @@ -86,6 +126,20 @@ RET_ENDP
26843 BEGIN(sub)
26844 subl %eax, (v)
26845 sbbl %edx, 4(v)
26846 +
26847 +#ifdef CONFIG_PAX_REFCOUNT
26848 + jno 0f
26849 + addl %eax, (v)
26850 + adcl %edx, 4(v)
26851 + int $4
26852 +0:
26853 + _ASM_EXTABLE(0b, 0b)
26854 +#endif
26855 +
26856 +RET_ENDP
26857 +BEGIN(sub_unchecked)
26858 + subl %eax, (v)
26859 + sbbl %edx, 4(v)
26860 RET_ENDP
26861 #undef v
26862
26863 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26864 sbbl $0, %edx
26865 addl (v), %eax
26866 adcl 4(v), %edx
26867 +
26868 +#ifdef CONFIG_PAX_REFCOUNT
26869 + into
26870 +1234:
26871 + _ASM_EXTABLE(1234b, 2f)
26872 +#endif
26873 +
26874 + movl %eax, (v)
26875 + movl %edx, 4(v)
26876 +
26877 +#ifdef CONFIG_PAX_REFCOUNT
26878 +2:
26879 +#endif
26880 +
26881 +RET_ENDP
26882 +BEGIN(sub_return_unchecked)
26883 + negl %edx
26884 + negl %eax
26885 + sbbl $0, %edx
26886 + addl (v), %eax
26887 + adcl 4(v), %edx
26888 movl %eax, (v)
26889 movl %edx, 4(v)
26890 RET_ENDP
26891 @@ -105,6 +180,20 @@ RET_ENDP
26892 BEGIN(inc)
26893 addl $1, (v)
26894 adcl $0, 4(v)
26895 +
26896 +#ifdef CONFIG_PAX_REFCOUNT
26897 + jno 0f
26898 + subl $1, (v)
26899 + sbbl $0, 4(v)
26900 + int $4
26901 +0:
26902 + _ASM_EXTABLE(0b, 0b)
26903 +#endif
26904 +
26905 +RET_ENDP
26906 +BEGIN(inc_unchecked)
26907 + addl $1, (v)
26908 + adcl $0, 4(v)
26909 RET_ENDP
26910 #undef v
26911
26912 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26913 movl 4(v), %edx
26914 addl $1, %eax
26915 adcl $0, %edx
26916 +
26917 +#ifdef CONFIG_PAX_REFCOUNT
26918 + into
26919 +1234:
26920 + _ASM_EXTABLE(1234b, 2f)
26921 +#endif
26922 +
26923 + movl %eax, (v)
26924 + movl %edx, 4(v)
26925 +
26926 +#ifdef CONFIG_PAX_REFCOUNT
26927 +2:
26928 +#endif
26929 +
26930 +RET_ENDP
26931 +BEGIN(inc_return_unchecked)
26932 + movl (v), %eax
26933 + movl 4(v), %edx
26934 + addl $1, %eax
26935 + adcl $0, %edx
26936 movl %eax, (v)
26937 movl %edx, 4(v)
26938 RET_ENDP
26939 @@ -123,6 +232,20 @@ RET_ENDP
26940 BEGIN(dec)
26941 subl $1, (v)
26942 sbbl $0, 4(v)
26943 +
26944 +#ifdef CONFIG_PAX_REFCOUNT
26945 + jno 0f
26946 + addl $1, (v)
26947 + adcl $0, 4(v)
26948 + int $4
26949 +0:
26950 + _ASM_EXTABLE(0b, 0b)
26951 +#endif
26952 +
26953 +RET_ENDP
26954 +BEGIN(dec_unchecked)
26955 + subl $1, (v)
26956 + sbbl $0, 4(v)
26957 RET_ENDP
26958 #undef v
26959
26960 @@ -132,6 +255,26 @@ BEGIN(dec_return)
26961 movl 4(v), %edx
26962 subl $1, %eax
26963 sbbl $0, %edx
26964 +
26965 +#ifdef CONFIG_PAX_REFCOUNT
26966 + into
26967 +1234:
26968 + _ASM_EXTABLE(1234b, 2f)
26969 +#endif
26970 +
26971 + movl %eax, (v)
26972 + movl %edx, 4(v)
26973 +
26974 +#ifdef CONFIG_PAX_REFCOUNT
26975 +2:
26976 +#endif
26977 +
26978 +RET_ENDP
26979 +BEGIN(dec_return_unchecked)
26980 + movl (v), %eax
26981 + movl 4(v), %edx
26982 + subl $1, %eax
26983 + sbbl $0, %edx
26984 movl %eax, (v)
26985 movl %edx, 4(v)
26986 RET_ENDP
26987 @@ -143,6 +286,13 @@ BEGIN(add_unless)
26988 adcl %edx, %edi
26989 addl (v), %eax
26990 adcl 4(v), %edx
26991 +
26992 +#ifdef CONFIG_PAX_REFCOUNT
26993 + into
26994 +1234:
26995 + _ASM_EXTABLE(1234b, 2f)
26996 +#endif
26997 +
26998 cmpl %eax, %ecx
26999 je 3f
27000 1:
27001 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27002 1:
27003 addl $1, %eax
27004 adcl $0, %edx
27005 +
27006 +#ifdef CONFIG_PAX_REFCOUNT
27007 + into
27008 +1234:
27009 + _ASM_EXTABLE(1234b, 2f)
27010 +#endif
27011 +
27012 movl %eax, (v)
27013 movl %edx, 4(v)
27014 movl $1, %eax
27015 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27016 movl 4(v), %edx
27017 subl $1, %eax
27018 sbbl $0, %edx
27019 +
27020 +#ifdef CONFIG_PAX_REFCOUNT
27021 + into
27022 +1234:
27023 + _ASM_EXTABLE(1234b, 1f)
27024 +#endif
27025 +
27026 js 1f
27027 movl %eax, (v)
27028 movl %edx, 4(v)
27029 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27030 index f5cc9eb..51fa319 100644
27031 --- a/arch/x86/lib/atomic64_cx8_32.S
27032 +++ b/arch/x86/lib/atomic64_cx8_32.S
27033 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27034 CFI_STARTPROC
27035
27036 read64 %ecx
27037 + pax_force_retaddr
27038 ret
27039 CFI_ENDPROC
27040 ENDPROC(atomic64_read_cx8)
27041
27042 +ENTRY(atomic64_read_unchecked_cx8)
27043 + CFI_STARTPROC
27044 +
27045 + read64 %ecx
27046 + pax_force_retaddr
27047 + ret
27048 + CFI_ENDPROC
27049 +ENDPROC(atomic64_read_unchecked_cx8)
27050 +
27051 ENTRY(atomic64_set_cx8)
27052 CFI_STARTPROC
27053
27054 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27055 cmpxchg8b (%esi)
27056 jne 1b
27057
27058 + pax_force_retaddr
27059 ret
27060 CFI_ENDPROC
27061 ENDPROC(atomic64_set_cx8)
27062
27063 +ENTRY(atomic64_set_unchecked_cx8)
27064 + CFI_STARTPROC
27065 +
27066 +1:
27067 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27068 + * are atomic on 586 and newer */
27069 + cmpxchg8b (%esi)
27070 + jne 1b
27071 +
27072 + pax_force_retaddr
27073 + ret
27074 + CFI_ENDPROC
27075 +ENDPROC(atomic64_set_unchecked_cx8)
27076 +
27077 ENTRY(atomic64_xchg_cx8)
27078 CFI_STARTPROC
27079
27080 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27081 cmpxchg8b (%esi)
27082 jne 1b
27083
27084 + pax_force_retaddr
27085 ret
27086 CFI_ENDPROC
27087 ENDPROC(atomic64_xchg_cx8)
27088
27089 -.macro addsub_return func ins insc
27090 -ENTRY(atomic64_\func\()_return_cx8)
27091 +.macro addsub_return func ins insc unchecked=""
27092 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27093 CFI_STARTPROC
27094 SAVE ebp
27095 SAVE ebx
27096 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27097 movl %edx, %ecx
27098 \ins\()l %esi, %ebx
27099 \insc\()l %edi, %ecx
27100 +
27101 +.ifb \unchecked
27102 +#ifdef CONFIG_PAX_REFCOUNT
27103 + into
27104 +2:
27105 + _ASM_EXTABLE(2b, 3f)
27106 +#endif
27107 +.endif
27108 +
27109 LOCK_PREFIX
27110 cmpxchg8b (%ebp)
27111 jne 1b
27112 -
27113 -10:
27114 movl %ebx, %eax
27115 movl %ecx, %edx
27116 +
27117 +.ifb \unchecked
27118 +#ifdef CONFIG_PAX_REFCOUNT
27119 +3:
27120 +#endif
27121 +.endif
27122 +
27123 RESTORE edi
27124 RESTORE esi
27125 RESTORE ebx
27126 RESTORE ebp
27127 + pax_force_retaddr
27128 ret
27129 CFI_ENDPROC
27130 -ENDPROC(atomic64_\func\()_return_cx8)
27131 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27132 .endm
27133
27134 addsub_return add add adc
27135 addsub_return sub sub sbb
27136 +addsub_return add add adc _unchecked
27137 +addsub_return sub sub sbb _unchecked
27138
27139 -.macro incdec_return func ins insc
27140 -ENTRY(atomic64_\func\()_return_cx8)
27141 +.macro incdec_return func ins insc unchecked=""
27142 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27143 CFI_STARTPROC
27144 SAVE ebx
27145
27146 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27147 movl %edx, %ecx
27148 \ins\()l $1, %ebx
27149 \insc\()l $0, %ecx
27150 +
27151 +.ifb \unchecked
27152 +#ifdef CONFIG_PAX_REFCOUNT
27153 + into
27154 +2:
27155 + _ASM_EXTABLE(2b, 3f)
27156 +#endif
27157 +.endif
27158 +
27159 LOCK_PREFIX
27160 cmpxchg8b (%esi)
27161 jne 1b
27162
27163 -10:
27164 movl %ebx, %eax
27165 movl %ecx, %edx
27166 +
27167 +.ifb \unchecked
27168 +#ifdef CONFIG_PAX_REFCOUNT
27169 +3:
27170 +#endif
27171 +.endif
27172 +
27173 RESTORE ebx
27174 + pax_force_retaddr
27175 ret
27176 CFI_ENDPROC
27177 -ENDPROC(atomic64_\func\()_return_cx8)
27178 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27179 .endm
27180
27181 incdec_return inc add adc
27182 incdec_return dec sub sbb
27183 +incdec_return inc add adc _unchecked
27184 +incdec_return dec sub sbb _unchecked
27185
27186 ENTRY(atomic64_dec_if_positive_cx8)
27187 CFI_STARTPROC
27188 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27189 movl %edx, %ecx
27190 subl $1, %ebx
27191 sbb $0, %ecx
27192 +
27193 +#ifdef CONFIG_PAX_REFCOUNT
27194 + into
27195 +1234:
27196 + _ASM_EXTABLE(1234b, 2f)
27197 +#endif
27198 +
27199 js 2f
27200 LOCK_PREFIX
27201 cmpxchg8b (%esi)
27202 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27203 movl %ebx, %eax
27204 movl %ecx, %edx
27205 RESTORE ebx
27206 + pax_force_retaddr
27207 ret
27208 CFI_ENDPROC
27209 ENDPROC(atomic64_dec_if_positive_cx8)
27210 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27211 movl %edx, %ecx
27212 addl %ebp, %ebx
27213 adcl %edi, %ecx
27214 +
27215 +#ifdef CONFIG_PAX_REFCOUNT
27216 + into
27217 +1234:
27218 + _ASM_EXTABLE(1234b, 3f)
27219 +#endif
27220 +
27221 LOCK_PREFIX
27222 cmpxchg8b (%esi)
27223 jne 1b
27224 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27225 CFI_ADJUST_CFA_OFFSET -8
27226 RESTORE ebx
27227 RESTORE ebp
27228 + pax_force_retaddr
27229 ret
27230 4:
27231 cmpl %edx, 4(%esp)
27232 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27233 xorl %ecx, %ecx
27234 addl $1, %ebx
27235 adcl %edx, %ecx
27236 +
27237 +#ifdef CONFIG_PAX_REFCOUNT
27238 + into
27239 +1234:
27240 + _ASM_EXTABLE(1234b, 3f)
27241 +#endif
27242 +
27243 LOCK_PREFIX
27244 cmpxchg8b (%esi)
27245 jne 1b
27246 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27247 movl $1, %eax
27248 3:
27249 RESTORE ebx
27250 + pax_force_retaddr
27251 ret
27252 CFI_ENDPROC
27253 ENDPROC(atomic64_inc_not_zero_cx8)
27254 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27255 index e78b8ee..7e173a8 100644
27256 --- a/arch/x86/lib/checksum_32.S
27257 +++ b/arch/x86/lib/checksum_32.S
27258 @@ -29,7 +29,8 @@
27259 #include <asm/dwarf2.h>
27260 #include <asm/errno.h>
27261 #include <asm/asm.h>
27262 -
27263 +#include <asm/segment.h>
27264 +
27265 /*
27266 * computes a partial checksum, e.g. for TCP/UDP fragments
27267 */
27268 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27269
27270 #define ARGBASE 16
27271 #define FP 12
27272 -
27273 -ENTRY(csum_partial_copy_generic)
27274 +
27275 +ENTRY(csum_partial_copy_generic_to_user)
27276 CFI_STARTPROC
27277 +
27278 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27279 + pushl_cfi %gs
27280 + popl_cfi %es
27281 + jmp csum_partial_copy_generic
27282 +#endif
27283 +
27284 +ENTRY(csum_partial_copy_generic_from_user)
27285 +
27286 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27287 + pushl_cfi %gs
27288 + popl_cfi %ds
27289 +#endif
27290 +
27291 +ENTRY(csum_partial_copy_generic)
27292 subl $4,%esp
27293 CFI_ADJUST_CFA_OFFSET 4
27294 pushl_cfi %edi
27295 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27296 jmp 4f
27297 SRC(1: movw (%esi), %bx )
27298 addl $2, %esi
27299 -DST( movw %bx, (%edi) )
27300 +DST( movw %bx, %es:(%edi) )
27301 addl $2, %edi
27302 addw %bx, %ax
27303 adcl $0, %eax
27304 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27305 SRC(1: movl (%esi), %ebx )
27306 SRC( movl 4(%esi), %edx )
27307 adcl %ebx, %eax
27308 -DST( movl %ebx, (%edi) )
27309 +DST( movl %ebx, %es:(%edi) )
27310 adcl %edx, %eax
27311 -DST( movl %edx, 4(%edi) )
27312 +DST( movl %edx, %es:4(%edi) )
27313
27314 SRC( movl 8(%esi), %ebx )
27315 SRC( movl 12(%esi), %edx )
27316 adcl %ebx, %eax
27317 -DST( movl %ebx, 8(%edi) )
27318 +DST( movl %ebx, %es:8(%edi) )
27319 adcl %edx, %eax
27320 -DST( movl %edx, 12(%edi) )
27321 +DST( movl %edx, %es:12(%edi) )
27322
27323 SRC( movl 16(%esi), %ebx )
27324 SRC( movl 20(%esi), %edx )
27325 adcl %ebx, %eax
27326 -DST( movl %ebx, 16(%edi) )
27327 +DST( movl %ebx, %es:16(%edi) )
27328 adcl %edx, %eax
27329 -DST( movl %edx, 20(%edi) )
27330 +DST( movl %edx, %es:20(%edi) )
27331
27332 SRC( movl 24(%esi), %ebx )
27333 SRC( movl 28(%esi), %edx )
27334 adcl %ebx, %eax
27335 -DST( movl %ebx, 24(%edi) )
27336 +DST( movl %ebx, %es:24(%edi) )
27337 adcl %edx, %eax
27338 -DST( movl %edx, 28(%edi) )
27339 +DST( movl %edx, %es:28(%edi) )
27340
27341 lea 32(%esi), %esi
27342 lea 32(%edi), %edi
27343 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27344 shrl $2, %edx # This clears CF
27345 SRC(3: movl (%esi), %ebx )
27346 adcl %ebx, %eax
27347 -DST( movl %ebx, (%edi) )
27348 +DST( movl %ebx, %es:(%edi) )
27349 lea 4(%esi), %esi
27350 lea 4(%edi), %edi
27351 dec %edx
27352 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27353 jb 5f
27354 SRC( movw (%esi), %cx )
27355 leal 2(%esi), %esi
27356 -DST( movw %cx, (%edi) )
27357 +DST( movw %cx, %es:(%edi) )
27358 leal 2(%edi), %edi
27359 je 6f
27360 shll $16,%ecx
27361 SRC(5: movb (%esi), %cl )
27362 -DST( movb %cl, (%edi) )
27363 +DST( movb %cl, %es:(%edi) )
27364 6: addl %ecx, %eax
27365 adcl $0, %eax
27366 7:
27367 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27368
27369 6001:
27370 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27371 - movl $-EFAULT, (%ebx)
27372 + movl $-EFAULT, %ss:(%ebx)
27373
27374 # zero the complete destination - computing the rest
27375 # is too much work
27376 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27377
27378 6002:
27379 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27380 - movl $-EFAULT,(%ebx)
27381 + movl $-EFAULT,%ss:(%ebx)
27382 jmp 5000b
27383
27384 .previous
27385
27386 + pushl_cfi %ss
27387 + popl_cfi %ds
27388 + pushl_cfi %ss
27389 + popl_cfi %es
27390 popl_cfi %ebx
27391 CFI_RESTORE ebx
27392 popl_cfi %esi
27393 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27394 popl_cfi %ecx # equivalent to addl $4,%esp
27395 ret
27396 CFI_ENDPROC
27397 -ENDPROC(csum_partial_copy_generic)
27398 +ENDPROC(csum_partial_copy_generic_to_user)
27399
27400 #else
27401
27402 /* Version for PentiumII/PPro */
27403
27404 #define ROUND1(x) \
27405 + nop; nop; nop; \
27406 SRC(movl x(%esi), %ebx ) ; \
27407 addl %ebx, %eax ; \
27408 - DST(movl %ebx, x(%edi) ) ;
27409 + DST(movl %ebx, %es:x(%edi)) ;
27410
27411 #define ROUND(x) \
27412 + nop; nop; nop; \
27413 SRC(movl x(%esi), %ebx ) ; \
27414 adcl %ebx, %eax ; \
27415 - DST(movl %ebx, x(%edi) ) ;
27416 + DST(movl %ebx, %es:x(%edi)) ;
27417
27418 #define ARGBASE 12
27419 -
27420 -ENTRY(csum_partial_copy_generic)
27421 +
27422 +ENTRY(csum_partial_copy_generic_to_user)
27423 CFI_STARTPROC
27424 +
27425 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27426 + pushl_cfi %gs
27427 + popl_cfi %es
27428 + jmp csum_partial_copy_generic
27429 +#endif
27430 +
27431 +ENTRY(csum_partial_copy_generic_from_user)
27432 +
27433 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27434 + pushl_cfi %gs
27435 + popl_cfi %ds
27436 +#endif
27437 +
27438 +ENTRY(csum_partial_copy_generic)
27439 pushl_cfi %ebx
27440 CFI_REL_OFFSET ebx, 0
27441 pushl_cfi %edi
27442 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27443 subl %ebx, %edi
27444 lea -1(%esi),%edx
27445 andl $-32,%edx
27446 - lea 3f(%ebx,%ebx), %ebx
27447 + lea 3f(%ebx,%ebx,2), %ebx
27448 testl %esi, %esi
27449 jmp *%ebx
27450 1: addl $64,%esi
27451 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27452 jb 5f
27453 SRC( movw (%esi), %dx )
27454 leal 2(%esi), %esi
27455 -DST( movw %dx, (%edi) )
27456 +DST( movw %dx, %es:(%edi) )
27457 leal 2(%edi), %edi
27458 je 6f
27459 shll $16,%edx
27460 5:
27461 SRC( movb (%esi), %dl )
27462 -DST( movb %dl, (%edi) )
27463 +DST( movb %dl, %es:(%edi) )
27464 6: addl %edx, %eax
27465 adcl $0, %eax
27466 7:
27467 .section .fixup, "ax"
27468 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27469 - movl $-EFAULT, (%ebx)
27470 + movl $-EFAULT, %ss:(%ebx)
27471 # zero the complete destination (computing the rest is too much work)
27472 movl ARGBASE+8(%esp),%edi # dst
27473 movl ARGBASE+12(%esp),%ecx # len
27474 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27475 rep; stosb
27476 jmp 7b
27477 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27478 - movl $-EFAULT, (%ebx)
27479 + movl $-EFAULT, %ss:(%ebx)
27480 jmp 7b
27481 .previous
27482
27483 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27484 + pushl_cfi %ss
27485 + popl_cfi %ds
27486 + pushl_cfi %ss
27487 + popl_cfi %es
27488 +#endif
27489 +
27490 popl_cfi %esi
27491 CFI_RESTORE esi
27492 popl_cfi %edi
27493 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27494 CFI_RESTORE ebx
27495 ret
27496 CFI_ENDPROC
27497 -ENDPROC(csum_partial_copy_generic)
27498 +ENDPROC(csum_partial_copy_generic_to_user)
27499
27500 #undef ROUND
27501 #undef ROUND1
27502 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27503 index f2145cf..cea889d 100644
27504 --- a/arch/x86/lib/clear_page_64.S
27505 +++ b/arch/x86/lib/clear_page_64.S
27506 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27507 movl $4096/8,%ecx
27508 xorl %eax,%eax
27509 rep stosq
27510 + pax_force_retaddr
27511 ret
27512 CFI_ENDPROC
27513 ENDPROC(clear_page_c)
27514 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27515 movl $4096,%ecx
27516 xorl %eax,%eax
27517 rep stosb
27518 + pax_force_retaddr
27519 ret
27520 CFI_ENDPROC
27521 ENDPROC(clear_page_c_e)
27522 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27523 leaq 64(%rdi),%rdi
27524 jnz .Lloop
27525 nop
27526 + pax_force_retaddr
27527 ret
27528 CFI_ENDPROC
27529 .Lclear_page_end:
27530 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27531
27532 #include <asm/cpufeature.h>
27533
27534 - .section .altinstr_replacement,"ax"
27535 + .section .altinstr_replacement,"a"
27536 1: .byte 0xeb /* jmp <disp8> */
27537 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27538 2: .byte 0xeb /* jmp <disp8> */
27539 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27540 index 1e572c5..2a162cd 100644
27541 --- a/arch/x86/lib/cmpxchg16b_emu.S
27542 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27543 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27544
27545 popf
27546 mov $1, %al
27547 + pax_force_retaddr
27548 ret
27549
27550 not_same:
27551 popf
27552 xor %al,%al
27553 + pax_force_retaddr
27554 ret
27555
27556 CFI_ENDPROC
27557 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27558 index 176cca6..1166c50 100644
27559 --- a/arch/x86/lib/copy_page_64.S
27560 +++ b/arch/x86/lib/copy_page_64.S
27561 @@ -9,6 +9,7 @@ copy_page_rep:
27562 CFI_STARTPROC
27563 movl $4096/8, %ecx
27564 rep movsq
27565 + pax_force_retaddr
27566 ret
27567 CFI_ENDPROC
27568 ENDPROC(copy_page_rep)
27569 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27570
27571 ENTRY(copy_page)
27572 CFI_STARTPROC
27573 - subq $2*8, %rsp
27574 - CFI_ADJUST_CFA_OFFSET 2*8
27575 + subq $3*8, %rsp
27576 + CFI_ADJUST_CFA_OFFSET 3*8
27577 movq %rbx, (%rsp)
27578 CFI_REL_OFFSET rbx, 0
27579 movq %r12, 1*8(%rsp)
27580 CFI_REL_OFFSET r12, 1*8
27581 + movq %r13, 2*8(%rsp)
27582 + CFI_REL_OFFSET r13, 2*8
27583
27584 movl $(4096/64)-5, %ecx
27585 .p2align 4
27586 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27587 movq 0x8*2(%rsi), %rdx
27588 movq 0x8*3(%rsi), %r8
27589 movq 0x8*4(%rsi), %r9
27590 - movq 0x8*5(%rsi), %r10
27591 + movq 0x8*5(%rsi), %r13
27592 movq 0x8*6(%rsi), %r11
27593 movq 0x8*7(%rsi), %r12
27594
27595 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27596 movq %rdx, 0x8*2(%rdi)
27597 movq %r8, 0x8*3(%rdi)
27598 movq %r9, 0x8*4(%rdi)
27599 - movq %r10, 0x8*5(%rdi)
27600 + movq %r13, 0x8*5(%rdi)
27601 movq %r11, 0x8*6(%rdi)
27602 movq %r12, 0x8*7(%rdi)
27603
27604 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27605 movq 0x8*2(%rsi), %rdx
27606 movq 0x8*3(%rsi), %r8
27607 movq 0x8*4(%rsi), %r9
27608 - movq 0x8*5(%rsi), %r10
27609 + movq 0x8*5(%rsi), %r13
27610 movq 0x8*6(%rsi), %r11
27611 movq 0x8*7(%rsi), %r12
27612
27613 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27614 movq %rdx, 0x8*2(%rdi)
27615 movq %r8, 0x8*3(%rdi)
27616 movq %r9, 0x8*4(%rdi)
27617 - movq %r10, 0x8*5(%rdi)
27618 + movq %r13, 0x8*5(%rdi)
27619 movq %r11, 0x8*6(%rdi)
27620 movq %r12, 0x8*7(%rdi)
27621
27622 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27623 CFI_RESTORE rbx
27624 movq 1*8(%rsp), %r12
27625 CFI_RESTORE r12
27626 - addq $2*8, %rsp
27627 - CFI_ADJUST_CFA_OFFSET -2*8
27628 + movq 2*8(%rsp), %r13
27629 + CFI_RESTORE r13
27630 + addq $3*8, %rsp
27631 + CFI_ADJUST_CFA_OFFSET -3*8
27632 + pax_force_retaddr
27633 ret
27634 .Lcopy_page_end:
27635 CFI_ENDPROC
27636 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27637
27638 #include <asm/cpufeature.h>
27639
27640 - .section .altinstr_replacement,"ax"
27641 + .section .altinstr_replacement,"a"
27642 1: .byte 0xeb /* jmp <disp8> */
27643 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27644 2:
27645 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27646 index a30ca15..6b3f4e1 100644
27647 --- a/arch/x86/lib/copy_user_64.S
27648 +++ b/arch/x86/lib/copy_user_64.S
27649 @@ -18,31 +18,7 @@
27650 #include <asm/alternative-asm.h>
27651 #include <asm/asm.h>
27652 #include <asm/smap.h>
27653 -
27654 -/*
27655 - * By placing feature2 after feature1 in altinstructions section, we logically
27656 - * implement:
27657 - * If CPU has feature2, jmp to alt2 is used
27658 - * else if CPU has feature1, jmp to alt1 is used
27659 - * else jmp to orig is used.
27660 - */
27661 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27662 -0:
27663 - .byte 0xe9 /* 32bit jump */
27664 - .long \orig-1f /* by default jump to orig */
27665 -1:
27666 - .section .altinstr_replacement,"ax"
27667 -2: .byte 0xe9 /* near jump with 32bit immediate */
27668 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27669 -3: .byte 0xe9 /* near jump with 32bit immediate */
27670 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27671 - .previous
27672 -
27673 - .section .altinstructions,"a"
27674 - altinstruction_entry 0b,2b,\feature1,5,5
27675 - altinstruction_entry 0b,3b,\feature2,5,5
27676 - .previous
27677 - .endm
27678 +#include <asm/pgtable.h>
27679
27680 .macro ALIGN_DESTINATION
27681 #ifdef FIX_ALIGNMENT
27682 @@ -70,52 +46,6 @@
27683 #endif
27684 .endm
27685
27686 -/* Standard copy_to_user with segment limit checking */
27687 -ENTRY(_copy_to_user)
27688 - CFI_STARTPROC
27689 - GET_THREAD_INFO(%rax)
27690 - movq %rdi,%rcx
27691 - addq %rdx,%rcx
27692 - jc bad_to_user
27693 - cmpq TI_addr_limit(%rax),%rcx
27694 - ja bad_to_user
27695 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27696 - copy_user_generic_unrolled,copy_user_generic_string, \
27697 - copy_user_enhanced_fast_string
27698 - CFI_ENDPROC
27699 -ENDPROC(_copy_to_user)
27700 -
27701 -/* Standard copy_from_user with segment limit checking */
27702 -ENTRY(_copy_from_user)
27703 - CFI_STARTPROC
27704 - GET_THREAD_INFO(%rax)
27705 - movq %rsi,%rcx
27706 - addq %rdx,%rcx
27707 - jc bad_from_user
27708 - cmpq TI_addr_limit(%rax),%rcx
27709 - ja bad_from_user
27710 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27711 - copy_user_generic_unrolled,copy_user_generic_string, \
27712 - copy_user_enhanced_fast_string
27713 - CFI_ENDPROC
27714 -ENDPROC(_copy_from_user)
27715 -
27716 - .section .fixup,"ax"
27717 - /* must zero dest */
27718 -ENTRY(bad_from_user)
27719 -bad_from_user:
27720 - CFI_STARTPROC
27721 - movl %edx,%ecx
27722 - xorl %eax,%eax
27723 - rep
27724 - stosb
27725 -bad_to_user:
27726 - movl %edx,%eax
27727 - ret
27728 - CFI_ENDPROC
27729 -ENDPROC(bad_from_user)
27730 - .previous
27731 -
27732 /*
27733 * copy_user_generic_unrolled - memory copy with exception handling.
27734 * This version is for CPUs like P4 that don't have efficient micro
27735 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27736 */
27737 ENTRY(copy_user_generic_unrolled)
27738 CFI_STARTPROC
27739 + ASM_PAX_OPEN_USERLAND
27740 ASM_STAC
27741 cmpl $8,%edx
27742 jb 20f /* less then 8 bytes, go to byte copy loop */
27743 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27744 jz 17f
27745 1: movq (%rsi),%r8
27746 2: movq 1*8(%rsi),%r9
27747 -3: movq 2*8(%rsi),%r10
27748 +3: movq 2*8(%rsi),%rax
27749 4: movq 3*8(%rsi),%r11
27750 5: movq %r8,(%rdi)
27751 6: movq %r9,1*8(%rdi)
27752 -7: movq %r10,2*8(%rdi)
27753 +7: movq %rax,2*8(%rdi)
27754 8: movq %r11,3*8(%rdi)
27755 9: movq 4*8(%rsi),%r8
27756 10: movq 5*8(%rsi),%r9
27757 -11: movq 6*8(%rsi),%r10
27758 +11: movq 6*8(%rsi),%rax
27759 12: movq 7*8(%rsi),%r11
27760 13: movq %r8,4*8(%rdi)
27761 14: movq %r9,5*8(%rdi)
27762 -15: movq %r10,6*8(%rdi)
27763 +15: movq %rax,6*8(%rdi)
27764 16: movq %r11,7*8(%rdi)
27765 leaq 64(%rsi),%rsi
27766 leaq 64(%rdi),%rdi
27767 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27768 jnz 21b
27769 23: xor %eax,%eax
27770 ASM_CLAC
27771 + ASM_PAX_CLOSE_USERLAND
27772 + pax_force_retaddr
27773 ret
27774
27775 .section .fixup,"ax"
27776 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27777 */
27778 ENTRY(copy_user_generic_string)
27779 CFI_STARTPROC
27780 + ASM_PAX_OPEN_USERLAND
27781 ASM_STAC
27782 andl %edx,%edx
27783 jz 4f
27784 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27785 movsb
27786 4: xorl %eax,%eax
27787 ASM_CLAC
27788 + ASM_PAX_CLOSE_USERLAND
27789 + pax_force_retaddr
27790 ret
27791
27792 .section .fixup,"ax"
27793 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27794 */
27795 ENTRY(copy_user_enhanced_fast_string)
27796 CFI_STARTPROC
27797 + ASM_PAX_OPEN_USERLAND
27798 ASM_STAC
27799 andl %edx,%edx
27800 jz 2f
27801 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27802 movsb
27803 2: xorl %eax,%eax
27804 ASM_CLAC
27805 + ASM_PAX_CLOSE_USERLAND
27806 + pax_force_retaddr
27807 ret
27808
27809 .section .fixup,"ax"
27810 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27811 index 6a4f43c..55d26f2 100644
27812 --- a/arch/x86/lib/copy_user_nocache_64.S
27813 +++ b/arch/x86/lib/copy_user_nocache_64.S
27814 @@ -8,6 +8,7 @@
27815
27816 #include <linux/linkage.h>
27817 #include <asm/dwarf2.h>
27818 +#include <asm/alternative-asm.h>
27819
27820 #define FIX_ALIGNMENT 1
27821
27822 @@ -16,6 +17,7 @@
27823 #include <asm/thread_info.h>
27824 #include <asm/asm.h>
27825 #include <asm/smap.h>
27826 +#include <asm/pgtable.h>
27827
27828 .macro ALIGN_DESTINATION
27829 #ifdef FIX_ALIGNMENT
27830 @@ -49,6 +51,16 @@
27831 */
27832 ENTRY(__copy_user_nocache)
27833 CFI_STARTPROC
27834 +
27835 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27836 + mov pax_user_shadow_base,%rcx
27837 + cmp %rcx,%rsi
27838 + jae 1f
27839 + add %rcx,%rsi
27840 +1:
27841 +#endif
27842 +
27843 + ASM_PAX_OPEN_USERLAND
27844 ASM_STAC
27845 cmpl $8,%edx
27846 jb 20f /* less then 8 bytes, go to byte copy loop */
27847 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27848 jz 17f
27849 1: movq (%rsi),%r8
27850 2: movq 1*8(%rsi),%r9
27851 -3: movq 2*8(%rsi),%r10
27852 +3: movq 2*8(%rsi),%rax
27853 4: movq 3*8(%rsi),%r11
27854 5: movnti %r8,(%rdi)
27855 6: movnti %r9,1*8(%rdi)
27856 -7: movnti %r10,2*8(%rdi)
27857 +7: movnti %rax,2*8(%rdi)
27858 8: movnti %r11,3*8(%rdi)
27859 9: movq 4*8(%rsi),%r8
27860 10: movq 5*8(%rsi),%r9
27861 -11: movq 6*8(%rsi),%r10
27862 +11: movq 6*8(%rsi),%rax
27863 12: movq 7*8(%rsi),%r11
27864 13: movnti %r8,4*8(%rdi)
27865 14: movnti %r9,5*8(%rdi)
27866 -15: movnti %r10,6*8(%rdi)
27867 +15: movnti %rax,6*8(%rdi)
27868 16: movnti %r11,7*8(%rdi)
27869 leaq 64(%rsi),%rsi
27870 leaq 64(%rdi),%rdi
27871 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27872 jnz 21b
27873 23: xorl %eax,%eax
27874 ASM_CLAC
27875 + ASM_PAX_CLOSE_USERLAND
27876 sfence
27877 + pax_force_retaddr
27878 ret
27879
27880 .section .fixup,"ax"
27881 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27882 index 2419d5f..953ee51 100644
27883 --- a/arch/x86/lib/csum-copy_64.S
27884 +++ b/arch/x86/lib/csum-copy_64.S
27885 @@ -9,6 +9,7 @@
27886 #include <asm/dwarf2.h>
27887 #include <asm/errno.h>
27888 #include <asm/asm.h>
27889 +#include <asm/alternative-asm.h>
27890
27891 /*
27892 * Checksum copy with exception handling.
27893 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27894 CFI_RESTORE rbp
27895 addq $7*8, %rsp
27896 CFI_ADJUST_CFA_OFFSET -7*8
27897 + pax_force_retaddr 0, 1
27898 ret
27899 CFI_RESTORE_STATE
27900
27901 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27902 index 25b7ae8..c40113e 100644
27903 --- a/arch/x86/lib/csum-wrappers_64.c
27904 +++ b/arch/x86/lib/csum-wrappers_64.c
27905 @@ -52,8 +52,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27906 len -= 2;
27907 }
27908 }
27909 - isum = csum_partial_copy_generic((__force const void *)src,
27910 + pax_open_userland();
27911 + stac();
27912 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27913 dst, len, isum, errp, NULL);
27914 + clac();
27915 + pax_close_userland();
27916 if (unlikely(*errp))
27917 goto out_err;
27918
27919 @@ -105,8 +109,13 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27920 }
27921
27922 *errp = 0;
27923 - return csum_partial_copy_generic(src, (void __force *)dst,
27924 + pax_open_userland();
27925 + stac();
27926 + isum = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27927 len, isum, NULL, errp);
27928 + clac();
27929 + pax_close_userland();
27930 + return isum;
27931 }
27932 EXPORT_SYMBOL(csum_partial_copy_to_user);
27933
27934 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27935 index a451235..1daa956 100644
27936 --- a/arch/x86/lib/getuser.S
27937 +++ b/arch/x86/lib/getuser.S
27938 @@ -33,17 +33,40 @@
27939 #include <asm/thread_info.h>
27940 #include <asm/asm.h>
27941 #include <asm/smap.h>
27942 +#include <asm/segment.h>
27943 +#include <asm/pgtable.h>
27944 +#include <asm/alternative-asm.h>
27945 +
27946 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27947 +#define __copyuser_seg gs;
27948 +#else
27949 +#define __copyuser_seg
27950 +#endif
27951
27952 .text
27953 ENTRY(__get_user_1)
27954 CFI_STARTPROC
27955 +
27956 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27957 GET_THREAD_INFO(%_ASM_DX)
27958 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27959 jae bad_get_user
27960 ASM_STAC
27961 -1: movzbl (%_ASM_AX),%edx
27962 +
27963 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27964 + mov pax_user_shadow_base,%_ASM_DX
27965 + cmp %_ASM_DX,%_ASM_AX
27966 + jae 1234f
27967 + add %_ASM_DX,%_ASM_AX
27968 +1234:
27969 +#endif
27970 +
27971 +#endif
27972 +
27973 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
27974 xor %eax,%eax
27975 ASM_CLAC
27976 + pax_force_retaddr
27977 ret
27978 CFI_ENDPROC
27979 ENDPROC(__get_user_1)
27980 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
27981 ENTRY(__get_user_2)
27982 CFI_STARTPROC
27983 add $1,%_ASM_AX
27984 +
27985 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27986 jc bad_get_user
27987 GET_THREAD_INFO(%_ASM_DX)
27988 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27989 jae bad_get_user
27990 ASM_STAC
27991 -2: movzwl -1(%_ASM_AX),%edx
27992 +
27993 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27994 + mov pax_user_shadow_base,%_ASM_DX
27995 + cmp %_ASM_DX,%_ASM_AX
27996 + jae 1234f
27997 + add %_ASM_DX,%_ASM_AX
27998 +1234:
27999 +#endif
28000 +
28001 +#endif
28002 +
28003 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28004 xor %eax,%eax
28005 ASM_CLAC
28006 + pax_force_retaddr
28007 ret
28008 CFI_ENDPROC
28009 ENDPROC(__get_user_2)
28010 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28011 ENTRY(__get_user_4)
28012 CFI_STARTPROC
28013 add $3,%_ASM_AX
28014 +
28015 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28016 jc bad_get_user
28017 GET_THREAD_INFO(%_ASM_DX)
28018 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28019 jae bad_get_user
28020 ASM_STAC
28021 -3: movl -3(%_ASM_AX),%edx
28022 +
28023 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28024 + mov pax_user_shadow_base,%_ASM_DX
28025 + cmp %_ASM_DX,%_ASM_AX
28026 + jae 1234f
28027 + add %_ASM_DX,%_ASM_AX
28028 +1234:
28029 +#endif
28030 +
28031 +#endif
28032 +
28033 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28034 xor %eax,%eax
28035 ASM_CLAC
28036 + pax_force_retaddr
28037 ret
28038 CFI_ENDPROC
28039 ENDPROC(__get_user_4)
28040 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28041 GET_THREAD_INFO(%_ASM_DX)
28042 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28043 jae bad_get_user
28044 +
28045 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28046 + mov pax_user_shadow_base,%_ASM_DX
28047 + cmp %_ASM_DX,%_ASM_AX
28048 + jae 1234f
28049 + add %_ASM_DX,%_ASM_AX
28050 +1234:
28051 +#endif
28052 +
28053 ASM_STAC
28054 4: movq -7(%_ASM_AX),%rdx
28055 xor %eax,%eax
28056 ASM_CLAC
28057 + pax_force_retaddr
28058 ret
28059 #else
28060 add $7,%_ASM_AX
28061 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28062 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28063 jae bad_get_user_8
28064 ASM_STAC
28065 -4: movl -7(%_ASM_AX),%edx
28066 -5: movl -3(%_ASM_AX),%ecx
28067 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28068 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28069 xor %eax,%eax
28070 ASM_CLAC
28071 + pax_force_retaddr
28072 ret
28073 #endif
28074 CFI_ENDPROC
28075 @@ -113,6 +175,7 @@ bad_get_user:
28076 xor %edx,%edx
28077 mov $(-EFAULT),%_ASM_AX
28078 ASM_CLAC
28079 + pax_force_retaddr
28080 ret
28081 CFI_ENDPROC
28082 END(bad_get_user)
28083 @@ -124,6 +187,7 @@ bad_get_user_8:
28084 xor %ecx,%ecx
28085 mov $(-EFAULT),%_ASM_AX
28086 ASM_CLAC
28087 + pax_force_retaddr
28088 ret
28089 CFI_ENDPROC
28090 END(bad_get_user_8)
28091 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28092 index 54fcffe..7be149e 100644
28093 --- a/arch/x86/lib/insn.c
28094 +++ b/arch/x86/lib/insn.c
28095 @@ -20,8 +20,10 @@
28096
28097 #ifdef __KERNEL__
28098 #include <linux/string.h>
28099 +#include <asm/pgtable_types.h>
28100 #else
28101 #include <string.h>
28102 +#define ktla_ktva(addr) addr
28103 #endif
28104 #include <asm/inat.h>
28105 #include <asm/insn.h>
28106 @@ -53,8 +55,8 @@
28107 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28108 {
28109 memset(insn, 0, sizeof(*insn));
28110 - insn->kaddr = kaddr;
28111 - insn->next_byte = kaddr;
28112 + insn->kaddr = ktla_ktva(kaddr);
28113 + insn->next_byte = ktla_ktva(kaddr);
28114 insn->x86_64 = x86_64 ? 1 : 0;
28115 insn->opnd_bytes = 4;
28116 if (x86_64)
28117 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28118 index 05a95e7..326f2fa 100644
28119 --- a/arch/x86/lib/iomap_copy_64.S
28120 +++ b/arch/x86/lib/iomap_copy_64.S
28121 @@ -17,6 +17,7 @@
28122
28123 #include <linux/linkage.h>
28124 #include <asm/dwarf2.h>
28125 +#include <asm/alternative-asm.h>
28126
28127 /*
28128 * override generic version in lib/iomap_copy.c
28129 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28130 CFI_STARTPROC
28131 movl %edx,%ecx
28132 rep movsd
28133 + pax_force_retaddr
28134 ret
28135 CFI_ENDPROC
28136 ENDPROC(__iowrite32_copy)
28137 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28138 index 56313a3..9b59269 100644
28139 --- a/arch/x86/lib/memcpy_64.S
28140 +++ b/arch/x86/lib/memcpy_64.S
28141 @@ -24,7 +24,7 @@
28142 * This gets patched over the unrolled variant (below) via the
28143 * alternative instructions framework:
28144 */
28145 - .section .altinstr_replacement, "ax", @progbits
28146 + .section .altinstr_replacement, "a", @progbits
28147 .Lmemcpy_c:
28148 movq %rdi, %rax
28149 movq %rdx, %rcx
28150 @@ -33,6 +33,7 @@
28151 rep movsq
28152 movl %edx, %ecx
28153 rep movsb
28154 + pax_force_retaddr
28155 ret
28156 .Lmemcpy_e:
28157 .previous
28158 @@ -44,11 +45,12 @@
28159 * This gets patched over the unrolled variant (below) via the
28160 * alternative instructions framework:
28161 */
28162 - .section .altinstr_replacement, "ax", @progbits
28163 + .section .altinstr_replacement, "a", @progbits
28164 .Lmemcpy_c_e:
28165 movq %rdi, %rax
28166 movq %rdx, %rcx
28167 rep movsb
28168 + pax_force_retaddr
28169 ret
28170 .Lmemcpy_e_e:
28171 .previous
28172 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28173 */
28174 movq 0*8(%rsi), %r8
28175 movq 1*8(%rsi), %r9
28176 - movq 2*8(%rsi), %r10
28177 + movq 2*8(%rsi), %rcx
28178 movq 3*8(%rsi), %r11
28179 leaq 4*8(%rsi), %rsi
28180
28181 movq %r8, 0*8(%rdi)
28182 movq %r9, 1*8(%rdi)
28183 - movq %r10, 2*8(%rdi)
28184 + movq %rcx, 2*8(%rdi)
28185 movq %r11, 3*8(%rdi)
28186 leaq 4*8(%rdi), %rdi
28187 jae .Lcopy_forward_loop
28188 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28189 subq $0x20, %rdx
28190 movq -1*8(%rsi), %r8
28191 movq -2*8(%rsi), %r9
28192 - movq -3*8(%rsi), %r10
28193 + movq -3*8(%rsi), %rcx
28194 movq -4*8(%rsi), %r11
28195 leaq -4*8(%rsi), %rsi
28196 movq %r8, -1*8(%rdi)
28197 movq %r9, -2*8(%rdi)
28198 - movq %r10, -3*8(%rdi)
28199 + movq %rcx, -3*8(%rdi)
28200 movq %r11, -4*8(%rdi)
28201 leaq -4*8(%rdi), %rdi
28202 jae .Lcopy_backward_loop
28203 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28204 */
28205 movq 0*8(%rsi), %r8
28206 movq 1*8(%rsi), %r9
28207 - movq -2*8(%rsi, %rdx), %r10
28208 + movq -2*8(%rsi, %rdx), %rcx
28209 movq -1*8(%rsi, %rdx), %r11
28210 movq %r8, 0*8(%rdi)
28211 movq %r9, 1*8(%rdi)
28212 - movq %r10, -2*8(%rdi, %rdx)
28213 + movq %rcx, -2*8(%rdi, %rdx)
28214 movq %r11, -1*8(%rdi, %rdx)
28215 + pax_force_retaddr
28216 retq
28217 .p2align 4
28218 .Lless_16bytes:
28219 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28220 movq -1*8(%rsi, %rdx), %r9
28221 movq %r8, 0*8(%rdi)
28222 movq %r9, -1*8(%rdi, %rdx)
28223 + pax_force_retaddr
28224 retq
28225 .p2align 4
28226 .Lless_8bytes:
28227 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28228 movl -4(%rsi, %rdx), %r8d
28229 movl %ecx, (%rdi)
28230 movl %r8d, -4(%rdi, %rdx)
28231 + pax_force_retaddr
28232 retq
28233 .p2align 4
28234 .Lless_3bytes:
28235 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28236 movb %cl, (%rdi)
28237
28238 .Lend:
28239 + pax_force_retaddr
28240 retq
28241 CFI_ENDPROC
28242 ENDPROC(memcpy)
28243 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28244 index 65268a6..5aa7815 100644
28245 --- a/arch/x86/lib/memmove_64.S
28246 +++ b/arch/x86/lib/memmove_64.S
28247 @@ -61,13 +61,13 @@ ENTRY(memmove)
28248 5:
28249 sub $0x20, %rdx
28250 movq 0*8(%rsi), %r11
28251 - movq 1*8(%rsi), %r10
28252 + movq 1*8(%rsi), %rcx
28253 movq 2*8(%rsi), %r9
28254 movq 3*8(%rsi), %r8
28255 leaq 4*8(%rsi), %rsi
28256
28257 movq %r11, 0*8(%rdi)
28258 - movq %r10, 1*8(%rdi)
28259 + movq %rcx, 1*8(%rdi)
28260 movq %r9, 2*8(%rdi)
28261 movq %r8, 3*8(%rdi)
28262 leaq 4*8(%rdi), %rdi
28263 @@ -81,10 +81,10 @@ ENTRY(memmove)
28264 4:
28265 movq %rdx, %rcx
28266 movq -8(%rsi, %rdx), %r11
28267 - lea -8(%rdi, %rdx), %r10
28268 + lea -8(%rdi, %rdx), %r9
28269 shrq $3, %rcx
28270 rep movsq
28271 - movq %r11, (%r10)
28272 + movq %r11, (%r9)
28273 jmp 13f
28274 .Lmemmove_end_forward:
28275
28276 @@ -95,14 +95,14 @@ ENTRY(memmove)
28277 7:
28278 movq %rdx, %rcx
28279 movq (%rsi), %r11
28280 - movq %rdi, %r10
28281 + movq %rdi, %r9
28282 leaq -8(%rsi, %rdx), %rsi
28283 leaq -8(%rdi, %rdx), %rdi
28284 shrq $3, %rcx
28285 std
28286 rep movsq
28287 cld
28288 - movq %r11, (%r10)
28289 + movq %r11, (%r9)
28290 jmp 13f
28291
28292 /*
28293 @@ -127,13 +127,13 @@ ENTRY(memmove)
28294 8:
28295 subq $0x20, %rdx
28296 movq -1*8(%rsi), %r11
28297 - movq -2*8(%rsi), %r10
28298 + movq -2*8(%rsi), %rcx
28299 movq -3*8(%rsi), %r9
28300 movq -4*8(%rsi), %r8
28301 leaq -4*8(%rsi), %rsi
28302
28303 movq %r11, -1*8(%rdi)
28304 - movq %r10, -2*8(%rdi)
28305 + movq %rcx, -2*8(%rdi)
28306 movq %r9, -3*8(%rdi)
28307 movq %r8, -4*8(%rdi)
28308 leaq -4*8(%rdi), %rdi
28309 @@ -151,11 +151,11 @@ ENTRY(memmove)
28310 * Move data from 16 bytes to 31 bytes.
28311 */
28312 movq 0*8(%rsi), %r11
28313 - movq 1*8(%rsi), %r10
28314 + movq 1*8(%rsi), %rcx
28315 movq -2*8(%rsi, %rdx), %r9
28316 movq -1*8(%rsi, %rdx), %r8
28317 movq %r11, 0*8(%rdi)
28318 - movq %r10, 1*8(%rdi)
28319 + movq %rcx, 1*8(%rdi)
28320 movq %r9, -2*8(%rdi, %rdx)
28321 movq %r8, -1*8(%rdi, %rdx)
28322 jmp 13f
28323 @@ -167,9 +167,9 @@ ENTRY(memmove)
28324 * Move data from 8 bytes to 15 bytes.
28325 */
28326 movq 0*8(%rsi), %r11
28327 - movq -1*8(%rsi, %rdx), %r10
28328 + movq -1*8(%rsi, %rdx), %r9
28329 movq %r11, 0*8(%rdi)
28330 - movq %r10, -1*8(%rdi, %rdx)
28331 + movq %r9, -1*8(%rdi, %rdx)
28332 jmp 13f
28333 10:
28334 cmpq $4, %rdx
28335 @@ -178,9 +178,9 @@ ENTRY(memmove)
28336 * Move data from 4 bytes to 7 bytes.
28337 */
28338 movl (%rsi), %r11d
28339 - movl -4(%rsi, %rdx), %r10d
28340 + movl -4(%rsi, %rdx), %r9d
28341 movl %r11d, (%rdi)
28342 - movl %r10d, -4(%rdi, %rdx)
28343 + movl %r9d, -4(%rdi, %rdx)
28344 jmp 13f
28345 11:
28346 cmp $2, %rdx
28347 @@ -189,9 +189,9 @@ ENTRY(memmove)
28348 * Move data from 2 bytes to 3 bytes.
28349 */
28350 movw (%rsi), %r11w
28351 - movw -2(%rsi, %rdx), %r10w
28352 + movw -2(%rsi, %rdx), %r9w
28353 movw %r11w, (%rdi)
28354 - movw %r10w, -2(%rdi, %rdx)
28355 + movw %r9w, -2(%rdi, %rdx)
28356 jmp 13f
28357 12:
28358 cmp $1, %rdx
28359 @@ -202,14 +202,16 @@ ENTRY(memmove)
28360 movb (%rsi), %r11b
28361 movb %r11b, (%rdi)
28362 13:
28363 + pax_force_retaddr
28364 retq
28365 CFI_ENDPROC
28366
28367 - .section .altinstr_replacement,"ax"
28368 + .section .altinstr_replacement,"a"
28369 .Lmemmove_begin_forward_efs:
28370 /* Forward moving data. */
28371 movq %rdx, %rcx
28372 rep movsb
28373 + pax_force_retaddr
28374 retq
28375 .Lmemmove_end_forward_efs:
28376 .previous
28377 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28378 index 2dcb380..50a78bc 100644
28379 --- a/arch/x86/lib/memset_64.S
28380 +++ b/arch/x86/lib/memset_64.S
28381 @@ -16,7 +16,7 @@
28382 *
28383 * rax original destination
28384 */
28385 - .section .altinstr_replacement, "ax", @progbits
28386 + .section .altinstr_replacement, "a", @progbits
28387 .Lmemset_c:
28388 movq %rdi,%r9
28389 movq %rdx,%rcx
28390 @@ -30,6 +30,7 @@
28391 movl %edx,%ecx
28392 rep stosb
28393 movq %r9,%rax
28394 + pax_force_retaddr
28395 ret
28396 .Lmemset_e:
28397 .previous
28398 @@ -45,13 +46,14 @@
28399 *
28400 * rax original destination
28401 */
28402 - .section .altinstr_replacement, "ax", @progbits
28403 + .section .altinstr_replacement, "a", @progbits
28404 .Lmemset_c_e:
28405 movq %rdi,%r9
28406 movb %sil,%al
28407 movq %rdx,%rcx
28408 rep stosb
28409 movq %r9,%rax
28410 + pax_force_retaddr
28411 ret
28412 .Lmemset_e_e:
28413 .previous
28414 @@ -59,7 +61,7 @@
28415 ENTRY(memset)
28416 ENTRY(__memset)
28417 CFI_STARTPROC
28418 - movq %rdi,%r10
28419 + movq %rdi,%r11
28420
28421 /* expand byte value */
28422 movzbl %sil,%ecx
28423 @@ -117,7 +119,8 @@ ENTRY(__memset)
28424 jnz .Lloop_1
28425
28426 .Lende:
28427 - movq %r10,%rax
28428 + movq %r11,%rax
28429 + pax_force_retaddr
28430 ret
28431
28432 CFI_RESTORE_STATE
28433 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28434 index c9f2d9b..e7fd2c0 100644
28435 --- a/arch/x86/lib/mmx_32.c
28436 +++ b/arch/x86/lib/mmx_32.c
28437 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28438 {
28439 void *p;
28440 int i;
28441 + unsigned long cr0;
28442
28443 if (unlikely(in_interrupt()))
28444 return __memcpy(to, from, len);
28445 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28446 kernel_fpu_begin();
28447
28448 __asm__ __volatile__ (
28449 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28450 - " prefetch 64(%0)\n"
28451 - " prefetch 128(%0)\n"
28452 - " prefetch 192(%0)\n"
28453 - " prefetch 256(%0)\n"
28454 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28455 + " prefetch 64(%1)\n"
28456 + " prefetch 128(%1)\n"
28457 + " prefetch 192(%1)\n"
28458 + " prefetch 256(%1)\n"
28459 "2: \n"
28460 ".section .fixup, \"ax\"\n"
28461 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28462 + "3: \n"
28463 +
28464 +#ifdef CONFIG_PAX_KERNEXEC
28465 + " movl %%cr0, %0\n"
28466 + " movl %0, %%eax\n"
28467 + " andl $0xFFFEFFFF, %%eax\n"
28468 + " movl %%eax, %%cr0\n"
28469 +#endif
28470 +
28471 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28472 +
28473 +#ifdef CONFIG_PAX_KERNEXEC
28474 + " movl %0, %%cr0\n"
28475 +#endif
28476 +
28477 " jmp 2b\n"
28478 ".previous\n"
28479 _ASM_EXTABLE(1b, 3b)
28480 - : : "r" (from));
28481 + : "=&r" (cr0) : "r" (from) : "ax");
28482
28483 for ( ; i > 5; i--) {
28484 __asm__ __volatile__ (
28485 - "1: prefetch 320(%0)\n"
28486 - "2: movq (%0), %%mm0\n"
28487 - " movq 8(%0), %%mm1\n"
28488 - " movq 16(%0), %%mm2\n"
28489 - " movq 24(%0), %%mm3\n"
28490 - " movq %%mm0, (%1)\n"
28491 - " movq %%mm1, 8(%1)\n"
28492 - " movq %%mm2, 16(%1)\n"
28493 - " movq %%mm3, 24(%1)\n"
28494 - " movq 32(%0), %%mm0\n"
28495 - " movq 40(%0), %%mm1\n"
28496 - " movq 48(%0), %%mm2\n"
28497 - " movq 56(%0), %%mm3\n"
28498 - " movq %%mm0, 32(%1)\n"
28499 - " movq %%mm1, 40(%1)\n"
28500 - " movq %%mm2, 48(%1)\n"
28501 - " movq %%mm3, 56(%1)\n"
28502 + "1: prefetch 320(%1)\n"
28503 + "2: movq (%1), %%mm0\n"
28504 + " movq 8(%1), %%mm1\n"
28505 + " movq 16(%1), %%mm2\n"
28506 + " movq 24(%1), %%mm3\n"
28507 + " movq %%mm0, (%2)\n"
28508 + " movq %%mm1, 8(%2)\n"
28509 + " movq %%mm2, 16(%2)\n"
28510 + " movq %%mm3, 24(%2)\n"
28511 + " movq 32(%1), %%mm0\n"
28512 + " movq 40(%1), %%mm1\n"
28513 + " movq 48(%1), %%mm2\n"
28514 + " movq 56(%1), %%mm3\n"
28515 + " movq %%mm0, 32(%2)\n"
28516 + " movq %%mm1, 40(%2)\n"
28517 + " movq %%mm2, 48(%2)\n"
28518 + " movq %%mm3, 56(%2)\n"
28519 ".section .fixup, \"ax\"\n"
28520 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28521 + "3:\n"
28522 +
28523 +#ifdef CONFIG_PAX_KERNEXEC
28524 + " movl %%cr0, %0\n"
28525 + " movl %0, %%eax\n"
28526 + " andl $0xFFFEFFFF, %%eax\n"
28527 + " movl %%eax, %%cr0\n"
28528 +#endif
28529 +
28530 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28531 +
28532 +#ifdef CONFIG_PAX_KERNEXEC
28533 + " movl %0, %%cr0\n"
28534 +#endif
28535 +
28536 " jmp 2b\n"
28537 ".previous\n"
28538 _ASM_EXTABLE(1b, 3b)
28539 - : : "r" (from), "r" (to) : "memory");
28540 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28541
28542 from += 64;
28543 to += 64;
28544 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28545 static void fast_copy_page(void *to, void *from)
28546 {
28547 int i;
28548 + unsigned long cr0;
28549
28550 kernel_fpu_begin();
28551
28552 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28553 * but that is for later. -AV
28554 */
28555 __asm__ __volatile__(
28556 - "1: prefetch (%0)\n"
28557 - " prefetch 64(%0)\n"
28558 - " prefetch 128(%0)\n"
28559 - " prefetch 192(%0)\n"
28560 - " prefetch 256(%0)\n"
28561 + "1: prefetch (%1)\n"
28562 + " prefetch 64(%1)\n"
28563 + " prefetch 128(%1)\n"
28564 + " prefetch 192(%1)\n"
28565 + " prefetch 256(%1)\n"
28566 "2: \n"
28567 ".section .fixup, \"ax\"\n"
28568 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28569 + "3: \n"
28570 +
28571 +#ifdef CONFIG_PAX_KERNEXEC
28572 + " movl %%cr0, %0\n"
28573 + " movl %0, %%eax\n"
28574 + " andl $0xFFFEFFFF, %%eax\n"
28575 + " movl %%eax, %%cr0\n"
28576 +#endif
28577 +
28578 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28579 +
28580 +#ifdef CONFIG_PAX_KERNEXEC
28581 + " movl %0, %%cr0\n"
28582 +#endif
28583 +
28584 " jmp 2b\n"
28585 ".previous\n"
28586 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28587 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28588
28589 for (i = 0; i < (4096-320)/64; i++) {
28590 __asm__ __volatile__ (
28591 - "1: prefetch 320(%0)\n"
28592 - "2: movq (%0), %%mm0\n"
28593 - " movntq %%mm0, (%1)\n"
28594 - " movq 8(%0), %%mm1\n"
28595 - " movntq %%mm1, 8(%1)\n"
28596 - " movq 16(%0), %%mm2\n"
28597 - " movntq %%mm2, 16(%1)\n"
28598 - " movq 24(%0), %%mm3\n"
28599 - " movntq %%mm3, 24(%1)\n"
28600 - " movq 32(%0), %%mm4\n"
28601 - " movntq %%mm4, 32(%1)\n"
28602 - " movq 40(%0), %%mm5\n"
28603 - " movntq %%mm5, 40(%1)\n"
28604 - " movq 48(%0), %%mm6\n"
28605 - " movntq %%mm6, 48(%1)\n"
28606 - " movq 56(%0), %%mm7\n"
28607 - " movntq %%mm7, 56(%1)\n"
28608 + "1: prefetch 320(%1)\n"
28609 + "2: movq (%1), %%mm0\n"
28610 + " movntq %%mm0, (%2)\n"
28611 + " movq 8(%1), %%mm1\n"
28612 + " movntq %%mm1, 8(%2)\n"
28613 + " movq 16(%1), %%mm2\n"
28614 + " movntq %%mm2, 16(%2)\n"
28615 + " movq 24(%1), %%mm3\n"
28616 + " movntq %%mm3, 24(%2)\n"
28617 + " movq 32(%1), %%mm4\n"
28618 + " movntq %%mm4, 32(%2)\n"
28619 + " movq 40(%1), %%mm5\n"
28620 + " movntq %%mm5, 40(%2)\n"
28621 + " movq 48(%1), %%mm6\n"
28622 + " movntq %%mm6, 48(%2)\n"
28623 + " movq 56(%1), %%mm7\n"
28624 + " movntq %%mm7, 56(%2)\n"
28625 ".section .fixup, \"ax\"\n"
28626 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28627 + "3:\n"
28628 +
28629 +#ifdef CONFIG_PAX_KERNEXEC
28630 + " movl %%cr0, %0\n"
28631 + " movl %0, %%eax\n"
28632 + " andl $0xFFFEFFFF, %%eax\n"
28633 + " movl %%eax, %%cr0\n"
28634 +#endif
28635 +
28636 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28637 +
28638 +#ifdef CONFIG_PAX_KERNEXEC
28639 + " movl %0, %%cr0\n"
28640 +#endif
28641 +
28642 " jmp 2b\n"
28643 ".previous\n"
28644 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28645 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28646
28647 from += 64;
28648 to += 64;
28649 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28650 static void fast_copy_page(void *to, void *from)
28651 {
28652 int i;
28653 + unsigned long cr0;
28654
28655 kernel_fpu_begin();
28656
28657 __asm__ __volatile__ (
28658 - "1: prefetch (%0)\n"
28659 - " prefetch 64(%0)\n"
28660 - " prefetch 128(%0)\n"
28661 - " prefetch 192(%0)\n"
28662 - " prefetch 256(%0)\n"
28663 + "1: prefetch (%1)\n"
28664 + " prefetch 64(%1)\n"
28665 + " prefetch 128(%1)\n"
28666 + " prefetch 192(%1)\n"
28667 + " prefetch 256(%1)\n"
28668 "2: \n"
28669 ".section .fixup, \"ax\"\n"
28670 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28671 + "3: \n"
28672 +
28673 +#ifdef CONFIG_PAX_KERNEXEC
28674 + " movl %%cr0, %0\n"
28675 + " movl %0, %%eax\n"
28676 + " andl $0xFFFEFFFF, %%eax\n"
28677 + " movl %%eax, %%cr0\n"
28678 +#endif
28679 +
28680 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28681 +
28682 +#ifdef CONFIG_PAX_KERNEXEC
28683 + " movl %0, %%cr0\n"
28684 +#endif
28685 +
28686 " jmp 2b\n"
28687 ".previous\n"
28688 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28689 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28690
28691 for (i = 0; i < 4096/64; i++) {
28692 __asm__ __volatile__ (
28693 - "1: prefetch 320(%0)\n"
28694 - "2: movq (%0), %%mm0\n"
28695 - " movq 8(%0), %%mm1\n"
28696 - " movq 16(%0), %%mm2\n"
28697 - " movq 24(%0), %%mm3\n"
28698 - " movq %%mm0, (%1)\n"
28699 - " movq %%mm1, 8(%1)\n"
28700 - " movq %%mm2, 16(%1)\n"
28701 - " movq %%mm3, 24(%1)\n"
28702 - " movq 32(%0), %%mm0\n"
28703 - " movq 40(%0), %%mm1\n"
28704 - " movq 48(%0), %%mm2\n"
28705 - " movq 56(%0), %%mm3\n"
28706 - " movq %%mm0, 32(%1)\n"
28707 - " movq %%mm1, 40(%1)\n"
28708 - " movq %%mm2, 48(%1)\n"
28709 - " movq %%mm3, 56(%1)\n"
28710 + "1: prefetch 320(%1)\n"
28711 + "2: movq (%1), %%mm0\n"
28712 + " movq 8(%1), %%mm1\n"
28713 + " movq 16(%1), %%mm2\n"
28714 + " movq 24(%1), %%mm3\n"
28715 + " movq %%mm0, (%2)\n"
28716 + " movq %%mm1, 8(%2)\n"
28717 + " movq %%mm2, 16(%2)\n"
28718 + " movq %%mm3, 24(%2)\n"
28719 + " movq 32(%1), %%mm0\n"
28720 + " movq 40(%1), %%mm1\n"
28721 + " movq 48(%1), %%mm2\n"
28722 + " movq 56(%1), %%mm3\n"
28723 + " movq %%mm0, 32(%2)\n"
28724 + " movq %%mm1, 40(%2)\n"
28725 + " movq %%mm2, 48(%2)\n"
28726 + " movq %%mm3, 56(%2)\n"
28727 ".section .fixup, \"ax\"\n"
28728 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28729 + "3:\n"
28730 +
28731 +#ifdef CONFIG_PAX_KERNEXEC
28732 + " movl %%cr0, %0\n"
28733 + " movl %0, %%eax\n"
28734 + " andl $0xFFFEFFFF, %%eax\n"
28735 + " movl %%eax, %%cr0\n"
28736 +#endif
28737 +
28738 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28739 +
28740 +#ifdef CONFIG_PAX_KERNEXEC
28741 + " movl %0, %%cr0\n"
28742 +#endif
28743 +
28744 " jmp 2b\n"
28745 ".previous\n"
28746 _ASM_EXTABLE(1b, 3b)
28747 - : : "r" (from), "r" (to) : "memory");
28748 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28749
28750 from += 64;
28751 to += 64;
28752 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28753 index f6d13ee..aca5f0b 100644
28754 --- a/arch/x86/lib/msr-reg.S
28755 +++ b/arch/x86/lib/msr-reg.S
28756 @@ -3,6 +3,7 @@
28757 #include <asm/dwarf2.h>
28758 #include <asm/asm.h>
28759 #include <asm/msr.h>
28760 +#include <asm/alternative-asm.h>
28761
28762 #ifdef CONFIG_X86_64
28763 /*
28764 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28765 CFI_STARTPROC
28766 pushq_cfi %rbx
28767 pushq_cfi %rbp
28768 - movq %rdi, %r10 /* Save pointer */
28769 + movq %rdi, %r9 /* Save pointer */
28770 xorl %r11d, %r11d /* Return value */
28771 movl (%rdi), %eax
28772 movl 4(%rdi), %ecx
28773 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28774 movl 28(%rdi), %edi
28775 CFI_REMEMBER_STATE
28776 1: \op
28777 -2: movl %eax, (%r10)
28778 +2: movl %eax, (%r9)
28779 movl %r11d, %eax /* Return value */
28780 - movl %ecx, 4(%r10)
28781 - movl %edx, 8(%r10)
28782 - movl %ebx, 12(%r10)
28783 - movl %ebp, 20(%r10)
28784 - movl %esi, 24(%r10)
28785 - movl %edi, 28(%r10)
28786 + movl %ecx, 4(%r9)
28787 + movl %edx, 8(%r9)
28788 + movl %ebx, 12(%r9)
28789 + movl %ebp, 20(%r9)
28790 + movl %esi, 24(%r9)
28791 + movl %edi, 28(%r9)
28792 popq_cfi %rbp
28793 popq_cfi %rbx
28794 + pax_force_retaddr
28795 ret
28796 3:
28797 CFI_RESTORE_STATE
28798 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28799 index fc6ba17..d4d989d 100644
28800 --- a/arch/x86/lib/putuser.S
28801 +++ b/arch/x86/lib/putuser.S
28802 @@ -16,7 +16,9 @@
28803 #include <asm/errno.h>
28804 #include <asm/asm.h>
28805 #include <asm/smap.h>
28806 -
28807 +#include <asm/segment.h>
28808 +#include <asm/pgtable.h>
28809 +#include <asm/alternative-asm.h>
28810
28811 /*
28812 * __put_user_X
28813 @@ -30,57 +32,125 @@
28814 * as they get called from within inline assembly.
28815 */
28816
28817 -#define ENTER CFI_STARTPROC ; \
28818 - GET_THREAD_INFO(%_ASM_BX)
28819 -#define EXIT ASM_CLAC ; \
28820 - ret ; \
28821 +#define ENTER CFI_STARTPROC
28822 +#define EXIT ASM_CLAC ; \
28823 + pax_force_retaddr ; \
28824 + ret ; \
28825 CFI_ENDPROC
28826
28827 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28828 +#define _DEST %_ASM_CX,%_ASM_BX
28829 +#else
28830 +#define _DEST %_ASM_CX
28831 +#endif
28832 +
28833 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28834 +#define __copyuser_seg gs;
28835 +#else
28836 +#define __copyuser_seg
28837 +#endif
28838 +
28839 .text
28840 ENTRY(__put_user_1)
28841 ENTER
28842 +
28843 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28844 + GET_THREAD_INFO(%_ASM_BX)
28845 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28846 jae bad_put_user
28847 ASM_STAC
28848 -1: movb %al,(%_ASM_CX)
28849 +
28850 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28851 + mov pax_user_shadow_base,%_ASM_BX
28852 + cmp %_ASM_BX,%_ASM_CX
28853 + jb 1234f
28854 + xor %ebx,%ebx
28855 +1234:
28856 +#endif
28857 +
28858 +#endif
28859 +
28860 +1: __copyuser_seg movb %al,(_DEST)
28861 xor %eax,%eax
28862 EXIT
28863 ENDPROC(__put_user_1)
28864
28865 ENTRY(__put_user_2)
28866 ENTER
28867 +
28868 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28869 + GET_THREAD_INFO(%_ASM_BX)
28870 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28871 sub $1,%_ASM_BX
28872 cmp %_ASM_BX,%_ASM_CX
28873 jae bad_put_user
28874 ASM_STAC
28875 -2: movw %ax,(%_ASM_CX)
28876 +
28877 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28878 + mov pax_user_shadow_base,%_ASM_BX
28879 + cmp %_ASM_BX,%_ASM_CX
28880 + jb 1234f
28881 + xor %ebx,%ebx
28882 +1234:
28883 +#endif
28884 +
28885 +#endif
28886 +
28887 +2: __copyuser_seg movw %ax,(_DEST)
28888 xor %eax,%eax
28889 EXIT
28890 ENDPROC(__put_user_2)
28891
28892 ENTRY(__put_user_4)
28893 ENTER
28894 +
28895 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28896 + GET_THREAD_INFO(%_ASM_BX)
28897 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28898 sub $3,%_ASM_BX
28899 cmp %_ASM_BX,%_ASM_CX
28900 jae bad_put_user
28901 ASM_STAC
28902 -3: movl %eax,(%_ASM_CX)
28903 +
28904 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28905 + mov pax_user_shadow_base,%_ASM_BX
28906 + cmp %_ASM_BX,%_ASM_CX
28907 + jb 1234f
28908 + xor %ebx,%ebx
28909 +1234:
28910 +#endif
28911 +
28912 +#endif
28913 +
28914 +3: __copyuser_seg movl %eax,(_DEST)
28915 xor %eax,%eax
28916 EXIT
28917 ENDPROC(__put_user_4)
28918
28919 ENTRY(__put_user_8)
28920 ENTER
28921 +
28922 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28923 + GET_THREAD_INFO(%_ASM_BX)
28924 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28925 sub $7,%_ASM_BX
28926 cmp %_ASM_BX,%_ASM_CX
28927 jae bad_put_user
28928 ASM_STAC
28929 -4: mov %_ASM_AX,(%_ASM_CX)
28930 +
28931 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28932 + mov pax_user_shadow_base,%_ASM_BX
28933 + cmp %_ASM_BX,%_ASM_CX
28934 + jb 1234f
28935 + xor %ebx,%ebx
28936 +1234:
28937 +#endif
28938 +
28939 +#endif
28940 +
28941 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28942 #ifdef CONFIG_X86_32
28943 -5: movl %edx,4(%_ASM_CX)
28944 +5: __copyuser_seg movl %edx,4(_DEST)
28945 #endif
28946 xor %eax,%eax
28947 EXIT
28948 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28949 index 1cad221..de671ee 100644
28950 --- a/arch/x86/lib/rwlock.S
28951 +++ b/arch/x86/lib/rwlock.S
28952 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
28953 FRAME
28954 0: LOCK_PREFIX
28955 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28956 +
28957 +#ifdef CONFIG_PAX_REFCOUNT
28958 + jno 1234f
28959 + LOCK_PREFIX
28960 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28961 + int $4
28962 +1234:
28963 + _ASM_EXTABLE(1234b, 1234b)
28964 +#endif
28965 +
28966 1: rep; nop
28967 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
28968 jne 1b
28969 LOCK_PREFIX
28970 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28971 +
28972 +#ifdef CONFIG_PAX_REFCOUNT
28973 + jno 1234f
28974 + LOCK_PREFIX
28975 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28976 + int $4
28977 +1234:
28978 + _ASM_EXTABLE(1234b, 1234b)
28979 +#endif
28980 +
28981 jnz 0b
28982 ENDFRAME
28983 + pax_force_retaddr
28984 ret
28985 CFI_ENDPROC
28986 END(__write_lock_failed)
28987 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
28988 FRAME
28989 0: LOCK_PREFIX
28990 READ_LOCK_SIZE(inc) (%__lock_ptr)
28991 +
28992 +#ifdef CONFIG_PAX_REFCOUNT
28993 + jno 1234f
28994 + LOCK_PREFIX
28995 + READ_LOCK_SIZE(dec) (%__lock_ptr)
28996 + int $4
28997 +1234:
28998 + _ASM_EXTABLE(1234b, 1234b)
28999 +#endif
29000 +
29001 1: rep; nop
29002 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29003 js 1b
29004 LOCK_PREFIX
29005 READ_LOCK_SIZE(dec) (%__lock_ptr)
29006 +
29007 +#ifdef CONFIG_PAX_REFCOUNT
29008 + jno 1234f
29009 + LOCK_PREFIX
29010 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29011 + int $4
29012 +1234:
29013 + _ASM_EXTABLE(1234b, 1234b)
29014 +#endif
29015 +
29016 js 0b
29017 ENDFRAME
29018 + pax_force_retaddr
29019 ret
29020 CFI_ENDPROC
29021 END(__read_lock_failed)
29022 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29023 index 5dff5f0..cadebf4 100644
29024 --- a/arch/x86/lib/rwsem.S
29025 +++ b/arch/x86/lib/rwsem.S
29026 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29027 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29028 CFI_RESTORE __ASM_REG(dx)
29029 restore_common_regs
29030 + pax_force_retaddr
29031 ret
29032 CFI_ENDPROC
29033 ENDPROC(call_rwsem_down_read_failed)
29034 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29035 movq %rax,%rdi
29036 call rwsem_down_write_failed
29037 restore_common_regs
29038 + pax_force_retaddr
29039 ret
29040 CFI_ENDPROC
29041 ENDPROC(call_rwsem_down_write_failed)
29042 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29043 movq %rax,%rdi
29044 call rwsem_wake
29045 restore_common_regs
29046 -1: ret
29047 +1: pax_force_retaddr
29048 + ret
29049 CFI_ENDPROC
29050 ENDPROC(call_rwsem_wake)
29051
29052 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29053 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29054 CFI_RESTORE __ASM_REG(dx)
29055 restore_common_regs
29056 + pax_force_retaddr
29057 ret
29058 CFI_ENDPROC
29059 ENDPROC(call_rwsem_downgrade_wake)
29060 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29061 index a63efd6..ccecad8 100644
29062 --- a/arch/x86/lib/thunk_64.S
29063 +++ b/arch/x86/lib/thunk_64.S
29064 @@ -8,6 +8,7 @@
29065 #include <linux/linkage.h>
29066 #include <asm/dwarf2.h>
29067 #include <asm/calling.h>
29068 +#include <asm/alternative-asm.h>
29069
29070 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29071 .macro THUNK name, func, put_ret_addr_in_rdi=0
29072 @@ -41,5 +42,6 @@
29073 SAVE_ARGS
29074 restore:
29075 RESTORE_ARGS
29076 + pax_force_retaddr
29077 ret
29078 CFI_ENDPROC
29079 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29080 index 3eb18ac..6890bc3 100644
29081 --- a/arch/x86/lib/usercopy_32.c
29082 +++ b/arch/x86/lib/usercopy_32.c
29083 @@ -42,11 +42,13 @@ do { \
29084 int __d0; \
29085 might_fault(); \
29086 __asm__ __volatile__( \
29087 + __COPYUSER_SET_ES \
29088 ASM_STAC "\n" \
29089 "0: rep; stosl\n" \
29090 " movl %2,%0\n" \
29091 "1: rep; stosb\n" \
29092 "2: " ASM_CLAC "\n" \
29093 + __COPYUSER_RESTORE_ES \
29094 ".section .fixup,\"ax\"\n" \
29095 "3: lea 0(%2,%0,4),%0\n" \
29096 " jmp 2b\n" \
29097 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29098
29099 #ifdef CONFIG_X86_INTEL_USERCOPY
29100 static unsigned long
29101 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29102 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29103 {
29104 int d0, d1;
29105 __asm__ __volatile__(
29106 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29107 " .align 2,0x90\n"
29108 "3: movl 0(%4), %%eax\n"
29109 "4: movl 4(%4), %%edx\n"
29110 - "5: movl %%eax, 0(%3)\n"
29111 - "6: movl %%edx, 4(%3)\n"
29112 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29113 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29114 "7: movl 8(%4), %%eax\n"
29115 "8: movl 12(%4),%%edx\n"
29116 - "9: movl %%eax, 8(%3)\n"
29117 - "10: movl %%edx, 12(%3)\n"
29118 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29119 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29120 "11: movl 16(%4), %%eax\n"
29121 "12: movl 20(%4), %%edx\n"
29122 - "13: movl %%eax, 16(%3)\n"
29123 - "14: movl %%edx, 20(%3)\n"
29124 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29125 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29126 "15: movl 24(%4), %%eax\n"
29127 "16: movl 28(%4), %%edx\n"
29128 - "17: movl %%eax, 24(%3)\n"
29129 - "18: movl %%edx, 28(%3)\n"
29130 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29131 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29132 "19: movl 32(%4), %%eax\n"
29133 "20: movl 36(%4), %%edx\n"
29134 - "21: movl %%eax, 32(%3)\n"
29135 - "22: movl %%edx, 36(%3)\n"
29136 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29137 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29138 "23: movl 40(%4), %%eax\n"
29139 "24: movl 44(%4), %%edx\n"
29140 - "25: movl %%eax, 40(%3)\n"
29141 - "26: movl %%edx, 44(%3)\n"
29142 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29143 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29144 "27: movl 48(%4), %%eax\n"
29145 "28: movl 52(%4), %%edx\n"
29146 - "29: movl %%eax, 48(%3)\n"
29147 - "30: movl %%edx, 52(%3)\n"
29148 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29149 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29150 "31: movl 56(%4), %%eax\n"
29151 "32: movl 60(%4), %%edx\n"
29152 - "33: movl %%eax, 56(%3)\n"
29153 - "34: movl %%edx, 60(%3)\n"
29154 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29155 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29156 " addl $-64, %0\n"
29157 " addl $64, %4\n"
29158 " addl $64, %3\n"
29159 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29160 " shrl $2, %0\n"
29161 " andl $3, %%eax\n"
29162 " cld\n"
29163 + __COPYUSER_SET_ES
29164 "99: rep; movsl\n"
29165 "36: movl %%eax, %0\n"
29166 "37: rep; movsb\n"
29167 "100:\n"
29168 + __COPYUSER_RESTORE_ES
29169 ".section .fixup,\"ax\"\n"
29170 "101: lea 0(%%eax,%0,4),%0\n"
29171 " jmp 100b\n"
29172 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29173 }
29174
29175 static unsigned long
29176 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29177 +{
29178 + int d0, d1;
29179 + __asm__ __volatile__(
29180 + " .align 2,0x90\n"
29181 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29182 + " cmpl $67, %0\n"
29183 + " jbe 3f\n"
29184 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29185 + " .align 2,0x90\n"
29186 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29187 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29188 + "5: movl %%eax, 0(%3)\n"
29189 + "6: movl %%edx, 4(%3)\n"
29190 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29191 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29192 + "9: movl %%eax, 8(%3)\n"
29193 + "10: movl %%edx, 12(%3)\n"
29194 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29195 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29196 + "13: movl %%eax, 16(%3)\n"
29197 + "14: movl %%edx, 20(%3)\n"
29198 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29199 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29200 + "17: movl %%eax, 24(%3)\n"
29201 + "18: movl %%edx, 28(%3)\n"
29202 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29203 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29204 + "21: movl %%eax, 32(%3)\n"
29205 + "22: movl %%edx, 36(%3)\n"
29206 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29207 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29208 + "25: movl %%eax, 40(%3)\n"
29209 + "26: movl %%edx, 44(%3)\n"
29210 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29211 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29212 + "29: movl %%eax, 48(%3)\n"
29213 + "30: movl %%edx, 52(%3)\n"
29214 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29215 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29216 + "33: movl %%eax, 56(%3)\n"
29217 + "34: movl %%edx, 60(%3)\n"
29218 + " addl $-64, %0\n"
29219 + " addl $64, %4\n"
29220 + " addl $64, %3\n"
29221 + " cmpl $63, %0\n"
29222 + " ja 1b\n"
29223 + "35: movl %0, %%eax\n"
29224 + " shrl $2, %0\n"
29225 + " andl $3, %%eax\n"
29226 + " cld\n"
29227 + "99: rep; "__copyuser_seg" movsl\n"
29228 + "36: movl %%eax, %0\n"
29229 + "37: rep; "__copyuser_seg" movsb\n"
29230 + "100:\n"
29231 + ".section .fixup,\"ax\"\n"
29232 + "101: lea 0(%%eax,%0,4),%0\n"
29233 + " jmp 100b\n"
29234 + ".previous\n"
29235 + _ASM_EXTABLE(1b,100b)
29236 + _ASM_EXTABLE(2b,100b)
29237 + _ASM_EXTABLE(3b,100b)
29238 + _ASM_EXTABLE(4b,100b)
29239 + _ASM_EXTABLE(5b,100b)
29240 + _ASM_EXTABLE(6b,100b)
29241 + _ASM_EXTABLE(7b,100b)
29242 + _ASM_EXTABLE(8b,100b)
29243 + _ASM_EXTABLE(9b,100b)
29244 + _ASM_EXTABLE(10b,100b)
29245 + _ASM_EXTABLE(11b,100b)
29246 + _ASM_EXTABLE(12b,100b)
29247 + _ASM_EXTABLE(13b,100b)
29248 + _ASM_EXTABLE(14b,100b)
29249 + _ASM_EXTABLE(15b,100b)
29250 + _ASM_EXTABLE(16b,100b)
29251 + _ASM_EXTABLE(17b,100b)
29252 + _ASM_EXTABLE(18b,100b)
29253 + _ASM_EXTABLE(19b,100b)
29254 + _ASM_EXTABLE(20b,100b)
29255 + _ASM_EXTABLE(21b,100b)
29256 + _ASM_EXTABLE(22b,100b)
29257 + _ASM_EXTABLE(23b,100b)
29258 + _ASM_EXTABLE(24b,100b)
29259 + _ASM_EXTABLE(25b,100b)
29260 + _ASM_EXTABLE(26b,100b)
29261 + _ASM_EXTABLE(27b,100b)
29262 + _ASM_EXTABLE(28b,100b)
29263 + _ASM_EXTABLE(29b,100b)
29264 + _ASM_EXTABLE(30b,100b)
29265 + _ASM_EXTABLE(31b,100b)
29266 + _ASM_EXTABLE(32b,100b)
29267 + _ASM_EXTABLE(33b,100b)
29268 + _ASM_EXTABLE(34b,100b)
29269 + _ASM_EXTABLE(35b,100b)
29270 + _ASM_EXTABLE(36b,100b)
29271 + _ASM_EXTABLE(37b,100b)
29272 + _ASM_EXTABLE(99b,101b)
29273 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29274 + : "1"(to), "2"(from), "0"(size)
29275 + : "eax", "edx", "memory");
29276 + return size;
29277 +}
29278 +
29279 +static unsigned long __size_overflow(3)
29280 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29281 {
29282 int d0, d1;
29283 __asm__ __volatile__(
29284 " .align 2,0x90\n"
29285 - "0: movl 32(%4), %%eax\n"
29286 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29287 " cmpl $67, %0\n"
29288 " jbe 2f\n"
29289 - "1: movl 64(%4), %%eax\n"
29290 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29291 " .align 2,0x90\n"
29292 - "2: movl 0(%4), %%eax\n"
29293 - "21: movl 4(%4), %%edx\n"
29294 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29295 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29296 " movl %%eax, 0(%3)\n"
29297 " movl %%edx, 4(%3)\n"
29298 - "3: movl 8(%4), %%eax\n"
29299 - "31: movl 12(%4),%%edx\n"
29300 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29301 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29302 " movl %%eax, 8(%3)\n"
29303 " movl %%edx, 12(%3)\n"
29304 - "4: movl 16(%4), %%eax\n"
29305 - "41: movl 20(%4), %%edx\n"
29306 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29307 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29308 " movl %%eax, 16(%3)\n"
29309 " movl %%edx, 20(%3)\n"
29310 - "10: movl 24(%4), %%eax\n"
29311 - "51: movl 28(%4), %%edx\n"
29312 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29313 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29314 " movl %%eax, 24(%3)\n"
29315 " movl %%edx, 28(%3)\n"
29316 - "11: movl 32(%4), %%eax\n"
29317 - "61: movl 36(%4), %%edx\n"
29318 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29319 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29320 " movl %%eax, 32(%3)\n"
29321 " movl %%edx, 36(%3)\n"
29322 - "12: movl 40(%4), %%eax\n"
29323 - "71: movl 44(%4), %%edx\n"
29324 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29325 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29326 " movl %%eax, 40(%3)\n"
29327 " movl %%edx, 44(%3)\n"
29328 - "13: movl 48(%4), %%eax\n"
29329 - "81: movl 52(%4), %%edx\n"
29330 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29331 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29332 " movl %%eax, 48(%3)\n"
29333 " movl %%edx, 52(%3)\n"
29334 - "14: movl 56(%4), %%eax\n"
29335 - "91: movl 60(%4), %%edx\n"
29336 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29337 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29338 " movl %%eax, 56(%3)\n"
29339 " movl %%edx, 60(%3)\n"
29340 " addl $-64, %0\n"
29341 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29342 " shrl $2, %0\n"
29343 " andl $3, %%eax\n"
29344 " cld\n"
29345 - "6: rep; movsl\n"
29346 + "6: rep; "__copyuser_seg" movsl\n"
29347 " movl %%eax,%0\n"
29348 - "7: rep; movsb\n"
29349 + "7: rep; "__copyuser_seg" movsb\n"
29350 "8:\n"
29351 ".section .fixup,\"ax\"\n"
29352 "9: lea 0(%%eax,%0,4),%0\n"
29353 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29354 * hyoshiok@miraclelinux.com
29355 */
29356
29357 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29358 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29359 const void __user *from, unsigned long size)
29360 {
29361 int d0, d1;
29362
29363 __asm__ __volatile__(
29364 " .align 2,0x90\n"
29365 - "0: movl 32(%4), %%eax\n"
29366 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29367 " cmpl $67, %0\n"
29368 " jbe 2f\n"
29369 - "1: movl 64(%4), %%eax\n"
29370 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29371 " .align 2,0x90\n"
29372 - "2: movl 0(%4), %%eax\n"
29373 - "21: movl 4(%4), %%edx\n"
29374 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29375 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29376 " movnti %%eax, 0(%3)\n"
29377 " movnti %%edx, 4(%3)\n"
29378 - "3: movl 8(%4), %%eax\n"
29379 - "31: movl 12(%4),%%edx\n"
29380 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29381 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29382 " movnti %%eax, 8(%3)\n"
29383 " movnti %%edx, 12(%3)\n"
29384 - "4: movl 16(%4), %%eax\n"
29385 - "41: movl 20(%4), %%edx\n"
29386 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29387 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29388 " movnti %%eax, 16(%3)\n"
29389 " movnti %%edx, 20(%3)\n"
29390 - "10: movl 24(%4), %%eax\n"
29391 - "51: movl 28(%4), %%edx\n"
29392 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29393 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29394 " movnti %%eax, 24(%3)\n"
29395 " movnti %%edx, 28(%3)\n"
29396 - "11: movl 32(%4), %%eax\n"
29397 - "61: movl 36(%4), %%edx\n"
29398 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29399 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29400 " movnti %%eax, 32(%3)\n"
29401 " movnti %%edx, 36(%3)\n"
29402 - "12: movl 40(%4), %%eax\n"
29403 - "71: movl 44(%4), %%edx\n"
29404 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29405 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29406 " movnti %%eax, 40(%3)\n"
29407 " movnti %%edx, 44(%3)\n"
29408 - "13: movl 48(%4), %%eax\n"
29409 - "81: movl 52(%4), %%edx\n"
29410 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29411 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29412 " movnti %%eax, 48(%3)\n"
29413 " movnti %%edx, 52(%3)\n"
29414 - "14: movl 56(%4), %%eax\n"
29415 - "91: movl 60(%4), %%edx\n"
29416 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29417 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29418 " movnti %%eax, 56(%3)\n"
29419 " movnti %%edx, 60(%3)\n"
29420 " addl $-64, %0\n"
29421 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29422 " shrl $2, %0\n"
29423 " andl $3, %%eax\n"
29424 " cld\n"
29425 - "6: rep; movsl\n"
29426 + "6: rep; "__copyuser_seg" movsl\n"
29427 " movl %%eax,%0\n"
29428 - "7: rep; movsb\n"
29429 + "7: rep; "__copyuser_seg" movsb\n"
29430 "8:\n"
29431 ".section .fixup,\"ax\"\n"
29432 "9: lea 0(%%eax,%0,4),%0\n"
29433 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29434 return size;
29435 }
29436
29437 -static unsigned long __copy_user_intel_nocache(void *to,
29438 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29439 const void __user *from, unsigned long size)
29440 {
29441 int d0, d1;
29442
29443 __asm__ __volatile__(
29444 " .align 2,0x90\n"
29445 - "0: movl 32(%4), %%eax\n"
29446 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29447 " cmpl $67, %0\n"
29448 " jbe 2f\n"
29449 - "1: movl 64(%4), %%eax\n"
29450 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29451 " .align 2,0x90\n"
29452 - "2: movl 0(%4), %%eax\n"
29453 - "21: movl 4(%4), %%edx\n"
29454 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29455 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29456 " movnti %%eax, 0(%3)\n"
29457 " movnti %%edx, 4(%3)\n"
29458 - "3: movl 8(%4), %%eax\n"
29459 - "31: movl 12(%4),%%edx\n"
29460 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29461 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29462 " movnti %%eax, 8(%3)\n"
29463 " movnti %%edx, 12(%3)\n"
29464 - "4: movl 16(%4), %%eax\n"
29465 - "41: movl 20(%4), %%edx\n"
29466 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29467 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29468 " movnti %%eax, 16(%3)\n"
29469 " movnti %%edx, 20(%3)\n"
29470 - "10: movl 24(%4), %%eax\n"
29471 - "51: movl 28(%4), %%edx\n"
29472 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29473 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29474 " movnti %%eax, 24(%3)\n"
29475 " movnti %%edx, 28(%3)\n"
29476 - "11: movl 32(%4), %%eax\n"
29477 - "61: movl 36(%4), %%edx\n"
29478 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29479 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29480 " movnti %%eax, 32(%3)\n"
29481 " movnti %%edx, 36(%3)\n"
29482 - "12: movl 40(%4), %%eax\n"
29483 - "71: movl 44(%4), %%edx\n"
29484 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29485 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29486 " movnti %%eax, 40(%3)\n"
29487 " movnti %%edx, 44(%3)\n"
29488 - "13: movl 48(%4), %%eax\n"
29489 - "81: movl 52(%4), %%edx\n"
29490 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29491 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29492 " movnti %%eax, 48(%3)\n"
29493 " movnti %%edx, 52(%3)\n"
29494 - "14: movl 56(%4), %%eax\n"
29495 - "91: movl 60(%4), %%edx\n"
29496 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29497 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29498 " movnti %%eax, 56(%3)\n"
29499 " movnti %%edx, 60(%3)\n"
29500 " addl $-64, %0\n"
29501 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29502 " shrl $2, %0\n"
29503 " andl $3, %%eax\n"
29504 " cld\n"
29505 - "6: rep; movsl\n"
29506 + "6: rep; "__copyuser_seg" movsl\n"
29507 " movl %%eax,%0\n"
29508 - "7: rep; movsb\n"
29509 + "7: rep; "__copyuser_seg" movsb\n"
29510 "8:\n"
29511 ".section .fixup,\"ax\"\n"
29512 "9: lea 0(%%eax,%0,4),%0\n"
29513 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29514 */
29515 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29516 unsigned long size);
29517 -unsigned long __copy_user_intel(void __user *to, const void *from,
29518 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29519 + unsigned long size);
29520 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29521 unsigned long size);
29522 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29523 const void __user *from, unsigned long size);
29524 #endif /* CONFIG_X86_INTEL_USERCOPY */
29525
29526 /* Generic arbitrary sized copy. */
29527 -#define __copy_user(to, from, size) \
29528 +#define __copy_user(to, from, size, prefix, set, restore) \
29529 do { \
29530 int __d0, __d1, __d2; \
29531 __asm__ __volatile__( \
29532 + set \
29533 " cmp $7,%0\n" \
29534 " jbe 1f\n" \
29535 " movl %1,%0\n" \
29536 " negl %0\n" \
29537 " andl $7,%0\n" \
29538 " subl %0,%3\n" \
29539 - "4: rep; movsb\n" \
29540 + "4: rep; "prefix"movsb\n" \
29541 " movl %3,%0\n" \
29542 " shrl $2,%0\n" \
29543 " andl $3,%3\n" \
29544 " .align 2,0x90\n" \
29545 - "0: rep; movsl\n" \
29546 + "0: rep; "prefix"movsl\n" \
29547 " movl %3,%0\n" \
29548 - "1: rep; movsb\n" \
29549 + "1: rep; "prefix"movsb\n" \
29550 "2:\n" \
29551 + restore \
29552 ".section .fixup,\"ax\"\n" \
29553 "5: addl %3,%0\n" \
29554 " jmp 2b\n" \
29555 @@ -538,14 +650,14 @@ do { \
29556 " negl %0\n" \
29557 " andl $7,%0\n" \
29558 " subl %0,%3\n" \
29559 - "4: rep; movsb\n" \
29560 + "4: rep; "__copyuser_seg"movsb\n" \
29561 " movl %3,%0\n" \
29562 " shrl $2,%0\n" \
29563 " andl $3,%3\n" \
29564 " .align 2,0x90\n" \
29565 - "0: rep; movsl\n" \
29566 + "0: rep; "__copyuser_seg"movsl\n" \
29567 " movl %3,%0\n" \
29568 - "1: rep; movsb\n" \
29569 + "1: rep; "__copyuser_seg"movsb\n" \
29570 "2:\n" \
29571 ".section .fixup,\"ax\"\n" \
29572 "5: addl %3,%0\n" \
29573 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29574 {
29575 stac();
29576 if (movsl_is_ok(to, from, n))
29577 - __copy_user(to, from, n);
29578 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29579 else
29580 - n = __copy_user_intel(to, from, n);
29581 + n = __generic_copy_to_user_intel(to, from, n);
29582 clac();
29583 return n;
29584 }
29585 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29586 {
29587 stac();
29588 if (movsl_is_ok(to, from, n))
29589 - __copy_user(to, from, n);
29590 + __copy_user(to, from, n, __copyuser_seg, "", "");
29591 else
29592 - n = __copy_user_intel((void __user *)to,
29593 - (const void *)from, n);
29594 + n = __generic_copy_from_user_intel(to, from, n);
29595 clac();
29596 return n;
29597 }
29598 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29599 if (n > 64 && cpu_has_xmm2)
29600 n = __copy_user_intel_nocache(to, from, n);
29601 else
29602 - __copy_user(to, from, n);
29603 + __copy_user(to, from, n, __copyuser_seg, "", "");
29604 #else
29605 - __copy_user(to, from, n);
29606 + __copy_user(to, from, n, __copyuser_seg, "", "");
29607 #endif
29608 clac();
29609 return n;
29610 }
29611 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29612
29613 -/**
29614 - * copy_to_user: - Copy a block of data into user space.
29615 - * @to: Destination address, in user space.
29616 - * @from: Source address, in kernel space.
29617 - * @n: Number of bytes to copy.
29618 - *
29619 - * Context: User context only. This function may sleep.
29620 - *
29621 - * Copy data from kernel space to user space.
29622 - *
29623 - * Returns number of bytes that could not be copied.
29624 - * On success, this will be zero.
29625 - */
29626 -unsigned long
29627 -copy_to_user(void __user *to, const void *from, unsigned long n)
29628 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29629 +void __set_fs(mm_segment_t x)
29630 {
29631 - if (access_ok(VERIFY_WRITE, to, n))
29632 - n = __copy_to_user(to, from, n);
29633 - return n;
29634 + switch (x.seg) {
29635 + case 0:
29636 + loadsegment(gs, 0);
29637 + break;
29638 + case TASK_SIZE_MAX:
29639 + loadsegment(gs, __USER_DS);
29640 + break;
29641 + case -1UL:
29642 + loadsegment(gs, __KERNEL_DS);
29643 + break;
29644 + default:
29645 + BUG();
29646 + }
29647 }
29648 -EXPORT_SYMBOL(copy_to_user);
29649 +EXPORT_SYMBOL(__set_fs);
29650
29651 -/**
29652 - * copy_from_user: - Copy a block of data from user space.
29653 - * @to: Destination address, in kernel space.
29654 - * @from: Source address, in user space.
29655 - * @n: Number of bytes to copy.
29656 - *
29657 - * Context: User context only. This function may sleep.
29658 - *
29659 - * Copy data from user space to kernel space.
29660 - *
29661 - * Returns number of bytes that could not be copied.
29662 - * On success, this will be zero.
29663 - *
29664 - * If some data could not be copied, this function will pad the copied
29665 - * data to the requested size using zero bytes.
29666 - */
29667 -unsigned long
29668 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29669 +void set_fs(mm_segment_t x)
29670 {
29671 - if (access_ok(VERIFY_READ, from, n))
29672 - n = __copy_from_user(to, from, n);
29673 - else
29674 - memset(to, 0, n);
29675 - return n;
29676 + current_thread_info()->addr_limit = x;
29677 + __set_fs(x);
29678 }
29679 -EXPORT_SYMBOL(_copy_from_user);
29680 +EXPORT_SYMBOL(set_fs);
29681 +#endif
29682 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29683 index 906fea3..0194a18 100644
29684 --- a/arch/x86/lib/usercopy_64.c
29685 +++ b/arch/x86/lib/usercopy_64.c
29686 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29687 might_fault();
29688 /* no memory constraint because it doesn't change any memory gcc knows
29689 about */
29690 + pax_open_userland();
29691 stac();
29692 asm volatile(
29693 " testq %[size8],%[size8]\n"
29694 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29695 _ASM_EXTABLE(0b,3b)
29696 _ASM_EXTABLE(1b,2b)
29697 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29698 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29699 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29700 [zero] "r" (0UL), [eight] "r" (8UL));
29701 clac();
29702 + pax_close_userland();
29703 return size;
29704 }
29705 EXPORT_SYMBOL(__clear_user);
29706 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29707 }
29708 EXPORT_SYMBOL(clear_user);
29709
29710 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29711 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29712 {
29713 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29714 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29715 - }
29716 - return len;
29717 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29718 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29719 + return len;
29720 }
29721 EXPORT_SYMBOL(copy_in_user);
29722
29723 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29724 * it is not necessary to optimize tail handling.
29725 */
29726 unsigned long
29727 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29728 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29729 {
29730 char c;
29731 unsigned zero_len;
29732
29733 + clac();
29734 + pax_close_userland();
29735 for (; len; --len, to++) {
29736 if (__get_user_nocheck(c, from++, sizeof(char)))
29737 break;
29738 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29739 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29740 if (__put_user_nocheck(c, to++, sizeof(char)))
29741 break;
29742 - clac();
29743 return len;
29744 }
29745 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29746 index 23d8e5f..9ccc13a 100644
29747 --- a/arch/x86/mm/Makefile
29748 +++ b/arch/x86/mm/Makefile
29749 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29750 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29751
29752 obj-$(CONFIG_MEMTEST) += memtest.o
29753 +
29754 +quote:="
29755 +obj-$(CONFIG_X86_64) += uderef_64.o
29756 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29757 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29758 index 903ec1e..c4166b2 100644
29759 --- a/arch/x86/mm/extable.c
29760 +++ b/arch/x86/mm/extable.c
29761 @@ -6,12 +6,24 @@
29762 static inline unsigned long
29763 ex_insn_addr(const struct exception_table_entry *x)
29764 {
29765 - return (unsigned long)&x->insn + x->insn;
29766 + unsigned long reloc = 0;
29767 +
29768 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29769 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29770 +#endif
29771 +
29772 + return (unsigned long)&x->insn + x->insn + reloc;
29773 }
29774 static inline unsigned long
29775 ex_fixup_addr(const struct exception_table_entry *x)
29776 {
29777 - return (unsigned long)&x->fixup + x->fixup;
29778 + unsigned long reloc = 0;
29779 +
29780 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29781 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29782 +#endif
29783 +
29784 + return (unsigned long)&x->fixup + x->fixup + reloc;
29785 }
29786
29787 int fixup_exception(struct pt_regs *regs)
29788 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29789 unsigned long new_ip;
29790
29791 #ifdef CONFIG_PNPBIOS
29792 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29793 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29794 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29795 extern u32 pnp_bios_is_utter_crap;
29796 pnp_bios_is_utter_crap = 1;
29797 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29798 i += 4;
29799 p->fixup -= i;
29800 i += 4;
29801 +
29802 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29803 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29804 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29805 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29806 +#endif
29807 +
29808 }
29809 }
29810
29811 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29812 index 654be4a..a4a3da1 100644
29813 --- a/arch/x86/mm/fault.c
29814 +++ b/arch/x86/mm/fault.c
29815 @@ -14,11 +14,18 @@
29816 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29817 #include <linux/prefetch.h> /* prefetchw */
29818 #include <linux/context_tracking.h> /* exception_enter(), ... */
29819 +#include <linux/unistd.h>
29820 +#include <linux/compiler.h>
29821
29822 #include <asm/traps.h> /* dotraplinkage, ... */
29823 #include <asm/pgalloc.h> /* pgd_*(), ... */
29824 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29825 #include <asm/fixmap.h> /* VSYSCALL_START */
29826 +#include <asm/tlbflush.h>
29827 +
29828 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29829 +#include <asm/stacktrace.h>
29830 +#endif
29831
29832 /*
29833 * Page fault error code bits:
29834 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29835 int ret = 0;
29836
29837 /* kprobe_running() needs smp_processor_id() */
29838 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29839 + if (kprobes_built_in() && !user_mode(regs)) {
29840 preempt_disable();
29841 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29842 ret = 1;
29843 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29844 return !instr_lo || (instr_lo>>1) == 1;
29845 case 0x00:
29846 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29847 - if (probe_kernel_address(instr, opcode))
29848 + if (user_mode(regs)) {
29849 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29850 + return 0;
29851 + } else if (probe_kernel_address(instr, opcode))
29852 return 0;
29853
29854 *prefetch = (instr_lo == 0xF) &&
29855 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29856 while (instr < max_instr) {
29857 unsigned char opcode;
29858
29859 - if (probe_kernel_address(instr, opcode))
29860 + if (user_mode(regs)) {
29861 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29862 + break;
29863 + } else if (probe_kernel_address(instr, opcode))
29864 break;
29865
29866 instr++;
29867 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29868 force_sig_info(si_signo, &info, tsk);
29869 }
29870
29871 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29872 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29873 +#endif
29874 +
29875 +#ifdef CONFIG_PAX_EMUTRAMP
29876 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29877 +#endif
29878 +
29879 +#ifdef CONFIG_PAX_PAGEEXEC
29880 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29881 +{
29882 + pgd_t *pgd;
29883 + pud_t *pud;
29884 + pmd_t *pmd;
29885 +
29886 + pgd = pgd_offset(mm, address);
29887 + if (!pgd_present(*pgd))
29888 + return NULL;
29889 + pud = pud_offset(pgd, address);
29890 + if (!pud_present(*pud))
29891 + return NULL;
29892 + pmd = pmd_offset(pud, address);
29893 + if (!pmd_present(*pmd))
29894 + return NULL;
29895 + return pmd;
29896 +}
29897 +#endif
29898 +
29899 DEFINE_SPINLOCK(pgd_lock);
29900 LIST_HEAD(pgd_list);
29901
29902 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29903 for (address = VMALLOC_START & PMD_MASK;
29904 address >= TASK_SIZE && address < FIXADDR_TOP;
29905 address += PMD_SIZE) {
29906 +
29907 +#ifdef CONFIG_PAX_PER_CPU_PGD
29908 + unsigned long cpu;
29909 +#else
29910 struct page *page;
29911 +#endif
29912
29913 spin_lock(&pgd_lock);
29914 +
29915 +#ifdef CONFIG_PAX_PER_CPU_PGD
29916 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29917 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29918 + pmd_t *ret;
29919 +
29920 + ret = vmalloc_sync_one(pgd, address);
29921 + if (!ret)
29922 + break;
29923 + pgd = get_cpu_pgd(cpu, kernel);
29924 +#else
29925 list_for_each_entry(page, &pgd_list, lru) {
29926 + pgd_t *pgd;
29927 spinlock_t *pgt_lock;
29928 pmd_t *ret;
29929
29930 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29931 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29932
29933 spin_lock(pgt_lock);
29934 - ret = vmalloc_sync_one(page_address(page), address);
29935 + pgd = page_address(page);
29936 +#endif
29937 +
29938 + ret = vmalloc_sync_one(pgd, address);
29939 +
29940 +#ifndef CONFIG_PAX_PER_CPU_PGD
29941 spin_unlock(pgt_lock);
29942 +#endif
29943
29944 if (!ret)
29945 break;
29946 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29947 * an interrupt in the middle of a task switch..
29948 */
29949 pgd_paddr = read_cr3();
29950 +
29951 +#ifdef CONFIG_PAX_PER_CPU_PGD
29952 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29953 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29954 +#endif
29955 +
29956 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
29957 if (!pmd_k)
29958 return -1;
29959 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29960 * happen within a race in page table update. In the later
29961 * case just flush:
29962 */
29963 - pgd = pgd_offset(current->active_mm, address);
29964 +
29965 pgd_ref = pgd_offset_k(address);
29966 if (pgd_none(*pgd_ref))
29967 return -1;
29968
29969 +#ifdef CONFIG_PAX_PER_CPU_PGD
29970 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
29971 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
29972 + if (pgd_none(*pgd)) {
29973 + set_pgd(pgd, *pgd_ref);
29974 + arch_flush_lazy_mmu_mode();
29975 + } else {
29976 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
29977 + }
29978 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
29979 +#else
29980 + pgd = pgd_offset(current->active_mm, address);
29981 +#endif
29982 +
29983 if (pgd_none(*pgd)) {
29984 set_pgd(pgd, *pgd_ref);
29985 arch_flush_lazy_mmu_mode();
29986 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
29987 static int is_errata100(struct pt_regs *regs, unsigned long address)
29988 {
29989 #ifdef CONFIG_X86_64
29990 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
29991 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
29992 return 1;
29993 #endif
29994 return 0;
29995 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
29996 }
29997
29998 static const char nx_warning[] = KERN_CRIT
29999 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30000 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30001
30002 static void
30003 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30004 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30005 if (!oops_may_print())
30006 return;
30007
30008 - if (error_code & PF_INSTR) {
30009 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30010 unsigned int level;
30011
30012 pte_t *pte = lookup_address(address, &level);
30013
30014 if (pte && pte_present(*pte) && !pte_exec(*pte))
30015 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30016 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30017 }
30018
30019 +#ifdef CONFIG_PAX_KERNEXEC
30020 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30021 + if (current->signal->curr_ip)
30022 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30023 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30024 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30025 + else
30026 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30027 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30028 + }
30029 +#endif
30030 +
30031 printk(KERN_ALERT "BUG: unable to handle kernel ");
30032 if (address < PAGE_SIZE)
30033 printk(KERN_CONT "NULL pointer dereference");
30034 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30035 return;
30036 }
30037 #endif
30038 +
30039 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30040 + if (pax_is_fetch_fault(regs, error_code, address)) {
30041 +
30042 +#ifdef CONFIG_PAX_EMUTRAMP
30043 + switch (pax_handle_fetch_fault(regs)) {
30044 + case 2:
30045 + return;
30046 + }
30047 +#endif
30048 +
30049 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30050 + do_group_exit(SIGKILL);
30051 + }
30052 +#endif
30053 +
30054 /* Kernel addresses are always protection faults: */
30055 if (address >= TASK_SIZE)
30056 error_code |= PF_PROT;
30057 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30058 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30059 printk(KERN_ERR
30060 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30061 - tsk->comm, tsk->pid, address);
30062 + tsk->comm, task_pid_nr(tsk), address);
30063 code = BUS_MCEERR_AR;
30064 }
30065 #endif
30066 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30067 return 1;
30068 }
30069
30070 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30071 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30072 +{
30073 + pte_t *pte;
30074 + pmd_t *pmd;
30075 + spinlock_t *ptl;
30076 + unsigned char pte_mask;
30077 +
30078 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30079 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30080 + return 0;
30081 +
30082 + /* PaX: it's our fault, let's handle it if we can */
30083 +
30084 + /* PaX: take a look at read faults before acquiring any locks */
30085 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30086 + /* instruction fetch attempt from a protected page in user mode */
30087 + up_read(&mm->mmap_sem);
30088 +
30089 +#ifdef CONFIG_PAX_EMUTRAMP
30090 + switch (pax_handle_fetch_fault(regs)) {
30091 + case 2:
30092 + return 1;
30093 + }
30094 +#endif
30095 +
30096 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30097 + do_group_exit(SIGKILL);
30098 + }
30099 +
30100 + pmd = pax_get_pmd(mm, address);
30101 + if (unlikely(!pmd))
30102 + return 0;
30103 +
30104 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30105 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30106 + pte_unmap_unlock(pte, ptl);
30107 + return 0;
30108 + }
30109 +
30110 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30111 + /* write attempt to a protected page in user mode */
30112 + pte_unmap_unlock(pte, ptl);
30113 + return 0;
30114 + }
30115 +
30116 +#ifdef CONFIG_SMP
30117 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30118 +#else
30119 + if (likely(address > get_limit(regs->cs)))
30120 +#endif
30121 + {
30122 + set_pte(pte, pte_mkread(*pte));
30123 + __flush_tlb_one(address);
30124 + pte_unmap_unlock(pte, ptl);
30125 + up_read(&mm->mmap_sem);
30126 + return 1;
30127 + }
30128 +
30129 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30130 +
30131 + /*
30132 + * PaX: fill DTLB with user rights and retry
30133 + */
30134 + __asm__ __volatile__ (
30135 + "orb %2,(%1)\n"
30136 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30137 +/*
30138 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30139 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30140 + * page fault when examined during a TLB load attempt. this is true not only
30141 + * for PTEs holding a non-present entry but also present entries that will
30142 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30143 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30144 + * for our target pages since their PTEs are simply not in the TLBs at all.
30145 +
30146 + * the best thing in omitting it is that we gain around 15-20% speed in the
30147 + * fast path of the page fault handler and can get rid of tracing since we
30148 + * can no longer flush unintended entries.
30149 + */
30150 + "invlpg (%0)\n"
30151 +#endif
30152 + __copyuser_seg"testb $0,(%0)\n"
30153 + "xorb %3,(%1)\n"
30154 + :
30155 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30156 + : "memory", "cc");
30157 + pte_unmap_unlock(pte, ptl);
30158 + up_read(&mm->mmap_sem);
30159 + return 1;
30160 +}
30161 +#endif
30162 +
30163 /*
30164 * Handle a spurious fault caused by a stale TLB entry.
30165 *
30166 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30167 static inline int
30168 access_error(unsigned long error_code, struct vm_area_struct *vma)
30169 {
30170 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30171 + return 1;
30172 +
30173 if (error_code & PF_WRITE) {
30174 /* write, present and write, not present: */
30175 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30176 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30177 if (error_code & PF_USER)
30178 return false;
30179
30180 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30181 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30182 return false;
30183
30184 return true;
30185 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30186 {
30187 struct vm_area_struct *vma;
30188 struct task_struct *tsk;
30189 - unsigned long address;
30190 struct mm_struct *mm;
30191 int fault;
30192 int write = error_code & PF_WRITE;
30193 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30194 (write ? FAULT_FLAG_WRITE : 0);
30195
30196 - tsk = current;
30197 - mm = tsk->mm;
30198 -
30199 /* Get the faulting address: */
30200 - address = read_cr2();
30201 + unsigned long address = read_cr2();
30202 +
30203 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30204 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30205 + if (!search_exception_tables(regs->ip)) {
30206 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30207 + bad_area_nosemaphore(regs, error_code, address);
30208 + return;
30209 + }
30210 + if (address < pax_user_shadow_base) {
30211 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30212 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30213 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30214 + } else
30215 + address -= pax_user_shadow_base;
30216 + }
30217 +#endif
30218 +
30219 + tsk = current;
30220 + mm = tsk->mm;
30221
30222 /*
30223 * Detect and handle instructions that would cause a page fault for
30224 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30225 * User-mode registers count as a user access even for any
30226 * potential system fault or CPU buglet:
30227 */
30228 - if (user_mode_vm(regs)) {
30229 + if (user_mode(regs)) {
30230 local_irq_enable();
30231 error_code |= PF_USER;
30232 } else {
30233 @@ -1142,6 +1365,11 @@ retry:
30234 might_sleep();
30235 }
30236
30237 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30238 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30239 + return;
30240 +#endif
30241 +
30242 vma = find_vma(mm, address);
30243 if (unlikely(!vma)) {
30244 bad_area(regs, error_code, address);
30245 @@ -1153,18 +1381,24 @@ retry:
30246 bad_area(regs, error_code, address);
30247 return;
30248 }
30249 - if (error_code & PF_USER) {
30250 - /*
30251 - * Accessing the stack below %sp is always a bug.
30252 - * The large cushion allows instructions like enter
30253 - * and pusha to work. ("enter $65535, $31" pushes
30254 - * 32 pointers and then decrements %sp by 65535.)
30255 - */
30256 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30257 - bad_area(regs, error_code, address);
30258 - return;
30259 - }
30260 + /*
30261 + * Accessing the stack below %sp is always a bug.
30262 + * The large cushion allows instructions like enter
30263 + * and pusha to work. ("enter $65535, $31" pushes
30264 + * 32 pointers and then decrements %sp by 65535.)
30265 + */
30266 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30267 + bad_area(regs, error_code, address);
30268 + return;
30269 }
30270 +
30271 +#ifdef CONFIG_PAX_SEGMEXEC
30272 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30273 + bad_area(regs, error_code, address);
30274 + return;
30275 + }
30276 +#endif
30277 +
30278 if (unlikely(expand_stack(vma, address))) {
30279 bad_area(regs, error_code, address);
30280 return;
30281 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30282 __do_page_fault(regs, error_code);
30283 exception_exit(prev_state);
30284 }
30285 +
30286 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30287 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30288 +{
30289 + struct mm_struct *mm = current->mm;
30290 + unsigned long ip = regs->ip;
30291 +
30292 + if (v8086_mode(regs))
30293 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30294 +
30295 +#ifdef CONFIG_PAX_PAGEEXEC
30296 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30297 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30298 + return true;
30299 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30300 + return true;
30301 + return false;
30302 + }
30303 +#endif
30304 +
30305 +#ifdef CONFIG_PAX_SEGMEXEC
30306 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30307 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30308 + return true;
30309 + return false;
30310 + }
30311 +#endif
30312 +
30313 + return false;
30314 +}
30315 +#endif
30316 +
30317 +#ifdef CONFIG_PAX_EMUTRAMP
30318 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30319 +{
30320 + int err;
30321 +
30322 + do { /* PaX: libffi trampoline emulation */
30323 + unsigned char mov, jmp;
30324 + unsigned int addr1, addr2;
30325 +
30326 +#ifdef CONFIG_X86_64
30327 + if ((regs->ip + 9) >> 32)
30328 + break;
30329 +#endif
30330 +
30331 + err = get_user(mov, (unsigned char __user *)regs->ip);
30332 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30333 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30334 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30335 +
30336 + if (err)
30337 + break;
30338 +
30339 + if (mov == 0xB8 && jmp == 0xE9) {
30340 + regs->ax = addr1;
30341 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30342 + return 2;
30343 + }
30344 + } while (0);
30345 +
30346 + do { /* PaX: gcc trampoline emulation #1 */
30347 + unsigned char mov1, mov2;
30348 + unsigned short jmp;
30349 + unsigned int addr1, addr2;
30350 +
30351 +#ifdef CONFIG_X86_64
30352 + if ((regs->ip + 11) >> 32)
30353 + break;
30354 +#endif
30355 +
30356 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30357 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30358 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30359 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30360 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30361 +
30362 + if (err)
30363 + break;
30364 +
30365 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30366 + regs->cx = addr1;
30367 + regs->ax = addr2;
30368 + regs->ip = addr2;
30369 + return 2;
30370 + }
30371 + } while (0);
30372 +
30373 + do { /* PaX: gcc trampoline emulation #2 */
30374 + unsigned char mov, jmp;
30375 + unsigned int addr1, addr2;
30376 +
30377 +#ifdef CONFIG_X86_64
30378 + if ((regs->ip + 9) >> 32)
30379 + break;
30380 +#endif
30381 +
30382 + err = get_user(mov, (unsigned char __user *)regs->ip);
30383 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30384 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30385 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30386 +
30387 + if (err)
30388 + break;
30389 +
30390 + if (mov == 0xB9 && jmp == 0xE9) {
30391 + regs->cx = addr1;
30392 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30393 + return 2;
30394 + }
30395 + } while (0);
30396 +
30397 + return 1; /* PaX in action */
30398 +}
30399 +
30400 +#ifdef CONFIG_X86_64
30401 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30402 +{
30403 + int err;
30404 +
30405 + do { /* PaX: libffi trampoline emulation */
30406 + unsigned short mov1, mov2, jmp1;
30407 + unsigned char stcclc, jmp2;
30408 + unsigned long addr1, addr2;
30409 +
30410 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30411 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30412 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30413 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30414 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30415 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30416 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30417 +
30418 + if (err)
30419 + break;
30420 +
30421 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30422 + regs->r11 = addr1;
30423 + regs->r10 = addr2;
30424 + if (stcclc == 0xF8)
30425 + regs->flags &= ~X86_EFLAGS_CF;
30426 + else
30427 + regs->flags |= X86_EFLAGS_CF;
30428 + regs->ip = addr1;
30429 + return 2;
30430 + }
30431 + } while (0);
30432 +
30433 + do { /* PaX: gcc trampoline emulation #1 */
30434 + unsigned short mov1, mov2, jmp1;
30435 + unsigned char jmp2;
30436 + unsigned int addr1;
30437 + unsigned long addr2;
30438 +
30439 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30440 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30441 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30442 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30443 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30444 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30445 +
30446 + if (err)
30447 + break;
30448 +
30449 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30450 + regs->r11 = addr1;
30451 + regs->r10 = addr2;
30452 + regs->ip = addr1;
30453 + return 2;
30454 + }
30455 + } while (0);
30456 +
30457 + do { /* PaX: gcc trampoline emulation #2 */
30458 + unsigned short mov1, mov2, jmp1;
30459 + unsigned char jmp2;
30460 + unsigned long addr1, addr2;
30461 +
30462 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30463 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30464 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30465 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30466 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30467 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30468 +
30469 + if (err)
30470 + break;
30471 +
30472 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30473 + regs->r11 = addr1;
30474 + regs->r10 = addr2;
30475 + regs->ip = addr1;
30476 + return 2;
30477 + }
30478 + } while (0);
30479 +
30480 + return 1; /* PaX in action */
30481 +}
30482 +#endif
30483 +
30484 +/*
30485 + * PaX: decide what to do with offenders (regs->ip = fault address)
30486 + *
30487 + * returns 1 when task should be killed
30488 + * 2 when gcc trampoline was detected
30489 + */
30490 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30491 +{
30492 + if (v8086_mode(regs))
30493 + return 1;
30494 +
30495 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30496 + return 1;
30497 +
30498 +#ifdef CONFIG_X86_32
30499 + return pax_handle_fetch_fault_32(regs);
30500 +#else
30501 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30502 + return pax_handle_fetch_fault_32(regs);
30503 + else
30504 + return pax_handle_fetch_fault_64(regs);
30505 +#endif
30506 +}
30507 +#endif
30508 +
30509 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30510 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30511 +{
30512 + long i;
30513 +
30514 + printk(KERN_ERR "PAX: bytes at PC: ");
30515 + for (i = 0; i < 20; i++) {
30516 + unsigned char c;
30517 + if (get_user(c, (unsigned char __force_user *)pc+i))
30518 + printk(KERN_CONT "?? ");
30519 + else
30520 + printk(KERN_CONT "%02x ", c);
30521 + }
30522 + printk("\n");
30523 +
30524 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30525 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30526 + unsigned long c;
30527 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30528 +#ifdef CONFIG_X86_32
30529 + printk(KERN_CONT "???????? ");
30530 +#else
30531 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30532 + printk(KERN_CONT "???????? ???????? ");
30533 + else
30534 + printk(KERN_CONT "???????????????? ");
30535 +#endif
30536 + } else {
30537 +#ifdef CONFIG_X86_64
30538 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30539 + printk(KERN_CONT "%08x ", (unsigned int)c);
30540 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30541 + } else
30542 +#endif
30543 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30544 + }
30545 + }
30546 + printk("\n");
30547 +}
30548 +#endif
30549 +
30550 +/**
30551 + * probe_kernel_write(): safely attempt to write to a location
30552 + * @dst: address to write to
30553 + * @src: pointer to the data that shall be written
30554 + * @size: size of the data chunk
30555 + *
30556 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30557 + * happens, handle that and return -EFAULT.
30558 + */
30559 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30560 +{
30561 + long ret;
30562 + mm_segment_t old_fs = get_fs();
30563 +
30564 + set_fs(KERNEL_DS);
30565 + pagefault_disable();
30566 + pax_open_kernel();
30567 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30568 + pax_close_kernel();
30569 + pagefault_enable();
30570 + set_fs(old_fs);
30571 +
30572 + return ret ? -EFAULT : 0;
30573 +}
30574 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30575 index dd74e46..7d26398 100644
30576 --- a/arch/x86/mm/gup.c
30577 +++ b/arch/x86/mm/gup.c
30578 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30579 addr = start;
30580 len = (unsigned long) nr_pages << PAGE_SHIFT;
30581 end = start + len;
30582 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30583 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30584 (void __user *)start, len)))
30585 return 0;
30586
30587 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30588 index 4500142..53a363c 100644
30589 --- a/arch/x86/mm/highmem_32.c
30590 +++ b/arch/x86/mm/highmem_32.c
30591 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30592 idx = type + KM_TYPE_NR*smp_processor_id();
30593 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30594 BUG_ON(!pte_none(*(kmap_pte-idx)));
30595 +
30596 + pax_open_kernel();
30597 set_pte(kmap_pte-idx, mk_pte(page, prot));
30598 + pax_close_kernel();
30599 +
30600 arch_flush_lazy_mmu_mode();
30601
30602 return (void *)vaddr;
30603 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30604 index 7e73e8c..11d3b86 100644
30605 --- a/arch/x86/mm/hugetlbpage.c
30606 +++ b/arch/x86/mm/hugetlbpage.c
30607 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30608 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30609 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30610 unsigned long addr, unsigned long len,
30611 - unsigned long pgoff, unsigned long flags)
30612 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30613 {
30614 struct hstate *h = hstate_file(file);
30615 struct vm_unmapped_area_info info;
30616 -
30617 +
30618 info.flags = 0;
30619 info.length = len;
30620 info.low_limit = TASK_UNMAPPED_BASE;
30621 +
30622 +#ifdef CONFIG_PAX_RANDMMAP
30623 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30624 + info.low_limit += current->mm->delta_mmap;
30625 +#endif
30626 +
30627 info.high_limit = TASK_SIZE;
30628 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30629 info.align_offset = 0;
30630 + info.threadstack_offset = offset;
30631 return vm_unmapped_area(&info);
30632 }
30633
30634 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30635 unsigned long addr0, unsigned long len,
30636 - unsigned long pgoff, unsigned long flags)
30637 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30638 {
30639 struct hstate *h = hstate_file(file);
30640 struct vm_unmapped_area_info info;
30641 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30642 info.high_limit = current->mm->mmap_base;
30643 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30644 info.align_offset = 0;
30645 + info.threadstack_offset = offset;
30646 addr = vm_unmapped_area(&info);
30647
30648 /*
30649 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30650 VM_BUG_ON(addr != -ENOMEM);
30651 info.flags = 0;
30652 info.low_limit = TASK_UNMAPPED_BASE;
30653 +
30654 +#ifdef CONFIG_PAX_RANDMMAP
30655 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30656 + info.low_limit += current->mm->delta_mmap;
30657 +#endif
30658 +
30659 info.high_limit = TASK_SIZE;
30660 addr = vm_unmapped_area(&info);
30661 }
30662 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30663 struct hstate *h = hstate_file(file);
30664 struct mm_struct *mm = current->mm;
30665 struct vm_area_struct *vma;
30666 + unsigned long pax_task_size = TASK_SIZE;
30667 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30668
30669 if (len & ~huge_page_mask(h))
30670 return -EINVAL;
30671 - if (len > TASK_SIZE)
30672 +
30673 +#ifdef CONFIG_PAX_SEGMEXEC
30674 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30675 + pax_task_size = SEGMEXEC_TASK_SIZE;
30676 +#endif
30677 +
30678 + pax_task_size -= PAGE_SIZE;
30679 +
30680 + if (len > pax_task_size)
30681 return -ENOMEM;
30682
30683 if (flags & MAP_FIXED) {
30684 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30685 return addr;
30686 }
30687
30688 +#ifdef CONFIG_PAX_RANDMMAP
30689 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30690 +#endif
30691 +
30692 if (addr) {
30693 addr = ALIGN(addr, huge_page_size(h));
30694 vma = find_vma(mm, addr);
30695 - if (TASK_SIZE - len >= addr &&
30696 - (!vma || addr + len <= vma->vm_start))
30697 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30698 return addr;
30699 }
30700 if (mm->get_unmapped_area == arch_get_unmapped_area)
30701 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30702 - pgoff, flags);
30703 + pgoff, flags, offset);
30704 else
30705 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30706 - pgoff, flags);
30707 + pgoff, flags, offset);
30708 }
30709
30710 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30711 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30712 index 04664cd..dae6e5d 100644
30713 --- a/arch/x86/mm/init.c
30714 +++ b/arch/x86/mm/init.c
30715 @@ -4,6 +4,7 @@
30716 #include <linux/swap.h>
30717 #include <linux/memblock.h>
30718 #include <linux/bootmem.h> /* for max_low_pfn */
30719 +#include <linux/tboot.h>
30720
30721 #include <asm/cacheflush.h>
30722 #include <asm/e820.h>
30723 @@ -17,6 +18,8 @@
30724 #include <asm/proto.h>
30725 #include <asm/dma.h> /* for MAX_DMA_PFN */
30726 #include <asm/microcode.h>
30727 +#include <asm/desc.h>
30728 +#include <asm/bios_ebda.h>
30729
30730 #include "mm_internal.h"
30731
30732 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30733 early_ioremap_page_table_range_init();
30734 #endif
30735
30736 +#ifdef CONFIG_PAX_PER_CPU_PGD
30737 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30738 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30739 + KERNEL_PGD_PTRS);
30740 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30741 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30742 + KERNEL_PGD_PTRS);
30743 + load_cr3(get_cpu_pgd(0, kernel));
30744 +#else
30745 load_cr3(swapper_pg_dir);
30746 +#endif
30747 +
30748 __flush_tlb_all();
30749
30750 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30751 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30752 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30753 * mmio resources as well as potential bios/acpi data regions.
30754 */
30755 +
30756 +#ifdef CONFIG_GRKERNSEC_KMEM
30757 +static unsigned int ebda_start __read_only;
30758 +static unsigned int ebda_end __read_only;
30759 +#endif
30760 +
30761 int devmem_is_allowed(unsigned long pagenr)
30762 {
30763 - if (pagenr < 256)
30764 +#ifdef CONFIG_GRKERNSEC_KMEM
30765 + /* allow BDA */
30766 + if (!pagenr)
30767 return 1;
30768 + /* allow EBDA */
30769 + if (pagenr >= ebda_start && pagenr < ebda_end)
30770 + return 1;
30771 + /* if tboot is in use, allow access to its hardcoded serial log range */
30772 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30773 + return 1;
30774 +#else
30775 + if (!pagenr)
30776 + return 1;
30777 +#ifdef CONFIG_VM86
30778 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30779 + return 1;
30780 +#endif
30781 +#endif
30782 +
30783 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30784 + return 1;
30785 +#ifdef CONFIG_GRKERNSEC_KMEM
30786 + /* throw out everything else below 1MB */
30787 + if (pagenr <= 256)
30788 + return 0;
30789 +#endif
30790 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30791 return 0;
30792 if (!page_is_ram(pagenr))
30793 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30794 #endif
30795 }
30796
30797 +#ifdef CONFIG_GRKERNSEC_KMEM
30798 +static inline void gr_init_ebda(void)
30799 +{
30800 + unsigned int ebda_addr;
30801 + unsigned int ebda_size = 0;
30802 +
30803 + ebda_addr = get_bios_ebda();
30804 + if (ebda_addr) {
30805 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30806 + ebda_size <<= 10;
30807 + }
30808 + if (ebda_addr && ebda_size) {
30809 + ebda_start = ebda_addr >> PAGE_SHIFT;
30810 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30811 + } else {
30812 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30813 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30814 + }
30815 +}
30816 +#else
30817 +static inline void gr_init_ebda(void) { }
30818 +#endif
30819 +
30820 void free_initmem(void)
30821 {
30822 +#ifdef CONFIG_PAX_KERNEXEC
30823 +#ifdef CONFIG_X86_32
30824 + /* PaX: limit KERNEL_CS to actual size */
30825 + unsigned long addr, limit;
30826 + struct desc_struct d;
30827 + int cpu;
30828 +#else
30829 + pgd_t *pgd;
30830 + pud_t *pud;
30831 + pmd_t *pmd;
30832 + unsigned long addr, end;
30833 +#endif
30834 +#endif
30835 +
30836 + gr_init_ebda();
30837 +
30838 +#ifdef CONFIG_PAX_KERNEXEC
30839 +#ifdef CONFIG_X86_32
30840 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30841 + limit = (limit - 1UL) >> PAGE_SHIFT;
30842 +
30843 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30844 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30845 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30846 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30847 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30848 + }
30849 +
30850 + /* PaX: make KERNEL_CS read-only */
30851 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30852 + if (!paravirt_enabled())
30853 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30854 +/*
30855 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30856 + pgd = pgd_offset_k(addr);
30857 + pud = pud_offset(pgd, addr);
30858 + pmd = pmd_offset(pud, addr);
30859 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30860 + }
30861 +*/
30862 +#ifdef CONFIG_X86_PAE
30863 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30864 +/*
30865 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30866 + pgd = pgd_offset_k(addr);
30867 + pud = pud_offset(pgd, addr);
30868 + pmd = pmd_offset(pud, addr);
30869 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30870 + }
30871 +*/
30872 +#endif
30873 +
30874 +#ifdef CONFIG_MODULES
30875 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30876 +#endif
30877 +
30878 +#else
30879 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30880 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30881 + pgd = pgd_offset_k(addr);
30882 + pud = pud_offset(pgd, addr);
30883 + pmd = pmd_offset(pud, addr);
30884 + if (!pmd_present(*pmd))
30885 + continue;
30886 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30887 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30888 + else
30889 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30890 + }
30891 +
30892 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30893 + end = addr + KERNEL_IMAGE_SIZE;
30894 + for (; addr < end; addr += PMD_SIZE) {
30895 + pgd = pgd_offset_k(addr);
30896 + pud = pud_offset(pgd, addr);
30897 + pmd = pmd_offset(pud, addr);
30898 + if (!pmd_present(*pmd))
30899 + continue;
30900 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30901 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30902 + }
30903 +#endif
30904 +
30905 + flush_tlb_all();
30906 +#endif
30907 +
30908 free_init_pages("unused kernel",
30909 (unsigned long)(&__init_begin),
30910 (unsigned long)(&__init_end));
30911 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30912 index 4287f1f..3b99c71 100644
30913 --- a/arch/x86/mm/init_32.c
30914 +++ b/arch/x86/mm/init_32.c
30915 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30916 bool __read_mostly __vmalloc_start_set = false;
30917
30918 /*
30919 - * Creates a middle page table and puts a pointer to it in the
30920 - * given global directory entry. This only returns the gd entry
30921 - * in non-PAE compilation mode, since the middle layer is folded.
30922 - */
30923 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30924 -{
30925 - pud_t *pud;
30926 - pmd_t *pmd_table;
30927 -
30928 -#ifdef CONFIG_X86_PAE
30929 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30930 - pmd_table = (pmd_t *)alloc_low_page();
30931 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30932 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30933 - pud = pud_offset(pgd, 0);
30934 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30935 -
30936 - return pmd_table;
30937 - }
30938 -#endif
30939 - pud = pud_offset(pgd, 0);
30940 - pmd_table = pmd_offset(pud, 0);
30941 -
30942 - return pmd_table;
30943 -}
30944 -
30945 -/*
30946 * Create a page table and place a pointer to it in a middle page
30947 * directory entry:
30948 */
30949 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30950 pte_t *page_table = (pte_t *)alloc_low_page();
30951
30952 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30953 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30954 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30955 +#else
30956 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30957 +#endif
30958 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30959 }
30960
30961 return pte_offset_kernel(pmd, 0);
30962 }
30963
30964 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30965 +{
30966 + pud_t *pud;
30967 + pmd_t *pmd_table;
30968 +
30969 + pud = pud_offset(pgd, 0);
30970 + pmd_table = pmd_offset(pud, 0);
30971 +
30972 + return pmd_table;
30973 +}
30974 +
30975 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
30976 {
30977 int pgd_idx = pgd_index(vaddr);
30978 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
30979 int pgd_idx, pmd_idx;
30980 unsigned long vaddr;
30981 pgd_t *pgd;
30982 + pud_t *pud;
30983 pmd_t *pmd;
30984 pte_t *pte = NULL;
30985 unsigned long count = page_table_range_init_count(start, end);
30986 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
30987 pgd = pgd_base + pgd_idx;
30988
30989 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
30990 - pmd = one_md_table_init(pgd);
30991 - pmd = pmd + pmd_index(vaddr);
30992 + pud = pud_offset(pgd, vaddr);
30993 + pmd = pmd_offset(pud, vaddr);
30994 +
30995 +#ifdef CONFIG_X86_PAE
30996 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
30997 +#endif
30998 +
30999 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31000 pmd++, pmd_idx++) {
31001 pte = page_table_kmap_check(one_page_table_init(pmd),
31002 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31003 }
31004 }
31005
31006 -static inline int is_kernel_text(unsigned long addr)
31007 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31008 {
31009 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31010 - return 1;
31011 - return 0;
31012 + if ((start > ktla_ktva((unsigned long)_etext) ||
31013 + end <= ktla_ktva((unsigned long)_stext)) &&
31014 + (start > ktla_ktva((unsigned long)_einittext) ||
31015 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31016 +
31017 +#ifdef CONFIG_ACPI_SLEEP
31018 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31019 +#endif
31020 +
31021 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31022 + return 0;
31023 + return 1;
31024 }
31025
31026 /*
31027 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31028 unsigned long last_map_addr = end;
31029 unsigned long start_pfn, end_pfn;
31030 pgd_t *pgd_base = swapper_pg_dir;
31031 - int pgd_idx, pmd_idx, pte_ofs;
31032 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31033 unsigned long pfn;
31034 pgd_t *pgd;
31035 + pud_t *pud;
31036 pmd_t *pmd;
31037 pte_t *pte;
31038 unsigned pages_2m, pages_4k;
31039 @@ -291,8 +295,13 @@ repeat:
31040 pfn = start_pfn;
31041 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31042 pgd = pgd_base + pgd_idx;
31043 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31044 - pmd = one_md_table_init(pgd);
31045 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31046 + pud = pud_offset(pgd, 0);
31047 + pmd = pmd_offset(pud, 0);
31048 +
31049 +#ifdef CONFIG_X86_PAE
31050 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31051 +#endif
31052
31053 if (pfn >= end_pfn)
31054 continue;
31055 @@ -304,14 +313,13 @@ repeat:
31056 #endif
31057 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31058 pmd++, pmd_idx++) {
31059 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31060 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31061
31062 /*
31063 * Map with big pages if possible, otherwise
31064 * create normal page tables:
31065 */
31066 if (use_pse) {
31067 - unsigned int addr2;
31068 pgprot_t prot = PAGE_KERNEL_LARGE;
31069 /*
31070 * first pass will use the same initial
31071 @@ -322,11 +330,7 @@ repeat:
31072 _PAGE_PSE);
31073
31074 pfn &= PMD_MASK >> PAGE_SHIFT;
31075 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31076 - PAGE_OFFSET + PAGE_SIZE-1;
31077 -
31078 - if (is_kernel_text(addr) ||
31079 - is_kernel_text(addr2))
31080 + if (is_kernel_text(address, address + PMD_SIZE))
31081 prot = PAGE_KERNEL_LARGE_EXEC;
31082
31083 pages_2m++;
31084 @@ -343,7 +347,7 @@ repeat:
31085 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31086 pte += pte_ofs;
31087 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31088 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31089 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31090 pgprot_t prot = PAGE_KERNEL;
31091 /*
31092 * first pass will use the same initial
31093 @@ -351,7 +355,7 @@ repeat:
31094 */
31095 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31096
31097 - if (is_kernel_text(addr))
31098 + if (is_kernel_text(address, address + PAGE_SIZE))
31099 prot = PAGE_KERNEL_EXEC;
31100
31101 pages_4k++;
31102 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31103
31104 pud = pud_offset(pgd, va);
31105 pmd = pmd_offset(pud, va);
31106 - if (!pmd_present(*pmd))
31107 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31108 break;
31109
31110 /* should not be large page here */
31111 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31112
31113 static void __init pagetable_init(void)
31114 {
31115 - pgd_t *pgd_base = swapper_pg_dir;
31116 -
31117 - permanent_kmaps_init(pgd_base);
31118 + permanent_kmaps_init(swapper_pg_dir);
31119 }
31120
31121 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31122 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31123 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31124
31125 /* user-defined highmem size */
31126 @@ -787,10 +789,10 @@ void __init mem_init(void)
31127 ((unsigned long)&__init_end -
31128 (unsigned long)&__init_begin) >> 10,
31129
31130 - (unsigned long)&_etext, (unsigned long)&_edata,
31131 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31132 + (unsigned long)&_sdata, (unsigned long)&_edata,
31133 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31134
31135 - (unsigned long)&_text, (unsigned long)&_etext,
31136 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31137 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31138
31139 /*
31140 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31141 if (!kernel_set_to_readonly)
31142 return;
31143
31144 + start = ktla_ktva(start);
31145 pr_debug("Set kernel text: %lx - %lx for read write\n",
31146 start, start+size);
31147
31148 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31149 if (!kernel_set_to_readonly)
31150 return;
31151
31152 + start = ktla_ktva(start);
31153 pr_debug("Set kernel text: %lx - %lx for read only\n",
31154 start, start+size);
31155
31156 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31157 unsigned long start = PFN_ALIGN(_text);
31158 unsigned long size = PFN_ALIGN(_etext) - start;
31159
31160 + start = ktla_ktva(start);
31161 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31162 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31163 size >> 10);
31164 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31165 index 104d56a..62ba13f 100644
31166 --- a/arch/x86/mm/init_64.c
31167 +++ b/arch/x86/mm/init_64.c
31168 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31169 * around without checking the pgd every time.
31170 */
31171
31172 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31173 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31174 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31175
31176 int force_personality32;
31177 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31178
31179 for (address = start; address <= end; address += PGDIR_SIZE) {
31180 const pgd_t *pgd_ref = pgd_offset_k(address);
31181 +
31182 +#ifdef CONFIG_PAX_PER_CPU_PGD
31183 + unsigned long cpu;
31184 +#else
31185 struct page *page;
31186 +#endif
31187
31188 if (pgd_none(*pgd_ref))
31189 continue;
31190
31191 spin_lock(&pgd_lock);
31192 +
31193 +#ifdef CONFIG_PAX_PER_CPU_PGD
31194 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31195 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31196 +
31197 + if (pgd_none(*pgd))
31198 + set_pgd(pgd, *pgd_ref);
31199 + else
31200 + BUG_ON(pgd_page_vaddr(*pgd)
31201 + != pgd_page_vaddr(*pgd_ref));
31202 + pgd = pgd_offset_cpu(cpu, kernel, address);
31203 +#else
31204 list_for_each_entry(page, &pgd_list, lru) {
31205 pgd_t *pgd;
31206 spinlock_t *pgt_lock;
31207 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31208 /* the pgt_lock only for Xen */
31209 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31210 spin_lock(pgt_lock);
31211 +#endif
31212
31213 if (pgd_none(*pgd))
31214 set_pgd(pgd, *pgd_ref);
31215 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31216 BUG_ON(pgd_page_vaddr(*pgd)
31217 != pgd_page_vaddr(*pgd_ref));
31218
31219 +#ifndef CONFIG_PAX_PER_CPU_PGD
31220 spin_unlock(pgt_lock);
31221 +#endif
31222 +
31223 }
31224 spin_unlock(&pgd_lock);
31225 }
31226 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31227 {
31228 if (pgd_none(*pgd)) {
31229 pud_t *pud = (pud_t *)spp_getpage();
31230 - pgd_populate(&init_mm, pgd, pud);
31231 + pgd_populate_kernel(&init_mm, pgd, pud);
31232 if (pud != pud_offset(pgd, 0))
31233 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31234 pud, pud_offset(pgd, 0));
31235 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31236 {
31237 if (pud_none(*pud)) {
31238 pmd_t *pmd = (pmd_t *) spp_getpage();
31239 - pud_populate(&init_mm, pud, pmd);
31240 + pud_populate_kernel(&init_mm, pud, pmd);
31241 if (pmd != pmd_offset(pud, 0))
31242 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31243 pmd, pmd_offset(pud, 0));
31244 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31245 pmd = fill_pmd(pud, vaddr);
31246 pte = fill_pte(pmd, vaddr);
31247
31248 + pax_open_kernel();
31249 set_pte(pte, new_pte);
31250 + pax_close_kernel();
31251
31252 /*
31253 * It's enough to flush this one mapping.
31254 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31255 pgd = pgd_offset_k((unsigned long)__va(phys));
31256 if (pgd_none(*pgd)) {
31257 pud = (pud_t *) spp_getpage();
31258 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31259 - _PAGE_USER));
31260 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31261 }
31262 pud = pud_offset(pgd, (unsigned long)__va(phys));
31263 if (pud_none(*pud)) {
31264 pmd = (pmd_t *) spp_getpage();
31265 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31266 - _PAGE_USER));
31267 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31268 }
31269 pmd = pmd_offset(pud, phys);
31270 BUG_ON(!pmd_none(*pmd));
31271 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31272 prot);
31273
31274 spin_lock(&init_mm.page_table_lock);
31275 - pud_populate(&init_mm, pud, pmd);
31276 + pud_populate_kernel(&init_mm, pud, pmd);
31277 spin_unlock(&init_mm.page_table_lock);
31278 }
31279 __flush_tlb_all();
31280 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31281 page_size_mask);
31282
31283 spin_lock(&init_mm.page_table_lock);
31284 - pgd_populate(&init_mm, pgd, pud);
31285 + pgd_populate_kernel(&init_mm, pgd, pud);
31286 spin_unlock(&init_mm.page_table_lock);
31287 pgd_changed = true;
31288 }
31289 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31290 static struct vm_area_struct gate_vma = {
31291 .vm_start = VSYSCALL_START,
31292 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31293 - .vm_page_prot = PAGE_READONLY_EXEC,
31294 - .vm_flags = VM_READ | VM_EXEC
31295 + .vm_page_prot = PAGE_READONLY,
31296 + .vm_flags = VM_READ
31297 };
31298
31299 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31300 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31301
31302 const char *arch_vma_name(struct vm_area_struct *vma)
31303 {
31304 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31305 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31306 return "[vdso]";
31307 if (vma == &gate_vma)
31308 return "[vsyscall]";
31309 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31310 index 7b179b4..6bd17777 100644
31311 --- a/arch/x86/mm/iomap_32.c
31312 +++ b/arch/x86/mm/iomap_32.c
31313 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31314 type = kmap_atomic_idx_push();
31315 idx = type + KM_TYPE_NR * smp_processor_id();
31316 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31317 +
31318 + pax_open_kernel();
31319 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31320 + pax_close_kernel();
31321 +
31322 arch_flush_lazy_mmu_mode();
31323
31324 return (void *)vaddr;
31325 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31326 index 0215e2c..1c62dab 100644
31327 --- a/arch/x86/mm/ioremap.c
31328 +++ b/arch/x86/mm/ioremap.c
31329 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31330 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31331 int is_ram = page_is_ram(pfn);
31332
31333 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31334 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31335 return NULL;
31336 WARN_ON_ONCE(is_ram);
31337 }
31338 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31339 *
31340 * Caller must ensure there is only one unmapping for the same pointer.
31341 */
31342 -void iounmap(volatile void __iomem *addr)
31343 +void iounmap(const volatile void __iomem *addr)
31344 {
31345 struct vm_struct *p, *o;
31346
31347 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31348
31349 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31350 if (page_is_ram(start >> PAGE_SHIFT))
31351 +#ifdef CONFIG_HIGHMEM
31352 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31353 +#endif
31354 return __va(phys);
31355
31356 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31357 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31358 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31359 {
31360 if (page_is_ram(phys >> PAGE_SHIFT))
31361 +#ifdef CONFIG_HIGHMEM
31362 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31363 +#endif
31364 return;
31365
31366 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31367 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31368 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31369
31370 static __initdata int after_paging_init;
31371 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31372 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31373
31374 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31375 {
31376 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31377 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31378
31379 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31380 - memset(bm_pte, 0, sizeof(bm_pte));
31381 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31382 + pmd_populate_user(&init_mm, pmd, bm_pte);
31383
31384 /*
31385 * The boot-ioremap range spans multiple pmds, for which
31386 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31387 index d87dd6d..bf3fa66 100644
31388 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31389 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31390 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31391 * memory (e.g. tracked pages)? For now, we need this to avoid
31392 * invoking kmemcheck for PnP BIOS calls.
31393 */
31394 - if (regs->flags & X86_VM_MASK)
31395 + if (v8086_mode(regs))
31396 return false;
31397 - if (regs->cs != __KERNEL_CS)
31398 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31399 return false;
31400
31401 pte = kmemcheck_pte_lookup(address);
31402 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31403 index 25e7e13..1964579 100644
31404 --- a/arch/x86/mm/mmap.c
31405 +++ b/arch/x86/mm/mmap.c
31406 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31407 * Leave an at least ~128 MB hole with possible stack randomization.
31408 */
31409 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31410 -#define MAX_GAP (TASK_SIZE/6*5)
31411 +#define MAX_GAP (pax_task_size/6*5)
31412
31413 static int mmap_is_legacy(void)
31414 {
31415 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31416 return rnd << PAGE_SHIFT;
31417 }
31418
31419 -static unsigned long mmap_base(void)
31420 +static unsigned long mmap_base(struct mm_struct *mm)
31421 {
31422 unsigned long gap = rlimit(RLIMIT_STACK);
31423 + unsigned long pax_task_size = TASK_SIZE;
31424 +
31425 +#ifdef CONFIG_PAX_SEGMEXEC
31426 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31427 + pax_task_size = SEGMEXEC_TASK_SIZE;
31428 +#endif
31429
31430 if (gap < MIN_GAP)
31431 gap = MIN_GAP;
31432 else if (gap > MAX_GAP)
31433 gap = MAX_GAP;
31434
31435 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31436 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31437 }
31438
31439 /*
31440 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31441 * does, but not when emulating X86_32
31442 */
31443 -static unsigned long mmap_legacy_base(void)
31444 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31445 {
31446 - if (mmap_is_ia32())
31447 + if (mmap_is_ia32()) {
31448 +
31449 +#ifdef CONFIG_PAX_SEGMEXEC
31450 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31451 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31452 + else
31453 +#endif
31454 +
31455 return TASK_UNMAPPED_BASE;
31456 - else
31457 + } else
31458 return TASK_UNMAPPED_BASE + mmap_rnd();
31459 }
31460
31461 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31462 */
31463 void arch_pick_mmap_layout(struct mm_struct *mm)
31464 {
31465 - mm->mmap_legacy_base = mmap_legacy_base();
31466 - mm->mmap_base = mmap_base();
31467 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31468 + mm->mmap_base = mmap_base(mm);
31469 +
31470 +#ifdef CONFIG_PAX_RANDMMAP
31471 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31472 + mm->mmap_legacy_base += mm->delta_mmap;
31473 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31474 + }
31475 +#endif
31476
31477 if (mmap_is_legacy()) {
31478 mm->mmap_base = mm->mmap_legacy_base;
31479 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31480 index 0057a7a..95c7edd 100644
31481 --- a/arch/x86/mm/mmio-mod.c
31482 +++ b/arch/x86/mm/mmio-mod.c
31483 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31484 break;
31485 default:
31486 {
31487 - unsigned char *ip = (unsigned char *)instptr;
31488 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31489 my_trace->opcode = MMIO_UNKNOWN_OP;
31490 my_trace->width = 0;
31491 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31492 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31493 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31494 void __iomem *addr)
31495 {
31496 - static atomic_t next_id;
31497 + static atomic_unchecked_t next_id;
31498 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31499 /* These are page-unaligned. */
31500 struct mmiotrace_map map = {
31501 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31502 .private = trace
31503 },
31504 .phys = offset,
31505 - .id = atomic_inc_return(&next_id)
31506 + .id = atomic_inc_return_unchecked(&next_id)
31507 };
31508 map.map_id = trace->id;
31509
31510 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31511 ioremap_trace_core(offset, size, addr);
31512 }
31513
31514 -static void iounmap_trace_core(volatile void __iomem *addr)
31515 +static void iounmap_trace_core(const volatile void __iomem *addr)
31516 {
31517 struct mmiotrace_map map = {
31518 .phys = 0,
31519 @@ -328,7 +328,7 @@ not_enabled:
31520 }
31521 }
31522
31523 -void mmiotrace_iounmap(volatile void __iomem *addr)
31524 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31525 {
31526 might_sleep();
31527 if (is_enabled()) /* recheck and proper locking in *_core() */
31528 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31529 index 8bf93ba..dbcd670 100644
31530 --- a/arch/x86/mm/numa.c
31531 +++ b/arch/x86/mm/numa.c
31532 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31533 return true;
31534 }
31535
31536 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31537 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31538 {
31539 unsigned long uninitialized_var(pfn_align);
31540 int i, nid;
31541 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31542 index d0b1773..4c3327c 100644
31543 --- a/arch/x86/mm/pageattr-test.c
31544 +++ b/arch/x86/mm/pageattr-test.c
31545 @@ -36,7 +36,7 @@ enum {
31546
31547 static int pte_testbit(pte_t pte)
31548 {
31549 - return pte_flags(pte) & _PAGE_UNUSED1;
31550 + return pte_flags(pte) & _PAGE_CPA_TEST;
31551 }
31552
31553 struct split_state {
31554 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31555 index bb32480..75f2f5e 100644
31556 --- a/arch/x86/mm/pageattr.c
31557 +++ b/arch/x86/mm/pageattr.c
31558 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31559 */
31560 #ifdef CONFIG_PCI_BIOS
31561 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31562 - pgprot_val(forbidden) |= _PAGE_NX;
31563 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31564 #endif
31565
31566 /*
31567 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31568 * Does not cover __inittext since that is gone later on. On
31569 * 64bit we do not enforce !NX on the low mapping
31570 */
31571 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31572 - pgprot_val(forbidden) |= _PAGE_NX;
31573 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31574 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31575
31576 +#ifdef CONFIG_DEBUG_RODATA
31577 /*
31578 * The .rodata section needs to be read-only. Using the pfn
31579 * catches all aliases.
31580 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31581 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31582 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31583 pgprot_val(forbidden) |= _PAGE_RW;
31584 +#endif
31585
31586 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31587 /*
31588 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31589 }
31590 #endif
31591
31592 +#ifdef CONFIG_PAX_KERNEXEC
31593 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31594 + pgprot_val(forbidden) |= _PAGE_RW;
31595 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31596 + }
31597 +#endif
31598 +
31599 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31600
31601 return prot;
31602 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31603 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31604 {
31605 /* change init_mm */
31606 + pax_open_kernel();
31607 set_pte_atomic(kpte, pte);
31608 +
31609 #ifdef CONFIG_X86_32
31610 if (!SHARED_KERNEL_PMD) {
31611 +
31612 +#ifdef CONFIG_PAX_PER_CPU_PGD
31613 + unsigned long cpu;
31614 +#else
31615 struct page *page;
31616 +#endif
31617
31618 +#ifdef CONFIG_PAX_PER_CPU_PGD
31619 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31620 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31621 +#else
31622 list_for_each_entry(page, &pgd_list, lru) {
31623 - pgd_t *pgd;
31624 + pgd_t *pgd = (pgd_t *)page_address(page);
31625 +#endif
31626 +
31627 pud_t *pud;
31628 pmd_t *pmd;
31629
31630 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31631 + pgd += pgd_index(address);
31632 pud = pud_offset(pgd, address);
31633 pmd = pmd_offset(pud, address);
31634 set_pte_atomic((pte_t *)pmd, pte);
31635 }
31636 }
31637 #endif
31638 + pax_close_kernel();
31639 }
31640
31641 static int
31642 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31643 index 6574388..87e9bef 100644
31644 --- a/arch/x86/mm/pat.c
31645 +++ b/arch/x86/mm/pat.c
31646 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31647
31648 if (!entry) {
31649 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31650 - current->comm, current->pid, start, end - 1);
31651 + current->comm, task_pid_nr(current), start, end - 1);
31652 return -EINVAL;
31653 }
31654
31655 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31656
31657 while (cursor < to) {
31658 if (!devmem_is_allowed(pfn)) {
31659 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31660 - current->comm, from, to - 1);
31661 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31662 + current->comm, from, to - 1, cursor);
31663 return 0;
31664 }
31665 cursor += PAGE_SIZE;
31666 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31667 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31668 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31669 "for [mem %#010Lx-%#010Lx]\n",
31670 - current->comm, current->pid,
31671 + current->comm, task_pid_nr(current),
31672 cattr_name(flags),
31673 base, (unsigned long long)(base + size-1));
31674 return -EINVAL;
31675 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31676 flags = lookup_memtype(paddr);
31677 if (want_flags != flags) {
31678 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31679 - current->comm, current->pid,
31680 + current->comm, task_pid_nr(current),
31681 cattr_name(want_flags),
31682 (unsigned long long)paddr,
31683 (unsigned long long)(paddr + size - 1),
31684 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31685 free_memtype(paddr, paddr + size);
31686 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31687 " for [mem %#010Lx-%#010Lx], got %s\n",
31688 - current->comm, current->pid,
31689 + current->comm, task_pid_nr(current),
31690 cattr_name(want_flags),
31691 (unsigned long long)paddr,
31692 (unsigned long long)(paddr + size - 1),
31693 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31694 index 415f6c4..d319983 100644
31695 --- a/arch/x86/mm/pat_rbtree.c
31696 +++ b/arch/x86/mm/pat_rbtree.c
31697 @@ -160,7 +160,7 @@ success:
31698
31699 failure:
31700 printk(KERN_INFO "%s:%d conflicting memory types "
31701 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31702 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31703 end, cattr_name(found_type), cattr_name(match->type));
31704 return -EBUSY;
31705 }
31706 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31707 index 9f0614d..92ae64a 100644
31708 --- a/arch/x86/mm/pf_in.c
31709 +++ b/arch/x86/mm/pf_in.c
31710 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31711 int i;
31712 enum reason_type rv = OTHERS;
31713
31714 - p = (unsigned char *)ins_addr;
31715 + p = (unsigned char *)ktla_ktva(ins_addr);
31716 p += skip_prefix(p, &prf);
31717 p += get_opcode(p, &opcode);
31718
31719 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31720 struct prefix_bits prf;
31721 int i;
31722
31723 - p = (unsigned char *)ins_addr;
31724 + p = (unsigned char *)ktla_ktva(ins_addr);
31725 p += skip_prefix(p, &prf);
31726 p += get_opcode(p, &opcode);
31727
31728 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31729 struct prefix_bits prf;
31730 int i;
31731
31732 - p = (unsigned char *)ins_addr;
31733 + p = (unsigned char *)ktla_ktva(ins_addr);
31734 p += skip_prefix(p, &prf);
31735 p += get_opcode(p, &opcode);
31736
31737 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31738 struct prefix_bits prf;
31739 int i;
31740
31741 - p = (unsigned char *)ins_addr;
31742 + p = (unsigned char *)ktla_ktva(ins_addr);
31743 p += skip_prefix(p, &prf);
31744 p += get_opcode(p, &opcode);
31745 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31746 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31747 struct prefix_bits prf;
31748 int i;
31749
31750 - p = (unsigned char *)ins_addr;
31751 + p = (unsigned char *)ktla_ktva(ins_addr);
31752 p += skip_prefix(p, &prf);
31753 p += get_opcode(p, &opcode);
31754 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31755 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31756 index dfa537a..fd45c64 100644
31757 --- a/arch/x86/mm/pgtable.c
31758 +++ b/arch/x86/mm/pgtable.c
31759 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31760 list_del(&page->lru);
31761 }
31762
31763 -#define UNSHARED_PTRS_PER_PGD \
31764 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31765 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31766 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31767
31768 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31769 +{
31770 + unsigned int count = USER_PGD_PTRS;
31771
31772 + if (!pax_user_shadow_base)
31773 + return;
31774 +
31775 + while (count--)
31776 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31777 +}
31778 +#endif
31779 +
31780 +#ifdef CONFIG_PAX_PER_CPU_PGD
31781 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31782 +{
31783 + unsigned int count = USER_PGD_PTRS;
31784 +
31785 + while (count--) {
31786 + pgd_t pgd;
31787 +
31788 +#ifdef CONFIG_X86_64
31789 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31790 +#else
31791 + pgd = *src++;
31792 +#endif
31793 +
31794 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31795 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31796 +#endif
31797 +
31798 + *dst++ = pgd;
31799 + }
31800 +
31801 +}
31802 +#endif
31803 +
31804 +#ifdef CONFIG_X86_64
31805 +#define pxd_t pud_t
31806 +#define pyd_t pgd_t
31807 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31808 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31809 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31810 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31811 +#define PYD_SIZE PGDIR_SIZE
31812 +#else
31813 +#define pxd_t pmd_t
31814 +#define pyd_t pud_t
31815 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31816 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31817 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31818 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31819 +#define PYD_SIZE PUD_SIZE
31820 +#endif
31821 +
31822 +#ifdef CONFIG_PAX_PER_CPU_PGD
31823 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31824 +static inline void pgd_dtor(pgd_t *pgd) {}
31825 +#else
31826 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31827 {
31828 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31829 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31830 pgd_list_del(pgd);
31831 spin_unlock(&pgd_lock);
31832 }
31833 +#endif
31834
31835 /*
31836 * List of all pgd's needed for non-PAE so it can invalidate entries
31837 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31838 * -- nyc
31839 */
31840
31841 -#ifdef CONFIG_X86_PAE
31842 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31843 /*
31844 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31845 * updating the top-level pagetable entries to guarantee the
31846 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31847 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31848 * and initialize the kernel pmds here.
31849 */
31850 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31851 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31852
31853 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31854 {
31855 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31856 */
31857 flush_tlb_mm(mm);
31858 }
31859 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31860 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31861 #else /* !CONFIG_X86_PAE */
31862
31863 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31864 -#define PREALLOCATED_PMDS 0
31865 +#define PREALLOCATED_PXDS 0
31866
31867 #endif /* CONFIG_X86_PAE */
31868
31869 -static void free_pmds(pmd_t *pmds[])
31870 +static void free_pxds(pxd_t *pxds[])
31871 {
31872 int i;
31873
31874 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31875 - if (pmds[i])
31876 - free_page((unsigned long)pmds[i]);
31877 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31878 + if (pxds[i])
31879 + free_page((unsigned long)pxds[i]);
31880 }
31881
31882 -static int preallocate_pmds(pmd_t *pmds[])
31883 +static int preallocate_pxds(pxd_t *pxds[])
31884 {
31885 int i;
31886 bool failed = false;
31887
31888 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31889 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31890 - if (pmd == NULL)
31891 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31892 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31893 + if (pxd == NULL)
31894 failed = true;
31895 - pmds[i] = pmd;
31896 + pxds[i] = pxd;
31897 }
31898
31899 if (failed) {
31900 - free_pmds(pmds);
31901 + free_pxds(pxds);
31902 return -ENOMEM;
31903 }
31904
31905 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31906 * preallocate which never got a corresponding vma will need to be
31907 * freed manually.
31908 */
31909 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31910 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31911 {
31912 int i;
31913
31914 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31915 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31916 pgd_t pgd = pgdp[i];
31917
31918 if (pgd_val(pgd) != 0) {
31919 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31920 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31921
31922 - pgdp[i] = native_make_pgd(0);
31923 + set_pgd(pgdp + i, native_make_pgd(0));
31924
31925 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31926 - pmd_free(mm, pmd);
31927 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31928 + pxd_free(mm, pxd);
31929 }
31930 }
31931 }
31932
31933 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31934 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31935 {
31936 - pud_t *pud;
31937 + pyd_t *pyd;
31938 int i;
31939
31940 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31941 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31942 return;
31943
31944 - pud = pud_offset(pgd, 0);
31945 -
31946 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31947 - pmd_t *pmd = pmds[i];
31948 +#ifdef CONFIG_X86_64
31949 + pyd = pyd_offset(mm, 0L);
31950 +#else
31951 + pyd = pyd_offset(pgd, 0L);
31952 +#endif
31953
31954 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31955 + pxd_t *pxd = pxds[i];
31956 if (i >= KERNEL_PGD_BOUNDARY)
31957 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31958 - sizeof(pmd_t) * PTRS_PER_PMD);
31959 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31960 + sizeof(pxd_t) * PTRS_PER_PMD);
31961
31962 - pud_populate(mm, pud, pmd);
31963 + pyd_populate(mm, pyd, pxd);
31964 }
31965 }
31966
31967 pgd_t *pgd_alloc(struct mm_struct *mm)
31968 {
31969 pgd_t *pgd;
31970 - pmd_t *pmds[PREALLOCATED_PMDS];
31971 + pxd_t *pxds[PREALLOCATED_PXDS];
31972
31973 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
31974
31975 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
31976
31977 mm->pgd = pgd;
31978
31979 - if (preallocate_pmds(pmds) != 0)
31980 + if (preallocate_pxds(pxds) != 0)
31981 goto out_free_pgd;
31982
31983 if (paravirt_pgd_alloc(mm) != 0)
31984 - goto out_free_pmds;
31985 + goto out_free_pxds;
31986
31987 /*
31988 * Make sure that pre-populating the pmds is atomic with
31989 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
31990 spin_lock(&pgd_lock);
31991
31992 pgd_ctor(mm, pgd);
31993 - pgd_prepopulate_pmd(mm, pgd, pmds);
31994 + pgd_prepopulate_pxd(mm, pgd, pxds);
31995
31996 spin_unlock(&pgd_lock);
31997
31998 return pgd;
31999
32000 -out_free_pmds:
32001 - free_pmds(pmds);
32002 +out_free_pxds:
32003 + free_pxds(pxds);
32004 out_free_pgd:
32005 free_page((unsigned long)pgd);
32006 out:
32007 @@ -300,7 +363,7 @@ out:
32008
32009 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32010 {
32011 - pgd_mop_up_pmds(mm, pgd);
32012 + pgd_mop_up_pxds(mm, pgd);
32013 pgd_dtor(pgd);
32014 paravirt_pgd_free(mm, pgd);
32015 free_page((unsigned long)pgd);
32016 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32017 index a69bcb8..19068ab 100644
32018 --- a/arch/x86/mm/pgtable_32.c
32019 +++ b/arch/x86/mm/pgtable_32.c
32020 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32021 return;
32022 }
32023 pte = pte_offset_kernel(pmd, vaddr);
32024 +
32025 + pax_open_kernel();
32026 if (pte_val(pteval))
32027 set_pte_at(&init_mm, vaddr, pte, pteval);
32028 else
32029 pte_clear(&init_mm, vaddr, pte);
32030 + pax_close_kernel();
32031
32032 /*
32033 * It's enough to flush this one mapping.
32034 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32035 index e666cbb..61788c45 100644
32036 --- a/arch/x86/mm/physaddr.c
32037 +++ b/arch/x86/mm/physaddr.c
32038 @@ -10,7 +10,7 @@
32039 #ifdef CONFIG_X86_64
32040
32041 #ifdef CONFIG_DEBUG_VIRTUAL
32042 -unsigned long __phys_addr(unsigned long x)
32043 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32044 {
32045 unsigned long y = x - __START_KERNEL_map;
32046
32047 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32048 #else
32049
32050 #ifdef CONFIG_DEBUG_VIRTUAL
32051 -unsigned long __phys_addr(unsigned long x)
32052 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32053 {
32054 unsigned long phys_addr = x - PAGE_OFFSET;
32055 /* VMALLOC_* aren't constants */
32056 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32057 index 90555bf..f5f1828 100644
32058 --- a/arch/x86/mm/setup_nx.c
32059 +++ b/arch/x86/mm/setup_nx.c
32060 @@ -5,8 +5,10 @@
32061 #include <asm/pgtable.h>
32062 #include <asm/proto.h>
32063
32064 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32065 static int disable_nx;
32066
32067 +#ifndef CONFIG_PAX_PAGEEXEC
32068 /*
32069 * noexec = on|off
32070 *
32071 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32072 return 0;
32073 }
32074 early_param("noexec", noexec_setup);
32075 +#endif
32076 +
32077 +#endif
32078
32079 void x86_configure_nx(void)
32080 {
32081 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32082 if (cpu_has_nx && !disable_nx)
32083 __supported_pte_mask |= _PAGE_NX;
32084 else
32085 +#endif
32086 __supported_pte_mask &= ~_PAGE_NX;
32087 }
32088
32089 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32090 index 282375f..e03a98f 100644
32091 --- a/arch/x86/mm/tlb.c
32092 +++ b/arch/x86/mm/tlb.c
32093 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32094 BUG();
32095 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32096 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32097 +
32098 +#ifndef CONFIG_PAX_PER_CPU_PGD
32099 load_cr3(swapper_pg_dir);
32100 +#endif
32101 +
32102 }
32103 }
32104 EXPORT_SYMBOL_GPL(leave_mm);
32105 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32106 new file mode 100644
32107 index 0000000..dace51c
32108 --- /dev/null
32109 +++ b/arch/x86/mm/uderef_64.c
32110 @@ -0,0 +1,37 @@
32111 +#include <linux/mm.h>
32112 +#include <asm/pgtable.h>
32113 +#include <asm/uaccess.h>
32114 +
32115 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32116 +/* PaX: due to the special call convention these functions must
32117 + * - remain leaf functions under all configurations,
32118 + * - never be called directly, only dereferenced from the wrappers.
32119 + */
32120 +void __pax_open_userland(void)
32121 +{
32122 + unsigned int cpu;
32123 +
32124 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32125 + return;
32126 +
32127 + cpu = raw_get_cpu();
32128 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32129 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32130 + raw_put_cpu_no_resched();
32131 +}
32132 +EXPORT_SYMBOL(__pax_open_userland);
32133 +
32134 +void __pax_close_userland(void)
32135 +{
32136 + unsigned int cpu;
32137 +
32138 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32139 + return;
32140 +
32141 + cpu = raw_get_cpu();
32142 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32143 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32144 + raw_put_cpu_no_resched();
32145 +}
32146 +EXPORT_SYMBOL(__pax_close_userland);
32147 +#endif
32148 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32149 index 877b9a1..a8ecf42 100644
32150 --- a/arch/x86/net/bpf_jit.S
32151 +++ b/arch/x86/net/bpf_jit.S
32152 @@ -9,6 +9,7 @@
32153 */
32154 #include <linux/linkage.h>
32155 #include <asm/dwarf2.h>
32156 +#include <asm/alternative-asm.h>
32157
32158 /*
32159 * Calling convention :
32160 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32161 jle bpf_slow_path_word
32162 mov (SKBDATA,%rsi),%eax
32163 bswap %eax /* ntohl() */
32164 + pax_force_retaddr
32165 ret
32166
32167 sk_load_half:
32168 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32169 jle bpf_slow_path_half
32170 movzwl (SKBDATA,%rsi),%eax
32171 rol $8,%ax # ntohs()
32172 + pax_force_retaddr
32173 ret
32174
32175 sk_load_byte:
32176 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32177 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32178 jle bpf_slow_path_byte
32179 movzbl (SKBDATA,%rsi),%eax
32180 + pax_force_retaddr
32181 ret
32182
32183 /**
32184 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32185 movzbl (SKBDATA,%rsi),%ebx
32186 and $15,%bl
32187 shl $2,%bl
32188 + pax_force_retaddr
32189 ret
32190
32191 /* rsi contains offset and can be scratched */
32192 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32193 js bpf_error
32194 mov -12(%rbp),%eax
32195 bswap %eax
32196 + pax_force_retaddr
32197 ret
32198
32199 bpf_slow_path_half:
32200 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32201 mov -12(%rbp),%ax
32202 rol $8,%ax
32203 movzwl %ax,%eax
32204 + pax_force_retaddr
32205 ret
32206
32207 bpf_slow_path_byte:
32208 bpf_slow_path_common(1)
32209 js bpf_error
32210 movzbl -12(%rbp),%eax
32211 + pax_force_retaddr
32212 ret
32213
32214 bpf_slow_path_byte_msh:
32215 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32216 and $15,%al
32217 shl $2,%al
32218 xchg %eax,%ebx
32219 + pax_force_retaddr
32220 ret
32221
32222 #define sk_negative_common(SIZE) \
32223 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32224 sk_negative_common(4)
32225 mov (%rax), %eax
32226 bswap %eax
32227 + pax_force_retaddr
32228 ret
32229
32230 bpf_slow_path_half_neg:
32231 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32232 mov (%rax),%ax
32233 rol $8,%ax
32234 movzwl %ax,%eax
32235 + pax_force_retaddr
32236 ret
32237
32238 bpf_slow_path_byte_neg:
32239 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32240 .globl sk_load_byte_negative_offset
32241 sk_negative_common(1)
32242 movzbl (%rax), %eax
32243 + pax_force_retaddr
32244 ret
32245
32246 bpf_slow_path_byte_msh_neg:
32247 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32248 and $15,%al
32249 shl $2,%al
32250 xchg %eax,%ebx
32251 + pax_force_retaddr
32252 ret
32253
32254 bpf_error:
32255 @@ -197,4 +210,5 @@ bpf_error:
32256 xor %eax,%eax
32257 mov -8(%rbp),%rbx
32258 leaveq
32259 + pax_force_retaddr
32260 ret
32261 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32262 index 79c216a..08d39cc 100644
32263 --- a/arch/x86/net/bpf_jit_comp.c
32264 +++ b/arch/x86/net/bpf_jit_comp.c
32265 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32266 return ptr + len;
32267 }
32268
32269 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32270 +#define MAX_INSTR_CODE_SIZE 96
32271 +#else
32272 +#define MAX_INSTR_CODE_SIZE 64
32273 +#endif
32274 +
32275 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32276
32277 #define EMIT1(b1) EMIT(b1, 1)
32278 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32279 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32280 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32281 +
32282 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32283 +/* original constant will appear in ecx */
32284 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32285 +do { \
32286 + /* mov ecx, randkey */ \
32287 + EMIT1(0xb9); \
32288 + EMIT(_key, 4); \
32289 + /* xor ecx, randkey ^ off */ \
32290 + EMIT2(0x81, 0xf1); \
32291 + EMIT((_key) ^ (_off), 4); \
32292 +} while (0)
32293 +
32294 +#define EMIT1_off32(b1, _off) \
32295 +do { \
32296 + switch (b1) { \
32297 + case 0x05: /* add eax, imm32 */ \
32298 + case 0x2d: /* sub eax, imm32 */ \
32299 + case 0x25: /* and eax, imm32 */ \
32300 + case 0x0d: /* or eax, imm32 */ \
32301 + case 0xb8: /* mov eax, imm32 */ \
32302 + case 0x35: /* xor eax, imm32 */ \
32303 + case 0x3d: /* cmp eax, imm32 */ \
32304 + case 0xa9: /* test eax, imm32 */ \
32305 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32306 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32307 + break; \
32308 + case 0xbb: /* mov ebx, imm32 */ \
32309 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32310 + /* mov ebx, ecx */ \
32311 + EMIT2(0x89, 0xcb); \
32312 + break; \
32313 + case 0xbe: /* mov esi, imm32 */ \
32314 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32315 + /* mov esi, ecx */ \
32316 + EMIT2(0x89, 0xce); \
32317 + break; \
32318 + case 0xe8: /* call rel imm32, always to known funcs */ \
32319 + EMIT1(b1); \
32320 + EMIT(_off, 4); \
32321 + break; \
32322 + case 0xe9: /* jmp rel imm32 */ \
32323 + EMIT1(b1); \
32324 + EMIT(_off, 4); \
32325 + /* prevent fall-through, we're not called if off = 0 */ \
32326 + EMIT(0xcccccccc, 4); \
32327 + EMIT(0xcccccccc, 4); \
32328 + break; \
32329 + default: \
32330 + BUILD_BUG(); \
32331 + } \
32332 +} while (0)
32333 +
32334 +#define EMIT2_off32(b1, b2, _off) \
32335 +do { \
32336 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32337 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32338 + EMIT(randkey, 4); \
32339 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32340 + EMIT((_off) - randkey, 4); \
32341 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32342 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32343 + /* imul eax, ecx */ \
32344 + EMIT3(0x0f, 0xaf, 0xc1); \
32345 + } else { \
32346 + BUILD_BUG(); \
32347 + } \
32348 +} while (0)
32349 +#else
32350 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32351 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32352 +#endif
32353
32354 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32355 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32356 @@ -91,6 +168,24 @@ do { \
32357 #define X86_JBE 0x76
32358 #define X86_JA 0x77
32359
32360 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32361 +#define APPEND_FLOW_VERIFY() \
32362 +do { \
32363 + /* mov ecx, randkey */ \
32364 + EMIT1(0xb9); \
32365 + EMIT(randkey, 4); \
32366 + /* cmp ecx, randkey */ \
32367 + EMIT2(0x81, 0xf9); \
32368 + EMIT(randkey, 4); \
32369 + /* jz after 8 int 3s */ \
32370 + EMIT2(0x74, 0x08); \
32371 + EMIT(0xcccccccc, 4); \
32372 + EMIT(0xcccccccc, 4); \
32373 +} while (0)
32374 +#else
32375 +#define APPEND_FLOW_VERIFY() do { } while (0)
32376 +#endif
32377 +
32378 #define EMIT_COND_JMP(op, offset) \
32379 do { \
32380 if (is_near(offset)) \
32381 @@ -98,6 +193,7 @@ do { \
32382 else { \
32383 EMIT2(0x0f, op + 0x10); \
32384 EMIT(offset, 4); /* jxx .+off32 */ \
32385 + APPEND_FLOW_VERIFY(); \
32386 } \
32387 } while (0)
32388
32389 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32390 return -1;
32391 }
32392
32393 -struct bpf_binary_header {
32394 - unsigned int pages;
32395 - /* Note : for security reasons, bpf code will follow a randomly
32396 - * sized amount of int3 instructions
32397 - */
32398 - u8 image[];
32399 -};
32400 -
32401 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32402 +/* Note : for security reasons, bpf code will follow a randomly
32403 + * sized amount of int3 instructions
32404 + */
32405 +static u8 *bpf_alloc_binary(unsigned int proglen,
32406 u8 **image_ptr)
32407 {
32408 unsigned int sz, hole;
32409 - struct bpf_binary_header *header;
32410 + u8 *header;
32411
32412 /* Most of BPF filters are really small,
32413 * but if some of them fill a page, allow at least
32414 * 128 extra bytes to insert a random section of int3
32415 */
32416 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32417 - header = module_alloc(sz);
32418 + sz = round_up(proglen + 128, PAGE_SIZE);
32419 + header = module_alloc_exec(sz);
32420 if (!header)
32421 return NULL;
32422
32423 + pax_open_kernel();
32424 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32425 + pax_close_kernel();
32426
32427 - header->pages = sz / PAGE_SIZE;
32428 - hole = sz - (proglen + sizeof(*header));
32429 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32430
32431 /* insert a random number of int3 instructions before BPF code */
32432 - *image_ptr = &header->image[prandom_u32() % hole];
32433 + *image_ptr = &header[prandom_u32() % hole];
32434 return header;
32435 }
32436
32437 void bpf_jit_compile(struct sk_filter *fp)
32438 {
32439 - u8 temp[64];
32440 + u8 temp[MAX_INSTR_CODE_SIZE];
32441 u8 *prog;
32442 unsigned int proglen, oldproglen = 0;
32443 int ilen, i;
32444 int t_offset, f_offset;
32445 u8 t_op, f_op, seen = 0, pass;
32446 u8 *image = NULL;
32447 - struct bpf_binary_header *header = NULL;
32448 + u8 *header = NULL;
32449 u8 *func;
32450 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32451 unsigned int cleanup_addr; /* epilogue code offset */
32452 unsigned int *addrs;
32453 const struct sock_filter *filter = fp->insns;
32454 int flen = fp->len;
32455 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32456 + unsigned int randkey;
32457 +#endif
32458
32459 if (!bpf_jit_enable)
32460 return;
32461 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32462 if (addrs == NULL)
32463 return;
32464
32465 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32466 + randkey = get_random_int();
32467 +#endif
32468 +
32469 /* Before first pass, make a rough estimation of addrs[]
32470 - * each bpf instruction is translated to less than 64 bytes
32471 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32472 */
32473 for (proglen = 0, i = 0; i < flen; i++) {
32474 - proglen += 64;
32475 + proglen += MAX_INSTR_CODE_SIZE;
32476 addrs[i] = proglen;
32477 }
32478 cleanup_addr = proglen; /* epilogue address */
32479 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32480 case BPF_S_ALU_MUL_K: /* A *= K */
32481 if (is_imm8(K))
32482 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32483 - else {
32484 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32485 - EMIT(K, 4);
32486 - }
32487 + else
32488 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32489 break;
32490 case BPF_S_ALU_DIV_X: /* A /= X; */
32491 seen |= SEEN_XREG;
32492 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32493 break;
32494 case BPF_S_ALU_MOD_K: /* A %= K; */
32495 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32496 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32497 + DILUTE_CONST_SEQUENCE(K, randkey);
32498 +#else
32499 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32500 +#endif
32501 EMIT2(0xf7, 0xf1); /* div %ecx */
32502 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32503 break;
32504 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32505 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32506 + DILUTE_CONST_SEQUENCE(K, randkey);
32507 + // imul rax, rcx
32508 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32509 +#else
32510 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32511 EMIT(K, 4);
32512 +#endif
32513 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32514 break;
32515 case BPF_S_ALU_AND_X:
32516 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32517 if (is_imm8(K)) {
32518 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32519 } else {
32520 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32521 - EMIT(K, 4);
32522 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32523 }
32524 } else {
32525 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32526 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32527 if (unlikely(proglen + ilen > oldproglen)) {
32528 pr_err("bpb_jit_compile fatal error\n");
32529 kfree(addrs);
32530 - module_free(NULL, header);
32531 + module_free_exec(NULL, image);
32532 return;
32533 }
32534 + pax_open_kernel();
32535 memcpy(image + proglen, temp, ilen);
32536 + pax_close_kernel();
32537 }
32538 proglen += ilen;
32539 addrs[i] = proglen;
32540 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32541
32542 if (image) {
32543 bpf_flush_icache(header, image + proglen);
32544 - set_memory_ro((unsigned long)header, header->pages);
32545 fp->bpf_func = (void *)image;
32546 }
32547 out:
32548 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32549 {
32550 if (fp->bpf_func != sk_run_filter) {
32551 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32552 - struct bpf_binary_header *header = (void *)addr;
32553 -
32554 - set_memory_rw(addr, header->pages);
32555 - module_free(NULL, header);
32556 + set_memory_rw(addr, 1);
32557 + module_free_exec(NULL, (void *)addr);
32558 }
32559 }
32560 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32561 index d6aa6e8..266395a 100644
32562 --- a/arch/x86/oprofile/backtrace.c
32563 +++ b/arch/x86/oprofile/backtrace.c
32564 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32565 struct stack_frame_ia32 *fp;
32566 unsigned long bytes;
32567
32568 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32569 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32570 if (bytes != sizeof(bufhead))
32571 return NULL;
32572
32573 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32574 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32575
32576 oprofile_add_trace(bufhead[0].return_address);
32577
32578 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32579 struct stack_frame bufhead[2];
32580 unsigned long bytes;
32581
32582 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32583 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32584 if (bytes != sizeof(bufhead))
32585 return NULL;
32586
32587 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32588 {
32589 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32590
32591 - if (!user_mode_vm(regs)) {
32592 + if (!user_mode(regs)) {
32593 unsigned long stack = kernel_stack_pointer(regs);
32594 if (depth)
32595 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32596 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32597 index 48768df..ba9143c 100644
32598 --- a/arch/x86/oprofile/nmi_int.c
32599 +++ b/arch/x86/oprofile/nmi_int.c
32600 @@ -23,6 +23,7 @@
32601 #include <asm/nmi.h>
32602 #include <asm/msr.h>
32603 #include <asm/apic.h>
32604 +#include <asm/pgtable.h>
32605
32606 #include "op_counter.h"
32607 #include "op_x86_model.h"
32608 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32609 if (ret)
32610 return ret;
32611
32612 - if (!model->num_virt_counters)
32613 - model->num_virt_counters = model->num_counters;
32614 + if (!model->num_virt_counters) {
32615 + pax_open_kernel();
32616 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32617 + pax_close_kernel();
32618 + }
32619
32620 mux_init(ops);
32621
32622 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32623 index b2b9443..be58856 100644
32624 --- a/arch/x86/oprofile/op_model_amd.c
32625 +++ b/arch/x86/oprofile/op_model_amd.c
32626 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32627 num_counters = AMD64_NUM_COUNTERS;
32628 }
32629
32630 - op_amd_spec.num_counters = num_counters;
32631 - op_amd_spec.num_controls = num_counters;
32632 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32633 + pax_open_kernel();
32634 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32635 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32636 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32637 + pax_close_kernel();
32638
32639 return 0;
32640 }
32641 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32642 index d90528e..0127e2b 100644
32643 --- a/arch/x86/oprofile/op_model_ppro.c
32644 +++ b/arch/x86/oprofile/op_model_ppro.c
32645 @@ -19,6 +19,7 @@
32646 #include <asm/msr.h>
32647 #include <asm/apic.h>
32648 #include <asm/nmi.h>
32649 +#include <asm/pgtable.h>
32650
32651 #include "op_x86_model.h"
32652 #include "op_counter.h"
32653 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32654
32655 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32656
32657 - op_arch_perfmon_spec.num_counters = num_counters;
32658 - op_arch_perfmon_spec.num_controls = num_counters;
32659 + pax_open_kernel();
32660 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32661 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32662 + pax_close_kernel();
32663 }
32664
32665 static int arch_perfmon_init(struct oprofile_operations *ignore)
32666 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32667 index 71e8a67..6a313bb 100644
32668 --- a/arch/x86/oprofile/op_x86_model.h
32669 +++ b/arch/x86/oprofile/op_x86_model.h
32670 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32671 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32672 struct op_msrs const * const msrs);
32673 #endif
32674 -};
32675 +} __do_const;
32676
32677 struct op_counter_config;
32678
32679 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32680 index 372e9b8..e775a6c 100644
32681 --- a/arch/x86/pci/irq.c
32682 +++ b/arch/x86/pci/irq.c
32683 @@ -50,7 +50,7 @@ struct irq_router {
32684 struct irq_router_handler {
32685 u16 vendor;
32686 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32687 -};
32688 +} __do_const;
32689
32690 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32691 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32692 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32693 return 0;
32694 }
32695
32696 -static __initdata struct irq_router_handler pirq_routers[] = {
32697 +static __initconst const struct irq_router_handler pirq_routers[] = {
32698 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32699 { PCI_VENDOR_ID_AL, ali_router_probe },
32700 { PCI_VENDOR_ID_ITE, ite_router_probe },
32701 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32702 static void __init pirq_find_router(struct irq_router *r)
32703 {
32704 struct irq_routing_table *rt = pirq_table;
32705 - struct irq_router_handler *h;
32706 + const struct irq_router_handler *h;
32707
32708 #ifdef CONFIG_PCI_BIOS
32709 if (!rt->signature) {
32710 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32711 return 0;
32712 }
32713
32714 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32715 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32716 {
32717 .callback = fix_broken_hp_bios_irq9,
32718 .ident = "HP Pavilion N5400 Series Laptop",
32719 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32720 index 6eb18c4..20d83de 100644
32721 --- a/arch/x86/pci/mrst.c
32722 +++ b/arch/x86/pci/mrst.c
32723 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32724 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32725 pci_mmcfg_late_init();
32726 pcibios_enable_irq = mrst_pci_irq_enable;
32727 - pci_root_ops = pci_mrst_ops;
32728 + pax_open_kernel();
32729 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32730 + pax_close_kernel();
32731 pci_soc_mode = 1;
32732 /* Continue with standard init */
32733 return 1;
32734 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32735 index c77b24a..c979855 100644
32736 --- a/arch/x86/pci/pcbios.c
32737 +++ b/arch/x86/pci/pcbios.c
32738 @@ -79,7 +79,7 @@ union bios32 {
32739 static struct {
32740 unsigned long address;
32741 unsigned short segment;
32742 -} bios32_indirect = { 0, __KERNEL_CS };
32743 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32744
32745 /*
32746 * Returns the entry point for the given service, NULL on error
32747 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32748 unsigned long length; /* %ecx */
32749 unsigned long entry; /* %edx */
32750 unsigned long flags;
32751 + struct desc_struct d, *gdt;
32752
32753 local_irq_save(flags);
32754 - __asm__("lcall *(%%edi); cld"
32755 +
32756 + gdt = get_cpu_gdt_table(smp_processor_id());
32757 +
32758 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32759 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32760 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32761 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32762 +
32763 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32764 : "=a" (return_code),
32765 "=b" (address),
32766 "=c" (length),
32767 "=d" (entry)
32768 : "0" (service),
32769 "1" (0),
32770 - "D" (&bios32_indirect));
32771 + "D" (&bios32_indirect),
32772 + "r"(__PCIBIOS_DS)
32773 + : "memory");
32774 +
32775 + pax_open_kernel();
32776 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32777 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32778 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32779 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32780 + pax_close_kernel();
32781 +
32782 local_irq_restore(flags);
32783
32784 switch (return_code) {
32785 - case 0:
32786 - return address + entry;
32787 - case 0x80: /* Not present */
32788 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32789 - return 0;
32790 - default: /* Shouldn't happen */
32791 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32792 - service, return_code);
32793 + case 0: {
32794 + int cpu;
32795 + unsigned char flags;
32796 +
32797 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32798 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32799 + printk(KERN_WARNING "bios32_service: not valid\n");
32800 return 0;
32801 + }
32802 + address = address + PAGE_OFFSET;
32803 + length += 16UL; /* some BIOSs underreport this... */
32804 + flags = 4;
32805 + if (length >= 64*1024*1024) {
32806 + length >>= PAGE_SHIFT;
32807 + flags |= 8;
32808 + }
32809 +
32810 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32811 + gdt = get_cpu_gdt_table(cpu);
32812 + pack_descriptor(&d, address, length, 0x9b, flags);
32813 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32814 + pack_descriptor(&d, address, length, 0x93, flags);
32815 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32816 + }
32817 + return entry;
32818 + }
32819 + case 0x80: /* Not present */
32820 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32821 + return 0;
32822 + default: /* Shouldn't happen */
32823 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32824 + service, return_code);
32825 + return 0;
32826 }
32827 }
32828
32829 static struct {
32830 unsigned long address;
32831 unsigned short segment;
32832 -} pci_indirect = { 0, __KERNEL_CS };
32833 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32834
32835 -static int pci_bios_present;
32836 +static int pci_bios_present __read_only;
32837
32838 static int check_pcibios(void)
32839 {
32840 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32841 unsigned long flags, pcibios_entry;
32842
32843 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32844 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32845 + pci_indirect.address = pcibios_entry;
32846
32847 local_irq_save(flags);
32848 - __asm__(
32849 - "lcall *(%%edi); cld\n\t"
32850 + __asm__("movw %w6, %%ds\n\t"
32851 + "lcall *%%ss:(%%edi); cld\n\t"
32852 + "push %%ss\n\t"
32853 + "pop %%ds\n\t"
32854 "jc 1f\n\t"
32855 "xor %%ah, %%ah\n"
32856 "1:"
32857 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32858 "=b" (ebx),
32859 "=c" (ecx)
32860 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32861 - "D" (&pci_indirect)
32862 + "D" (&pci_indirect),
32863 + "r" (__PCIBIOS_DS)
32864 : "memory");
32865 local_irq_restore(flags);
32866
32867 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32868
32869 switch (len) {
32870 case 1:
32871 - __asm__("lcall *(%%esi); cld\n\t"
32872 + __asm__("movw %w6, %%ds\n\t"
32873 + "lcall *%%ss:(%%esi); cld\n\t"
32874 + "push %%ss\n\t"
32875 + "pop %%ds\n\t"
32876 "jc 1f\n\t"
32877 "xor %%ah, %%ah\n"
32878 "1:"
32879 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32880 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32881 "b" (bx),
32882 "D" ((long)reg),
32883 - "S" (&pci_indirect));
32884 + "S" (&pci_indirect),
32885 + "r" (__PCIBIOS_DS));
32886 /*
32887 * Zero-extend the result beyond 8 bits, do not trust the
32888 * BIOS having done it:
32889 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32890 *value &= 0xff;
32891 break;
32892 case 2:
32893 - __asm__("lcall *(%%esi); cld\n\t"
32894 + __asm__("movw %w6, %%ds\n\t"
32895 + "lcall *%%ss:(%%esi); cld\n\t"
32896 + "push %%ss\n\t"
32897 + "pop %%ds\n\t"
32898 "jc 1f\n\t"
32899 "xor %%ah, %%ah\n"
32900 "1:"
32901 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32902 : "1" (PCIBIOS_READ_CONFIG_WORD),
32903 "b" (bx),
32904 "D" ((long)reg),
32905 - "S" (&pci_indirect));
32906 + "S" (&pci_indirect),
32907 + "r" (__PCIBIOS_DS));
32908 /*
32909 * Zero-extend the result beyond 16 bits, do not trust the
32910 * BIOS having done it:
32911 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32912 *value &= 0xffff;
32913 break;
32914 case 4:
32915 - __asm__("lcall *(%%esi); cld\n\t"
32916 + __asm__("movw %w6, %%ds\n\t"
32917 + "lcall *%%ss:(%%esi); cld\n\t"
32918 + "push %%ss\n\t"
32919 + "pop %%ds\n\t"
32920 "jc 1f\n\t"
32921 "xor %%ah, %%ah\n"
32922 "1:"
32923 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32924 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32925 "b" (bx),
32926 "D" ((long)reg),
32927 - "S" (&pci_indirect));
32928 + "S" (&pci_indirect),
32929 + "r" (__PCIBIOS_DS));
32930 break;
32931 }
32932
32933 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32934
32935 switch (len) {
32936 case 1:
32937 - __asm__("lcall *(%%esi); cld\n\t"
32938 + __asm__("movw %w6, %%ds\n\t"
32939 + "lcall *%%ss:(%%esi); cld\n\t"
32940 + "push %%ss\n\t"
32941 + "pop %%ds\n\t"
32942 "jc 1f\n\t"
32943 "xor %%ah, %%ah\n"
32944 "1:"
32945 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32946 "c" (value),
32947 "b" (bx),
32948 "D" ((long)reg),
32949 - "S" (&pci_indirect));
32950 + "S" (&pci_indirect),
32951 + "r" (__PCIBIOS_DS));
32952 break;
32953 case 2:
32954 - __asm__("lcall *(%%esi); cld\n\t"
32955 + __asm__("movw %w6, %%ds\n\t"
32956 + "lcall *%%ss:(%%esi); cld\n\t"
32957 + "push %%ss\n\t"
32958 + "pop %%ds\n\t"
32959 "jc 1f\n\t"
32960 "xor %%ah, %%ah\n"
32961 "1:"
32962 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32963 "c" (value),
32964 "b" (bx),
32965 "D" ((long)reg),
32966 - "S" (&pci_indirect));
32967 + "S" (&pci_indirect),
32968 + "r" (__PCIBIOS_DS));
32969 break;
32970 case 4:
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 @@ -289,7 +358,8 @@ 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 }
32988
32989 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
32990
32991 DBG("PCI: Fetching IRQ routing table... ");
32992 __asm__("push %%es\n\t"
32993 + "movw %w8, %%ds\n\t"
32994 "push %%ds\n\t"
32995 "pop %%es\n\t"
32996 - "lcall *(%%esi); cld\n\t"
32997 + "lcall *%%ss:(%%esi); cld\n\t"
32998 "pop %%es\n\t"
32999 + "push %%ss\n\t"
33000 + "pop %%ds\n"
33001 "jc 1f\n\t"
33002 "xor %%ah, %%ah\n"
33003 "1:"
33004 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33005 "1" (0),
33006 "D" ((long) &opt),
33007 "S" (&pci_indirect),
33008 - "m" (opt)
33009 + "m" (opt),
33010 + "r" (__PCIBIOS_DS)
33011 : "memory");
33012 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33013 if (ret & 0xff00)
33014 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33015 {
33016 int ret;
33017
33018 - __asm__("lcall *(%%esi); cld\n\t"
33019 + __asm__("movw %w5, %%ds\n\t"
33020 + "lcall *%%ss:(%%esi); cld\n\t"
33021 + "push %%ss\n\t"
33022 + "pop %%ds\n"
33023 "jc 1f\n\t"
33024 "xor %%ah, %%ah\n"
33025 "1:"
33026 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33027 : "0" (PCIBIOS_SET_PCI_HW_INT),
33028 "b" ((dev->bus->number << 8) | dev->devfn),
33029 "c" ((irq << 8) | (pin + 10)),
33030 - "S" (&pci_indirect));
33031 + "S" (&pci_indirect),
33032 + "r" (__PCIBIOS_DS));
33033 return !(ret & 0xff00);
33034 }
33035 EXPORT_SYMBOL(pcibios_set_irq_routing);
33036 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33037 index 40e4469..d915bf9 100644
33038 --- a/arch/x86/platform/efi/efi_32.c
33039 +++ b/arch/x86/platform/efi/efi_32.c
33040 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33041 {
33042 struct desc_ptr gdt_descr;
33043
33044 +#ifdef CONFIG_PAX_KERNEXEC
33045 + struct desc_struct d;
33046 +#endif
33047 +
33048 local_irq_save(efi_rt_eflags);
33049
33050 load_cr3(initial_page_table);
33051 __flush_tlb_all();
33052
33053 +#ifdef CONFIG_PAX_KERNEXEC
33054 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33055 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33056 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33057 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33058 +#endif
33059 +
33060 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33061 gdt_descr.size = GDT_SIZE - 1;
33062 load_gdt(&gdt_descr);
33063 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33064 {
33065 struct desc_ptr gdt_descr;
33066
33067 +#ifdef CONFIG_PAX_KERNEXEC
33068 + struct desc_struct d;
33069 +
33070 + memset(&d, 0, sizeof d);
33071 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33072 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33073 +#endif
33074 +
33075 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33076 gdt_descr.size = GDT_SIZE - 1;
33077 load_gdt(&gdt_descr);
33078
33079 +#ifdef CONFIG_PAX_PER_CPU_PGD
33080 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33081 +#else
33082 load_cr3(swapper_pg_dir);
33083 +#endif
33084 +
33085 __flush_tlb_all();
33086
33087 local_irq_restore(efi_rt_eflags);
33088 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33089 index 39a0e7f1..872396e 100644
33090 --- a/arch/x86/platform/efi/efi_64.c
33091 +++ b/arch/x86/platform/efi/efi_64.c
33092 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33093 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33094 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33095 }
33096 +
33097 +#ifdef CONFIG_PAX_PER_CPU_PGD
33098 + load_cr3(swapper_pg_dir);
33099 +#endif
33100 +
33101 __flush_tlb_all();
33102 }
33103
33104 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33105 for (pgd = 0; pgd < n_pgds; pgd++)
33106 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33107 kfree(save_pgd);
33108 +
33109 +#ifdef CONFIG_PAX_PER_CPU_PGD
33110 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33111 +#endif
33112 +
33113 __flush_tlb_all();
33114 local_irq_restore(efi_flags);
33115 early_code_mapping_set_exec(0);
33116 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33117 index fbe66e6..eae5e38 100644
33118 --- a/arch/x86/platform/efi/efi_stub_32.S
33119 +++ b/arch/x86/platform/efi/efi_stub_32.S
33120 @@ -6,7 +6,9 @@
33121 */
33122
33123 #include <linux/linkage.h>
33124 +#include <linux/init.h>
33125 #include <asm/page_types.h>
33126 +#include <asm/segment.h>
33127
33128 /*
33129 * efi_call_phys(void *, ...) is a function with variable parameters.
33130 @@ -20,7 +22,7 @@
33131 * service functions will comply with gcc calling convention, too.
33132 */
33133
33134 -.text
33135 +__INIT
33136 ENTRY(efi_call_phys)
33137 /*
33138 * 0. The function can only be called in Linux kernel. So CS has been
33139 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33140 * The mapping of lower virtual memory has been created in prelog and
33141 * epilog.
33142 */
33143 - movl $1f, %edx
33144 - subl $__PAGE_OFFSET, %edx
33145 - jmp *%edx
33146 +#ifdef CONFIG_PAX_KERNEXEC
33147 + movl $(__KERNEXEC_EFI_DS), %edx
33148 + mov %edx, %ds
33149 + mov %edx, %es
33150 + mov %edx, %ss
33151 + addl $2f,(1f)
33152 + ljmp *(1f)
33153 +
33154 +__INITDATA
33155 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33156 +.previous
33157 +
33158 +2:
33159 + subl $2b,(1b)
33160 +#else
33161 + jmp 1f-__PAGE_OFFSET
33162 1:
33163 +#endif
33164
33165 /*
33166 * 2. Now on the top of stack is the return
33167 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33168 * parameter 2, ..., param n. To make things easy, we save the return
33169 * address of efi_call_phys in a global variable.
33170 */
33171 - popl %edx
33172 - movl %edx, saved_return_addr
33173 - /* get the function pointer into ECX*/
33174 - popl %ecx
33175 - movl %ecx, efi_rt_function_ptr
33176 - movl $2f, %edx
33177 - subl $__PAGE_OFFSET, %edx
33178 - pushl %edx
33179 + popl (saved_return_addr)
33180 + popl (efi_rt_function_ptr)
33181
33182 /*
33183 * 3. Clear PG bit in %CR0.
33184 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33185 /*
33186 * 5. Call the physical function.
33187 */
33188 - jmp *%ecx
33189 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33190
33191 -2:
33192 /*
33193 * 6. After EFI runtime service returns, control will return to
33194 * following instruction. We'd better readjust stack pointer first.
33195 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33196 movl %cr0, %edx
33197 orl $0x80000000, %edx
33198 movl %edx, %cr0
33199 - jmp 1f
33200 -1:
33201 +
33202 /*
33203 * 8. Now restore the virtual mode from flat mode by
33204 * adding EIP with PAGE_OFFSET.
33205 */
33206 - movl $1f, %edx
33207 - jmp *%edx
33208 +#ifdef CONFIG_PAX_KERNEXEC
33209 + movl $(__KERNEL_DS), %edx
33210 + mov %edx, %ds
33211 + mov %edx, %es
33212 + mov %edx, %ss
33213 + ljmp $(__KERNEL_CS),$1f
33214 +#else
33215 + jmp 1f+__PAGE_OFFSET
33216 +#endif
33217 1:
33218
33219 /*
33220 * 9. Balance the stack. And because EAX contain the return value,
33221 * we'd better not clobber it.
33222 */
33223 - leal efi_rt_function_ptr, %edx
33224 - movl (%edx), %ecx
33225 - pushl %ecx
33226 + pushl (efi_rt_function_ptr)
33227
33228 /*
33229 - * 10. Push the saved return address onto the stack and return.
33230 + * 10. Return to the saved return address.
33231 */
33232 - leal saved_return_addr, %edx
33233 - movl (%edx), %ecx
33234 - pushl %ecx
33235 - ret
33236 + jmpl *(saved_return_addr)
33237 ENDPROC(efi_call_phys)
33238 .previous
33239
33240 -.data
33241 +__INITDATA
33242 saved_return_addr:
33243 .long 0
33244 efi_rt_function_ptr:
33245 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33246 index 4c07cca..2c8427d 100644
33247 --- a/arch/x86/platform/efi/efi_stub_64.S
33248 +++ b/arch/x86/platform/efi/efi_stub_64.S
33249 @@ -7,6 +7,7 @@
33250 */
33251
33252 #include <linux/linkage.h>
33253 +#include <asm/alternative-asm.h>
33254
33255 #define SAVE_XMM \
33256 mov %rsp, %rax; \
33257 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33258 call *%rdi
33259 addq $32, %rsp
33260 RESTORE_XMM
33261 + pax_force_retaddr 0, 1
33262 ret
33263 ENDPROC(efi_call0)
33264
33265 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33266 call *%rdi
33267 addq $32, %rsp
33268 RESTORE_XMM
33269 + pax_force_retaddr 0, 1
33270 ret
33271 ENDPROC(efi_call1)
33272
33273 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33274 call *%rdi
33275 addq $32, %rsp
33276 RESTORE_XMM
33277 + pax_force_retaddr 0, 1
33278 ret
33279 ENDPROC(efi_call2)
33280
33281 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33282 call *%rdi
33283 addq $32, %rsp
33284 RESTORE_XMM
33285 + pax_force_retaddr 0, 1
33286 ret
33287 ENDPROC(efi_call3)
33288
33289 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33290 call *%rdi
33291 addq $32, %rsp
33292 RESTORE_XMM
33293 + pax_force_retaddr 0, 1
33294 ret
33295 ENDPROC(efi_call4)
33296
33297 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33298 call *%rdi
33299 addq $48, %rsp
33300 RESTORE_XMM
33301 + pax_force_retaddr 0, 1
33302 ret
33303 ENDPROC(efi_call5)
33304
33305 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33306 call *%rdi
33307 addq $48, %rsp
33308 RESTORE_XMM
33309 + pax_force_retaddr 0, 1
33310 ret
33311 ENDPROC(efi_call6)
33312 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33313 index 47fe66f..6206449 100644
33314 --- a/arch/x86/platform/mrst/mrst.c
33315 +++ b/arch/x86/platform/mrst/mrst.c
33316 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33317 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33318 int sfi_mrtc_num;
33319
33320 -static void mrst_power_off(void)
33321 +static __noreturn void mrst_power_off(void)
33322 {
33323 + BUG();
33324 }
33325
33326 -static void mrst_reboot(void)
33327 +static __noreturn void mrst_reboot(void)
33328 {
33329 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33330 + BUG();
33331 }
33332
33333 /* parse all the mtimer info to a static mtimer array */
33334 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33335 index d6ee929..3637cb5 100644
33336 --- a/arch/x86/platform/olpc/olpc_dt.c
33337 +++ b/arch/x86/platform/olpc/olpc_dt.c
33338 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33339 return res;
33340 }
33341
33342 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33343 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33344 .nextprop = olpc_dt_nextprop,
33345 .getproplen = olpc_dt_getproplen,
33346 .getproperty = olpc_dt_getproperty,
33347 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33348 index 1cf5b30..fd45732 100644
33349 --- a/arch/x86/power/cpu.c
33350 +++ b/arch/x86/power/cpu.c
33351 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33352 static void fix_processor_context(void)
33353 {
33354 int cpu = smp_processor_id();
33355 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33356 -#ifdef CONFIG_X86_64
33357 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33358 - tss_desc tss;
33359 -#endif
33360 + struct tss_struct *t = init_tss + cpu;
33361 +
33362 set_tss_desc(cpu, t); /*
33363 * This just modifies memory; should not be
33364 * necessary. But... This is necessary, because
33365 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33366 */
33367
33368 #ifdef CONFIG_X86_64
33369 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33370 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33371 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33372 -
33373 syscall_init(); /* This sets MSR_*STAR and related */
33374 #endif
33375 load_TR_desc(); /* This does ltr */
33376 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33377 index a44f457..9140171 100644
33378 --- a/arch/x86/realmode/init.c
33379 +++ b/arch/x86/realmode/init.c
33380 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33381 __va(real_mode_header->trampoline_header);
33382
33383 #ifdef CONFIG_X86_32
33384 - trampoline_header->start = __pa_symbol(startup_32_smp);
33385 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33386 +
33387 +#ifdef CONFIG_PAX_KERNEXEC
33388 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33389 +#endif
33390 +
33391 + trampoline_header->boot_cs = __BOOT_CS;
33392 trampoline_header->gdt_limit = __BOOT_DS + 7;
33393 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33394 #else
33395 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33396 *trampoline_cr4_features = read_cr4();
33397
33398 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33399 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33400 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33401 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33402 #endif
33403 }
33404 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33405 index 8869287..d577672 100644
33406 --- a/arch/x86/realmode/rm/Makefile
33407 +++ b/arch/x86/realmode/rm/Makefile
33408 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33409 $(call cc-option, -fno-unit-at-a-time)) \
33410 $(call cc-option, -fno-stack-protector) \
33411 $(call cc-option, -mpreferred-stack-boundary=2)
33412 +ifdef CONSTIFY_PLUGIN
33413 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33414 +endif
33415 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33416 GCOV_PROFILE := n
33417 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33418 index a28221d..93c40f1 100644
33419 --- a/arch/x86/realmode/rm/header.S
33420 +++ b/arch/x86/realmode/rm/header.S
33421 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33422 #endif
33423 /* APM/BIOS reboot */
33424 .long pa_machine_real_restart_asm
33425 -#ifdef CONFIG_X86_64
33426 +#ifdef CONFIG_X86_32
33427 + .long __KERNEL_CS
33428 +#else
33429 .long __KERNEL32_CS
33430 #endif
33431 END(real_mode_header)
33432 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33433 index c1b2791..f9e31c7 100644
33434 --- a/arch/x86/realmode/rm/trampoline_32.S
33435 +++ b/arch/x86/realmode/rm/trampoline_32.S
33436 @@ -25,6 +25,12 @@
33437 #include <asm/page_types.h>
33438 #include "realmode.h"
33439
33440 +#ifdef CONFIG_PAX_KERNEXEC
33441 +#define ta(X) (X)
33442 +#else
33443 +#define ta(X) (pa_ ## X)
33444 +#endif
33445 +
33446 .text
33447 .code16
33448
33449 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33450
33451 cli # We should be safe anyway
33452
33453 - movl tr_start, %eax # where we need to go
33454 -
33455 movl $0xA5A5A5A5, trampoline_status
33456 # write marker for master knows we're running
33457
33458 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33459 movw $1, %dx # protected mode (PE) bit
33460 lmsw %dx # into protected mode
33461
33462 - ljmpl $__BOOT_CS, $pa_startup_32
33463 + ljmpl *(trampoline_header)
33464
33465 .section ".text32","ax"
33466 .code32
33467 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33468 .balign 8
33469 GLOBAL(trampoline_header)
33470 tr_start: .space 4
33471 - tr_gdt_pad: .space 2
33472 + tr_boot_cs: .space 2
33473 tr_gdt: .space 6
33474 END(trampoline_header)
33475
33476 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33477 index bb360dc..d0fd8f8 100644
33478 --- a/arch/x86/realmode/rm/trampoline_64.S
33479 +++ b/arch/x86/realmode/rm/trampoline_64.S
33480 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33481 movl %edx, %gs
33482
33483 movl pa_tr_cr4, %eax
33484 + andl $~X86_CR4_PCIDE, %eax
33485 movl %eax, %cr4 # Enable PAE mode
33486
33487 # Setup trampoline 4 level pagetables
33488 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33489 wrmsr
33490
33491 # Enable paging and in turn activate Long Mode
33492 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33493 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33494 movl %eax, %cr0
33495
33496 /*
33497 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33498 index e812034..c747134 100644
33499 --- a/arch/x86/tools/Makefile
33500 +++ b/arch/x86/tools/Makefile
33501 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33502
33503 $(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
33504
33505 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33506 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33507 hostprogs-y += relocs
33508 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33509 relocs: $(obj)/relocs
33510 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33511 index f7bab68..b6d9886 100644
33512 --- a/arch/x86/tools/relocs.c
33513 +++ b/arch/x86/tools/relocs.c
33514 @@ -1,5 +1,7 @@
33515 /* This is included from relocs_32/64.c */
33516
33517 +#include "../../../include/generated/autoconf.h"
33518 +
33519 #define ElfW(type) _ElfW(ELF_BITS, type)
33520 #define _ElfW(bits, type) __ElfW(bits, type)
33521 #define __ElfW(bits, type) Elf##bits##_##type
33522 @@ -11,6 +13,7 @@
33523 #define Elf_Sym ElfW(Sym)
33524
33525 static Elf_Ehdr ehdr;
33526 +static Elf_Phdr *phdr;
33527
33528 struct relocs {
33529 uint32_t *offset;
33530 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33531 }
33532 }
33533
33534 +static void read_phdrs(FILE *fp)
33535 +{
33536 + unsigned int i;
33537 +
33538 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33539 + if (!phdr) {
33540 + die("Unable to allocate %d program headers\n",
33541 + ehdr.e_phnum);
33542 + }
33543 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33544 + die("Seek to %d failed: %s\n",
33545 + ehdr.e_phoff, strerror(errno));
33546 + }
33547 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33548 + die("Cannot read ELF program headers: %s\n",
33549 + strerror(errno));
33550 + }
33551 + for(i = 0; i < ehdr.e_phnum; i++) {
33552 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33553 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33554 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33555 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33556 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33557 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33558 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33559 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33560 + }
33561 +
33562 +}
33563 +
33564 static void read_shdrs(FILE *fp)
33565 {
33566 - int i;
33567 + unsigned int i;
33568 Elf_Shdr shdr;
33569
33570 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33571 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33572
33573 static void read_strtabs(FILE *fp)
33574 {
33575 - int i;
33576 + unsigned int i;
33577 for (i = 0; i < ehdr.e_shnum; i++) {
33578 struct section *sec = &secs[i];
33579 if (sec->shdr.sh_type != SHT_STRTAB) {
33580 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33581
33582 static void read_symtabs(FILE *fp)
33583 {
33584 - int i,j;
33585 + unsigned int i,j;
33586 for (i = 0; i < ehdr.e_shnum; i++) {
33587 struct section *sec = &secs[i];
33588 if (sec->shdr.sh_type != SHT_SYMTAB) {
33589 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33590 }
33591
33592
33593 -static void read_relocs(FILE *fp)
33594 +static void read_relocs(FILE *fp, int use_real_mode)
33595 {
33596 - int i,j;
33597 + unsigned int i,j;
33598 + uint32_t base;
33599 +
33600 for (i = 0; i < ehdr.e_shnum; i++) {
33601 struct section *sec = &secs[i];
33602 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33603 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33604 die("Cannot read symbol table: %s\n",
33605 strerror(errno));
33606 }
33607 + base = 0;
33608 +
33609 +#ifdef CONFIG_X86_32
33610 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33611 + if (phdr[j].p_type != PT_LOAD )
33612 + continue;
33613 + 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)
33614 + continue;
33615 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33616 + break;
33617 + }
33618 +#endif
33619 +
33620 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33621 Elf_Rel *rel = &sec->reltab[j];
33622 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33623 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33624 rel->r_info = elf_xword_to_cpu(rel->r_info);
33625 #if (SHT_REL_TYPE == SHT_RELA)
33626 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33627 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33628
33629 static void print_absolute_symbols(void)
33630 {
33631 - int i;
33632 + unsigned int i;
33633 const char *format;
33634
33635 if (ELF_BITS == 64)
33636 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33637 for (i = 0; i < ehdr.e_shnum; i++) {
33638 struct section *sec = &secs[i];
33639 char *sym_strtab;
33640 - int j;
33641 + unsigned int j;
33642
33643 if (sec->shdr.sh_type != SHT_SYMTAB) {
33644 continue;
33645 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33646
33647 static void print_absolute_relocs(void)
33648 {
33649 - int i, printed = 0;
33650 + unsigned int i, printed = 0;
33651 const char *format;
33652
33653 if (ELF_BITS == 64)
33654 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33655 struct section *sec_applies, *sec_symtab;
33656 char *sym_strtab;
33657 Elf_Sym *sh_symtab;
33658 - int j;
33659 + unsigned int j;
33660 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33661 continue;
33662 }
33663 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33664 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33665 Elf_Sym *sym, const char *symname))
33666 {
33667 - int i;
33668 + unsigned int i;
33669 /* Walk through the relocations */
33670 for (i = 0; i < ehdr.e_shnum; i++) {
33671 char *sym_strtab;
33672 Elf_Sym *sh_symtab;
33673 struct section *sec_applies, *sec_symtab;
33674 - int j;
33675 + unsigned int j;
33676 struct section *sec = &secs[i];
33677
33678 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33679 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33680 {
33681 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33682 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33683 + char *sym_strtab = sec->link->link->strtab;
33684 +
33685 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33686 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33687 + return 0;
33688 +
33689 +#ifdef CONFIG_PAX_KERNEXEC
33690 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33691 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33692 + return 0;
33693 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33694 + return 0;
33695 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33696 + return 0;
33697 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33698 + return 0;
33699 +#endif
33700
33701 switch (r_type) {
33702 case R_386_NONE:
33703 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33704
33705 static void emit_relocs(int as_text, int use_real_mode)
33706 {
33707 - int i;
33708 + unsigned int i;
33709 int (*write_reloc)(uint32_t, FILE *) = write32;
33710 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33711 const char *symname);
33712 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33713 {
33714 regex_init(use_real_mode);
33715 read_ehdr(fp);
33716 + read_phdrs(fp);
33717 read_shdrs(fp);
33718 read_strtabs(fp);
33719 read_symtabs(fp);
33720 - read_relocs(fp);
33721 + read_relocs(fp, use_real_mode);
33722 if (ELF_BITS == 64)
33723 percpu_init();
33724 if (show_absolute_syms) {
33725 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33726 index 80ffa5b..a33bd15 100644
33727 --- a/arch/x86/um/tls_32.c
33728 +++ b/arch/x86/um/tls_32.c
33729 @@ -260,7 +260,7 @@ out:
33730 if (unlikely(task == current &&
33731 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33732 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33733 - "without flushed TLS.", current->pid);
33734 + "without flushed TLS.", task_pid_nr(current));
33735 }
33736
33737 return 0;
33738 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33739 index fd14be1..e3c79c0 100644
33740 --- a/arch/x86/vdso/Makefile
33741 +++ b/arch/x86/vdso/Makefile
33742 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33743 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33744 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33745
33746 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33747 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33748 GCOV_PROFILE := n
33749
33750 #
33751 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33752 index d6bfb87..876ee18 100644
33753 --- a/arch/x86/vdso/vdso32-setup.c
33754 +++ b/arch/x86/vdso/vdso32-setup.c
33755 @@ -25,6 +25,7 @@
33756 #include <asm/tlbflush.h>
33757 #include <asm/vdso.h>
33758 #include <asm/proto.h>
33759 +#include <asm/mman.h>
33760
33761 enum {
33762 VDSO_DISABLED = 0,
33763 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33764 void enable_sep_cpu(void)
33765 {
33766 int cpu = get_cpu();
33767 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33768 + struct tss_struct *tss = init_tss + cpu;
33769
33770 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33771 put_cpu();
33772 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33773 gate_vma.vm_start = FIXADDR_USER_START;
33774 gate_vma.vm_end = FIXADDR_USER_END;
33775 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33776 - gate_vma.vm_page_prot = __P101;
33777 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33778
33779 return 0;
33780 }
33781 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33782 if (compat)
33783 addr = VDSO_HIGH_BASE;
33784 else {
33785 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33786 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33787 if (IS_ERR_VALUE(addr)) {
33788 ret = addr;
33789 goto up_fail;
33790 }
33791 }
33792
33793 - current->mm->context.vdso = (void *)addr;
33794 + current->mm->context.vdso = addr;
33795
33796 if (compat_uses_vma || !compat) {
33797 /*
33798 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33799 }
33800
33801 current_thread_info()->sysenter_return =
33802 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33803 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33804
33805 up_fail:
33806 if (ret)
33807 - current->mm->context.vdso = NULL;
33808 + current->mm->context.vdso = 0;
33809
33810 up_write(&mm->mmap_sem);
33811
33812 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33813
33814 const char *arch_vma_name(struct vm_area_struct *vma)
33815 {
33816 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33817 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33818 return "[vdso]";
33819 +
33820 +#ifdef CONFIG_PAX_SEGMEXEC
33821 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33822 + return "[vdso]";
33823 +#endif
33824 +
33825 return NULL;
33826 }
33827
33828 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33829 * Check to see if the corresponding task was created in compat vdso
33830 * mode.
33831 */
33832 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33833 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33834 return &gate_vma;
33835 return NULL;
33836 }
33837 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33838 index 431e875..cbb23f3 100644
33839 --- a/arch/x86/vdso/vma.c
33840 +++ b/arch/x86/vdso/vma.c
33841 @@ -16,8 +16,6 @@
33842 #include <asm/vdso.h>
33843 #include <asm/page.h>
33844
33845 -unsigned int __read_mostly vdso_enabled = 1;
33846 -
33847 extern char vdso_start[], vdso_end[];
33848 extern unsigned short vdso_sync_cpuid;
33849
33850 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33851 * unaligned here as a result of stack start randomization.
33852 */
33853 addr = PAGE_ALIGN(addr);
33854 - addr = align_vdso_addr(addr);
33855
33856 return addr;
33857 }
33858 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33859 unsigned size)
33860 {
33861 struct mm_struct *mm = current->mm;
33862 - unsigned long addr;
33863 + unsigned long addr = 0;
33864 int ret;
33865
33866 - if (!vdso_enabled)
33867 - return 0;
33868 -
33869 down_write(&mm->mmap_sem);
33870 +
33871 +#ifdef CONFIG_PAX_RANDMMAP
33872 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33873 +#endif
33874 +
33875 addr = vdso_addr(mm->start_stack, size);
33876 + addr = align_vdso_addr(addr);
33877 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33878 if (IS_ERR_VALUE(addr)) {
33879 ret = addr;
33880 goto up_fail;
33881 }
33882
33883 - current->mm->context.vdso = (void *)addr;
33884 + mm->context.vdso = addr;
33885
33886 ret = install_special_mapping(mm, addr, size,
33887 VM_READ|VM_EXEC|
33888 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33889 pages);
33890 - if (ret) {
33891 - current->mm->context.vdso = NULL;
33892 - goto up_fail;
33893 - }
33894 + if (ret)
33895 + mm->context.vdso = 0;
33896
33897 up_fail:
33898 up_write(&mm->mmap_sem);
33899 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33900 vdsox32_size);
33901 }
33902 #endif
33903 -
33904 -static __init int vdso_setup(char *s)
33905 -{
33906 - vdso_enabled = simple_strtoul(s, NULL, 0);
33907 - return 0;
33908 -}
33909 -__setup("vdso=", vdso_setup);
33910 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33911 index 193097e..7590269 100644
33912 --- a/arch/x86/xen/enlighten.c
33913 +++ b/arch/x86/xen/enlighten.c
33914 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33915
33916 struct shared_info xen_dummy_shared_info;
33917
33918 -void *xen_initial_gdt;
33919 -
33920 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33921 __read_mostly int xen_have_vector_callback;
33922 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33923 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33924 {
33925 unsigned long va = dtr->address;
33926 unsigned int size = dtr->size + 1;
33927 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33928 - unsigned long frames[pages];
33929 + unsigned long frames[65536 / PAGE_SIZE];
33930 int f;
33931
33932 /*
33933 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33934 {
33935 unsigned long va = dtr->address;
33936 unsigned int size = dtr->size + 1;
33937 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33938 - unsigned long frames[pages];
33939 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33940 int f;
33941
33942 /*
33943 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33944 * 8-byte entries, or 16 4k pages..
33945 */
33946
33947 - BUG_ON(size > 65536);
33948 + BUG_ON(size > GDT_SIZE);
33949 BUG_ON(va & ~PAGE_MASK);
33950
33951 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33952 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33953 return 0;
33954 }
33955
33956 -static void set_xen_basic_apic_ops(void)
33957 +static void __init set_xen_basic_apic_ops(void)
33958 {
33959 apic->read = xen_apic_read;
33960 apic->write = xen_apic_write;
33961 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33962 #endif
33963 };
33964
33965 -static void xen_reboot(int reason)
33966 +static __noreturn void xen_reboot(int reason)
33967 {
33968 struct sched_shutdown r = { .reason = reason };
33969
33970 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
33971 - BUG();
33972 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
33973 + BUG();
33974 }
33975
33976 -static void xen_restart(char *msg)
33977 +static __noreturn void xen_restart(char *msg)
33978 {
33979 xen_reboot(SHUTDOWN_reboot);
33980 }
33981
33982 -static void xen_emergency_restart(void)
33983 +static __noreturn void xen_emergency_restart(void)
33984 {
33985 xen_reboot(SHUTDOWN_reboot);
33986 }
33987
33988 -static void xen_machine_halt(void)
33989 +static __noreturn void xen_machine_halt(void)
33990 {
33991 xen_reboot(SHUTDOWN_poweroff);
33992 }
33993
33994 -static void xen_machine_power_off(void)
33995 +static __noreturn void xen_machine_power_off(void)
33996 {
33997 if (pm_power_off)
33998 pm_power_off();
33999 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34000 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34001
34002 /* Work out if we support NX */
34003 - x86_configure_nx();
34004 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34005 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34006 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34007 + unsigned l, h;
34008 +
34009 + __supported_pte_mask |= _PAGE_NX;
34010 + rdmsr(MSR_EFER, l, h);
34011 + l |= EFER_NX;
34012 + wrmsr(MSR_EFER, l, h);
34013 + }
34014 +#endif
34015
34016 xen_setup_features();
34017
34018 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34019
34020 machine_ops = xen_machine_ops;
34021
34022 - /*
34023 - * The only reliable way to retain the initial address of the
34024 - * percpu gdt_page is to remember it here, so we can go and
34025 - * mark it RW later, when the initial percpu area is freed.
34026 - */
34027 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34028 -
34029 xen_smp_init();
34030
34031 #ifdef CONFIG_ACPI_NUMA
34032 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34033 index fdc3ba2..3daee39 100644
34034 --- a/arch/x86/xen/mmu.c
34035 +++ b/arch/x86/xen/mmu.c
34036 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34037 /* L3_k[510] -> level2_kernel_pgt
34038 * L3_i[511] -> level2_fixmap_pgt */
34039 convert_pfn_mfn(level3_kernel_pgt);
34040 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34041 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34042 + convert_pfn_mfn(level3_vmemmap_pgt);
34043
34044 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34045 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34046 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34047 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34048 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34049 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34050 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34051 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34052 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34053 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34054 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34055 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34056 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34057 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34058
34059 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34060 pv_mmu_ops.set_pud = xen_set_pud;
34061 #if PAGETABLE_LEVELS == 4
34062 pv_mmu_ops.set_pgd = xen_set_pgd;
34063 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34064 #endif
34065
34066 /* This will work as long as patching hasn't happened yet
34067 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34068 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34069 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34070 .set_pgd = xen_set_pgd_hyper,
34071 + .set_pgd_batched = xen_set_pgd_hyper,
34072
34073 .alloc_pud = xen_alloc_pmd_init,
34074 .release_pud = xen_release_pmd_init,
34075 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34076 index b81c88e..2cbe7b8 100644
34077 --- a/arch/x86/xen/smp.c
34078 +++ b/arch/x86/xen/smp.c
34079 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34080 {
34081 BUG_ON(smp_processor_id() != 0);
34082 native_smp_prepare_boot_cpu();
34083 -
34084 - /* We've switched to the "real" per-cpu gdt, so make sure the
34085 - old memory can be recycled */
34086 - make_lowmem_page_readwrite(xen_initial_gdt);
34087 -
34088 xen_filter_cpu_maps();
34089 xen_setup_vcpu_info_placement();
34090 }
34091 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34092 ctxt->user_regs.ss = __KERNEL_DS;
34093 #ifdef CONFIG_X86_32
34094 ctxt->user_regs.fs = __KERNEL_PERCPU;
34095 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34096 + savesegment(gs, ctxt->user_regs.gs);
34097 #else
34098 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34099 #endif
34100 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34101
34102 {
34103 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34104 - ctxt->user_regs.ds = __USER_DS;
34105 - ctxt->user_regs.es = __USER_DS;
34106 + ctxt->user_regs.ds = __KERNEL_DS;
34107 + ctxt->user_regs.es = __KERNEL_DS;
34108
34109 xen_copy_trap_info(ctxt->trap_ctxt);
34110
34111 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34112 int rc;
34113
34114 per_cpu(current_task, cpu) = idle;
34115 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34116 #ifdef CONFIG_X86_32
34117 irq_ctx_init(cpu);
34118 #else
34119 clear_tsk_thread_flag(idle, TIF_FORK);
34120 - per_cpu(kernel_stack, cpu) =
34121 - (unsigned long)task_stack_page(idle) -
34122 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34123 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34124 #endif
34125 xen_setup_runstate_info(cpu);
34126 xen_setup_timer(cpu);
34127 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34128
34129 void __init xen_smp_init(void)
34130 {
34131 - smp_ops = xen_smp_ops;
34132 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34133 xen_fill_possible_map();
34134 xen_init_spinlocks();
34135 }
34136 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34137 index 33ca6e4..0ded929 100644
34138 --- a/arch/x86/xen/xen-asm_32.S
34139 +++ b/arch/x86/xen/xen-asm_32.S
34140 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34141 ESP_OFFSET=4 # bytes pushed onto stack
34142
34143 /*
34144 - * Store vcpu_info pointer for easy access. Do it this way to
34145 - * avoid having to reload %fs
34146 + * Store vcpu_info pointer for easy access.
34147 */
34148 #ifdef CONFIG_SMP
34149 - GET_THREAD_INFO(%eax)
34150 - movl %ss:TI_cpu(%eax), %eax
34151 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34152 - mov %ss:xen_vcpu(%eax), %eax
34153 + push %fs
34154 + mov $(__KERNEL_PERCPU), %eax
34155 + mov %eax, %fs
34156 + mov PER_CPU_VAR(xen_vcpu), %eax
34157 + pop %fs
34158 #else
34159 movl %ss:xen_vcpu, %eax
34160 #endif
34161 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34162 index 7faed58..ba4427c 100644
34163 --- a/arch/x86/xen/xen-head.S
34164 +++ b/arch/x86/xen/xen-head.S
34165 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34166 #ifdef CONFIG_X86_32
34167 mov %esi,xen_start_info
34168 mov $init_thread_union+THREAD_SIZE,%esp
34169 +#ifdef CONFIG_SMP
34170 + movl $cpu_gdt_table,%edi
34171 + movl $__per_cpu_load,%eax
34172 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34173 + rorl $16,%eax
34174 + movb %al,__KERNEL_PERCPU + 4(%edi)
34175 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34176 + movl $__per_cpu_end - 1,%eax
34177 + subl $__per_cpu_start,%eax
34178 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34179 +#endif
34180 #else
34181 mov %rsi,xen_start_info
34182 mov $init_thread_union+THREAD_SIZE,%rsp
34183 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34184 index 86782c5..fa272c8 100644
34185 --- a/arch/x86/xen/xen-ops.h
34186 +++ b/arch/x86/xen/xen-ops.h
34187 @@ -10,8 +10,6 @@
34188 extern const char xen_hypervisor_callback[];
34189 extern const char xen_failsafe_callback[];
34190
34191 -extern void *xen_initial_gdt;
34192 -
34193 struct trap_info;
34194 void xen_copy_trap_info(struct trap_info *traps);
34195
34196 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34197 index 525bd3d..ef888b1 100644
34198 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34199 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34200 @@ -119,9 +119,9 @@
34201 ----------------------------------------------------------------------*/
34202
34203 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34204 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34205 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34206 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34207 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34208
34209 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34210 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34211 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34212 index 2f33760..835e50a 100644
34213 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34214 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34215 @@ -11,6 +11,7 @@
34216 #ifndef _XTENSA_CORE_H
34217 #define _XTENSA_CORE_H
34218
34219 +#include <linux/const.h>
34220
34221 /****************************************************************************
34222 Parameters Useful for Any Code, USER or PRIVILEGED
34223 @@ -112,9 +113,9 @@
34224 ----------------------------------------------------------------------*/
34225
34226 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34227 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34228 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34229 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34230 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34231
34232 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34233 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34234 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34235 index af00795..2bb8105 100644
34236 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34237 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34238 @@ -11,6 +11,7 @@
34239 #ifndef _XTENSA_CORE_CONFIGURATION_H
34240 #define _XTENSA_CORE_CONFIGURATION_H
34241
34242 +#include <linux/const.h>
34243
34244 /****************************************************************************
34245 Parameters Useful for Any Code, USER or PRIVILEGED
34246 @@ -118,9 +119,9 @@
34247 ----------------------------------------------------------------------*/
34248
34249 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34250 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34251 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34252 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34253 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34254
34255 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34256 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34257 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34258 index 290792a..416f287 100644
34259 --- a/block/blk-cgroup.c
34260 +++ b/block/blk-cgroup.c
34261 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34262
34263 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34264 {
34265 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34266 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34267 struct blkcg *blkcg;
34268 struct cgroup *parent = cgroup->parent;
34269
34270 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34271
34272 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34273 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34274 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34275 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34276 done:
34277 spin_lock_init(&blkcg->lock);
34278 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34279 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34280 index 4b8d9b54..ff76220 100644
34281 --- a/block/blk-iopoll.c
34282 +++ b/block/blk-iopoll.c
34283 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34284 }
34285 EXPORT_SYMBOL(blk_iopoll_complete);
34286
34287 -static void blk_iopoll_softirq(struct softirq_action *h)
34288 +static void blk_iopoll_softirq(void)
34289 {
34290 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34291 int rearm = 0, budget = blk_iopoll_budget;
34292 diff --git a/block/blk-map.c b/block/blk-map.c
34293 index 623e1cd..ca1e109 100644
34294 --- a/block/blk-map.c
34295 +++ b/block/blk-map.c
34296 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34297 if (!len || !kbuf)
34298 return -EINVAL;
34299
34300 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34301 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34302 if (do_copy)
34303 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34304 else
34305 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34306 index ec9e606..2244d4e 100644
34307 --- a/block/blk-softirq.c
34308 +++ b/block/blk-softirq.c
34309 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34310 * Softirq action handler - move entries to local list and loop over them
34311 * while passing them to the queue registered handler.
34312 */
34313 -static void blk_done_softirq(struct softirq_action *h)
34314 +static void blk_done_softirq(void)
34315 {
34316 struct list_head *cpu_list, local_list;
34317
34318 diff --git a/block/bsg.c b/block/bsg.c
34319 index 420a5a9..23834aa 100644
34320 --- a/block/bsg.c
34321 +++ b/block/bsg.c
34322 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34323 struct sg_io_v4 *hdr, struct bsg_device *bd,
34324 fmode_t has_write_perm)
34325 {
34326 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34327 + unsigned char *cmdptr;
34328 +
34329 if (hdr->request_len > BLK_MAX_CDB) {
34330 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34331 if (!rq->cmd)
34332 return -ENOMEM;
34333 - }
34334 + cmdptr = rq->cmd;
34335 + } else
34336 + cmdptr = tmpcmd;
34337
34338 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34339 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34340 hdr->request_len))
34341 return -EFAULT;
34342
34343 + if (cmdptr != rq->cmd)
34344 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34345 +
34346 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34347 if (blk_verify_command(rq->cmd, has_write_perm))
34348 return -EPERM;
34349 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34350 index 7e5d474..0cf0017 100644
34351 --- a/block/compat_ioctl.c
34352 +++ b/block/compat_ioctl.c
34353 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34354 err |= __get_user(f->spec1, &uf->spec1);
34355 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34356 err |= __get_user(name, &uf->name);
34357 - f->name = compat_ptr(name);
34358 + f->name = (void __force_kernel *)compat_ptr(name);
34359 if (err) {
34360 err = -EFAULT;
34361 goto out;
34362 diff --git a/block/genhd.c b/block/genhd.c
34363 index dadf42b..48dc887 100644
34364 --- a/block/genhd.c
34365 +++ b/block/genhd.c
34366 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34367
34368 /*
34369 * Register device numbers dev..(dev+range-1)
34370 - * range must be nonzero
34371 + * Noop if @range is zero.
34372 * The hash chain is sorted on range, so that subranges can override.
34373 */
34374 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34375 struct kobject *(*probe)(dev_t, int *, void *),
34376 int (*lock)(dev_t, void *), void *data)
34377 {
34378 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34379 + if (range)
34380 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34381 }
34382
34383 EXPORT_SYMBOL(blk_register_region);
34384
34385 +/* undo blk_register_region(), noop if @range is zero */
34386 void blk_unregister_region(dev_t devt, unsigned long range)
34387 {
34388 - kobj_unmap(bdev_map, devt, range);
34389 + if (range)
34390 + kobj_unmap(bdev_map, devt, range);
34391 }
34392
34393 EXPORT_SYMBOL(blk_unregister_region);
34394 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34395 index c85fc89..51e690b 100644
34396 --- a/block/partitions/efi.c
34397 +++ b/block/partitions/efi.c
34398 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34399 if (!gpt)
34400 return NULL;
34401
34402 + if (!le32_to_cpu(gpt->num_partition_entries))
34403 + return NULL;
34404 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34405 + if (!pte)
34406 + return NULL;
34407 +
34408 count = le32_to_cpu(gpt->num_partition_entries) *
34409 le32_to_cpu(gpt->sizeof_partition_entry);
34410 - if (!count)
34411 - return NULL;
34412 - pte = kmalloc(count, GFP_KERNEL);
34413 - if (!pte)
34414 - return NULL;
34415 -
34416 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34417 (u8 *) pte,
34418 count) < count) {
34419 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34420 index a5ffcc9..3cedc9c 100644
34421 --- a/block/scsi_ioctl.c
34422 +++ b/block/scsi_ioctl.c
34423 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34424 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34425 struct sg_io_hdr *hdr, fmode_t mode)
34426 {
34427 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34428 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34429 + unsigned char *cmdptr;
34430 +
34431 + if (rq->cmd != rq->__cmd)
34432 + cmdptr = rq->cmd;
34433 + else
34434 + cmdptr = tmpcmd;
34435 +
34436 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34437 return -EFAULT;
34438 +
34439 + if (cmdptr != rq->cmd)
34440 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34441 +
34442 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34443 return -EPERM;
34444
34445 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34446 int err;
34447 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34448 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34449 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34450 + unsigned char *cmdptr;
34451
34452 if (!sic)
34453 return -EINVAL;
34454 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34455 */
34456 err = -EFAULT;
34457 rq->cmd_len = cmdlen;
34458 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34459 +
34460 + if (rq->cmd != rq->__cmd)
34461 + cmdptr = rq->cmd;
34462 + else
34463 + cmdptr = tmpcmd;
34464 +
34465 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34466 goto error;
34467
34468 + if (rq->cmd != cmdptr)
34469 + memcpy(rq->cmd, cmdptr, cmdlen);
34470 +
34471 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34472 goto error;
34473
34474 diff --git a/crypto/api.c b/crypto/api.c
34475 index 3b61803..37c4c72 100644
34476 --- a/crypto/api.c
34477 +++ b/crypto/api.c
34478 @@ -34,6 +34,8 @@ EXPORT_SYMBOL_GPL(crypto_alg_sem);
34479 BLOCKING_NOTIFIER_HEAD(crypto_chain);
34480 EXPORT_SYMBOL_GPL(crypto_chain);
34481
34482 +static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg);
34483 +
34484 struct crypto_alg *crypto_mod_get(struct crypto_alg *alg)
34485 {
34486 return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL;
34487 @@ -144,8 +146,11 @@ static struct crypto_alg *crypto_larval_add(const char *name, u32 type,
34488 }
34489 up_write(&crypto_alg_sem);
34490
34491 - if (alg != &larval->alg)
34492 + if (alg != &larval->alg) {
34493 kfree(larval);
34494 + if (crypto_is_larval(alg))
34495 + alg = crypto_larval_wait(alg);
34496 + }
34497
34498 return alg;
34499 }
34500 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34501 index 7bdd61b..afec999 100644
34502 --- a/crypto/cryptd.c
34503 +++ b/crypto/cryptd.c
34504 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34505
34506 struct cryptd_blkcipher_request_ctx {
34507 crypto_completion_t complete;
34508 -};
34509 +} __no_const;
34510
34511 struct cryptd_hash_ctx {
34512 struct crypto_shash *child;
34513 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34514
34515 struct cryptd_aead_request_ctx {
34516 crypto_completion_t complete;
34517 -};
34518 +} __no_const;
34519
34520 static void cryptd_queue_worker(struct work_struct *work);
34521
34522 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34523 index f8c920c..ab2cb5a 100644
34524 --- a/crypto/pcrypt.c
34525 +++ b/crypto/pcrypt.c
34526 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34527 int ret;
34528
34529 pinst->kobj.kset = pcrypt_kset;
34530 - ret = kobject_add(&pinst->kobj, NULL, name);
34531 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34532 if (!ret)
34533 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34534
34535 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34536 index f220d64..d359ad6 100644
34537 --- a/drivers/acpi/apei/apei-internal.h
34538 +++ b/drivers/acpi/apei/apei-internal.h
34539 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34540 struct apei_exec_ins_type {
34541 u32 flags;
34542 apei_exec_ins_func_t run;
34543 -};
34544 +} __do_const;
34545
34546 struct apei_exec_context {
34547 u32 ip;
34548 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34549 index 33dc6a0..4b24b47 100644
34550 --- a/drivers/acpi/apei/cper.c
34551 +++ b/drivers/acpi/apei/cper.c
34552 @@ -39,12 +39,12 @@
34553 */
34554 u64 cper_next_record_id(void)
34555 {
34556 - static atomic64_t seq;
34557 + static atomic64_unchecked_t seq;
34558
34559 - if (!atomic64_read(&seq))
34560 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34561 + if (!atomic64_read_unchecked(&seq))
34562 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34563
34564 - return atomic64_inc_return(&seq);
34565 + return atomic64_inc_return_unchecked(&seq);
34566 }
34567 EXPORT_SYMBOL_GPL(cper_next_record_id);
34568
34569 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34570 index ec9b57d..9682b3a 100644
34571 --- a/drivers/acpi/apei/ghes.c
34572 +++ b/drivers/acpi/apei/ghes.c
34573 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34574 const struct acpi_hest_generic *generic,
34575 const struct acpi_hest_generic_status *estatus)
34576 {
34577 - static atomic_t seqno;
34578 + static atomic_unchecked_t seqno;
34579 unsigned int curr_seqno;
34580 char pfx_seq[64];
34581
34582 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34583 else
34584 pfx = KERN_ERR;
34585 }
34586 - curr_seqno = atomic_inc_return(&seqno);
34587 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34588 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34589 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34590 pfx_seq, generic->header.source_id);
34591 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34592 index be60399..778b33e8 100644
34593 --- a/drivers/acpi/bgrt.c
34594 +++ b/drivers/acpi/bgrt.c
34595 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34596 return -ENODEV;
34597
34598 sysfs_bin_attr_init(&image_attr);
34599 - image_attr.private = bgrt_image;
34600 - image_attr.size = bgrt_image_size;
34601 + pax_open_kernel();
34602 + *(void **)&image_attr.private = bgrt_image;
34603 + *(size_t *)&image_attr.size = bgrt_image_size;
34604 + pax_close_kernel();
34605
34606 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34607 if (!bgrt_kobj)
34608 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34609 index cb96296..b81293b 100644
34610 --- a/drivers/acpi/blacklist.c
34611 +++ b/drivers/acpi/blacklist.c
34612 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34613 u32 is_critical_error;
34614 };
34615
34616 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34617 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34618
34619 /*
34620 * POLICY: If *anything* doesn't work, put it on the blacklist.
34621 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34622 return 0;
34623 }
34624
34625 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34626 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34627 {
34628 .callback = dmi_disable_osi_vista,
34629 .ident = "Fujitsu Siemens",
34630 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34631 index f98dd00..7b69865 100644
34632 --- a/drivers/acpi/processor_idle.c
34633 +++ b/drivers/acpi/processor_idle.c
34634 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34635 {
34636 int i, count = CPUIDLE_DRIVER_STATE_START;
34637 struct acpi_processor_cx *cx;
34638 - struct cpuidle_state *state;
34639 + cpuidle_state_no_const *state;
34640 struct cpuidle_driver *drv = &acpi_idle_driver;
34641
34642 if (!pr->flags.power_setup_done)
34643 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34644 index 05306a5..733d1f0 100644
34645 --- a/drivers/acpi/sysfs.c
34646 +++ b/drivers/acpi/sysfs.c
34647 @@ -423,11 +423,11 @@ static u32 num_counters;
34648 static struct attribute **all_attrs;
34649 static u32 acpi_gpe_count;
34650
34651 -static struct attribute_group interrupt_stats_attr_group = {
34652 +static attribute_group_no_const interrupt_stats_attr_group = {
34653 .name = "interrupts",
34654 };
34655
34656 -static struct kobj_attribute *counter_attrs;
34657 +static kobj_attribute_no_const *counter_attrs;
34658
34659 static void delete_gpe_attr_array(void)
34660 {
34661 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34662 index acfd0f7..e5acb08 100644
34663 --- a/drivers/ata/libahci.c
34664 +++ b/drivers/ata/libahci.c
34665 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34666 }
34667 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34668
34669 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34670 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34671 struct ata_taskfile *tf, int is_cmd, u16 flags,
34672 unsigned long timeout_msec)
34673 {
34674 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34675 index c24354d..335c975 100644
34676 --- a/drivers/ata/libata-core.c
34677 +++ b/drivers/ata/libata-core.c
34678 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34679 static void ata_dev_xfermask(struct ata_device *dev);
34680 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34681
34682 -atomic_t ata_print_id = ATOMIC_INIT(0);
34683 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34684
34685 struct ata_force_param {
34686 const char *name;
34687 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34688 struct ata_port *ap;
34689 unsigned int tag;
34690
34691 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34692 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34693 ap = qc->ap;
34694
34695 qc->flags = 0;
34696 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34697 struct ata_port *ap;
34698 struct ata_link *link;
34699
34700 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34701 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34702 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34703 ap = qc->ap;
34704 link = qc->dev->link;
34705 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34706 return;
34707
34708 spin_lock(&lock);
34709 + pax_open_kernel();
34710
34711 for (cur = ops->inherits; cur; cur = cur->inherits) {
34712 void **inherit = (void **)cur;
34713 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34714 if (IS_ERR(*pp))
34715 *pp = NULL;
34716
34717 - ops->inherits = NULL;
34718 + *(struct ata_port_operations **)&ops->inherits = NULL;
34719
34720 + pax_close_kernel();
34721 spin_unlock(&lock);
34722 }
34723
34724 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34725
34726 /* give ports names and add SCSI hosts */
34727 for (i = 0; i < host->n_ports; i++) {
34728 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34729 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34730 host->ports[i]->local_port_no = i + 1;
34731 }
34732
34733 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34734 index b1e880a..8cf82e1 100644
34735 --- a/drivers/ata/libata-scsi.c
34736 +++ b/drivers/ata/libata-scsi.c
34737 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34738
34739 if (rc)
34740 return rc;
34741 - ap->print_id = atomic_inc_return(&ata_print_id);
34742 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34743 return 0;
34744 }
34745 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34746 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34747 index 577d902b..cb4781e 100644
34748 --- a/drivers/ata/libata.h
34749 +++ b/drivers/ata/libata.h
34750 @@ -53,7 +53,7 @@ enum {
34751 ATA_DNXFER_QUIET = (1 << 31),
34752 };
34753
34754 -extern atomic_t ata_print_id;
34755 +extern atomic_unchecked_t ata_print_id;
34756 extern int atapi_passthru16;
34757 extern int libata_fua;
34758 extern int libata_noacpi;
34759 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34760 index 848ed32..132f39d 100644
34761 --- a/drivers/ata/pata_arasan_cf.c
34762 +++ b/drivers/ata/pata_arasan_cf.c
34763 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34764 /* Handle platform specific quirks */
34765 if (quirk) {
34766 if (quirk & CF_BROKEN_PIO) {
34767 - ap->ops->set_piomode = NULL;
34768 + pax_open_kernel();
34769 + *(void **)&ap->ops->set_piomode = NULL;
34770 + pax_close_kernel();
34771 ap->pio_mask = 0;
34772 }
34773 if (quirk & CF_BROKEN_MWDMA)
34774 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34775 index f9b983a..887b9d8 100644
34776 --- a/drivers/atm/adummy.c
34777 +++ b/drivers/atm/adummy.c
34778 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34779 vcc->pop(vcc, skb);
34780 else
34781 dev_kfree_skb_any(skb);
34782 - atomic_inc(&vcc->stats->tx);
34783 + atomic_inc_unchecked(&vcc->stats->tx);
34784
34785 return 0;
34786 }
34787 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34788 index 62a7607..cc4be104 100644
34789 --- a/drivers/atm/ambassador.c
34790 +++ b/drivers/atm/ambassador.c
34791 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34792 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34793
34794 // VC layer stats
34795 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34796 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34797
34798 // free the descriptor
34799 kfree (tx_descr);
34800 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34801 dump_skb ("<<<", vc, skb);
34802
34803 // VC layer stats
34804 - atomic_inc(&atm_vcc->stats->rx);
34805 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34806 __net_timestamp(skb);
34807 // end of our responsibility
34808 atm_vcc->push (atm_vcc, skb);
34809 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34810 } else {
34811 PRINTK (KERN_INFO, "dropped over-size frame");
34812 // should we count this?
34813 - atomic_inc(&atm_vcc->stats->rx_drop);
34814 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34815 }
34816
34817 } else {
34818 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34819 }
34820
34821 if (check_area (skb->data, skb->len)) {
34822 - atomic_inc(&atm_vcc->stats->tx_err);
34823 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34824 return -ENOMEM; // ?
34825 }
34826
34827 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34828 index 0e3f8f9..765a7a5 100644
34829 --- a/drivers/atm/atmtcp.c
34830 +++ b/drivers/atm/atmtcp.c
34831 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34832 if (vcc->pop) vcc->pop(vcc,skb);
34833 else dev_kfree_skb(skb);
34834 if (dev_data) return 0;
34835 - atomic_inc(&vcc->stats->tx_err);
34836 + atomic_inc_unchecked(&vcc->stats->tx_err);
34837 return -ENOLINK;
34838 }
34839 size = skb->len+sizeof(struct atmtcp_hdr);
34840 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34841 if (!new_skb) {
34842 if (vcc->pop) vcc->pop(vcc,skb);
34843 else dev_kfree_skb(skb);
34844 - atomic_inc(&vcc->stats->tx_err);
34845 + atomic_inc_unchecked(&vcc->stats->tx_err);
34846 return -ENOBUFS;
34847 }
34848 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34849 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34850 if (vcc->pop) vcc->pop(vcc,skb);
34851 else dev_kfree_skb(skb);
34852 out_vcc->push(out_vcc,new_skb);
34853 - atomic_inc(&vcc->stats->tx);
34854 - atomic_inc(&out_vcc->stats->rx);
34855 + atomic_inc_unchecked(&vcc->stats->tx);
34856 + atomic_inc_unchecked(&out_vcc->stats->rx);
34857 return 0;
34858 }
34859
34860 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34861 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34862 read_unlock(&vcc_sklist_lock);
34863 if (!out_vcc) {
34864 - atomic_inc(&vcc->stats->tx_err);
34865 + atomic_inc_unchecked(&vcc->stats->tx_err);
34866 goto done;
34867 }
34868 skb_pull(skb,sizeof(struct atmtcp_hdr));
34869 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34870 __net_timestamp(new_skb);
34871 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34872 out_vcc->push(out_vcc,new_skb);
34873 - atomic_inc(&vcc->stats->tx);
34874 - atomic_inc(&out_vcc->stats->rx);
34875 + atomic_inc_unchecked(&vcc->stats->tx);
34876 + atomic_inc_unchecked(&out_vcc->stats->rx);
34877 done:
34878 if (vcc->pop) vcc->pop(vcc,skb);
34879 else dev_kfree_skb(skb);
34880 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34881 index b1955ba..b179940 100644
34882 --- a/drivers/atm/eni.c
34883 +++ b/drivers/atm/eni.c
34884 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34885 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34886 vcc->dev->number);
34887 length = 0;
34888 - atomic_inc(&vcc->stats->rx_err);
34889 + atomic_inc_unchecked(&vcc->stats->rx_err);
34890 }
34891 else {
34892 length = ATM_CELL_SIZE-1; /* no HEC */
34893 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34894 size);
34895 }
34896 eff = length = 0;
34897 - atomic_inc(&vcc->stats->rx_err);
34898 + atomic_inc_unchecked(&vcc->stats->rx_err);
34899 }
34900 else {
34901 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34902 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34903 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34904 vcc->dev->number,vcc->vci,length,size << 2,descr);
34905 length = eff = 0;
34906 - atomic_inc(&vcc->stats->rx_err);
34907 + atomic_inc_unchecked(&vcc->stats->rx_err);
34908 }
34909 }
34910 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34911 @@ -767,7 +767,7 @@ rx_dequeued++;
34912 vcc->push(vcc,skb);
34913 pushed++;
34914 }
34915 - atomic_inc(&vcc->stats->rx);
34916 + atomic_inc_unchecked(&vcc->stats->rx);
34917 }
34918 wake_up(&eni_dev->rx_wait);
34919 }
34920 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34921 PCI_DMA_TODEVICE);
34922 if (vcc->pop) vcc->pop(vcc,skb);
34923 else dev_kfree_skb_irq(skb);
34924 - atomic_inc(&vcc->stats->tx);
34925 + atomic_inc_unchecked(&vcc->stats->tx);
34926 wake_up(&eni_dev->tx_wait);
34927 dma_complete++;
34928 }
34929 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34930 index b41c948..a002b17 100644
34931 --- a/drivers/atm/firestream.c
34932 +++ b/drivers/atm/firestream.c
34933 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34934 }
34935 }
34936
34937 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34938 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34939
34940 fs_dprintk (FS_DEBUG_TXMEM, "i");
34941 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34942 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34943 #endif
34944 skb_put (skb, qe->p1 & 0xffff);
34945 ATM_SKB(skb)->vcc = atm_vcc;
34946 - atomic_inc(&atm_vcc->stats->rx);
34947 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34948 __net_timestamp(skb);
34949 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34950 atm_vcc->push (atm_vcc, skb);
34951 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34952 kfree (pe);
34953 }
34954 if (atm_vcc)
34955 - atomic_inc(&atm_vcc->stats->rx_drop);
34956 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34957 break;
34958 case 0x1f: /* Reassembly abort: no buffers. */
34959 /* Silently increment error counter. */
34960 if (atm_vcc)
34961 - atomic_inc(&atm_vcc->stats->rx_drop);
34962 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34963 break;
34964 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34965 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34966 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34967 index 204814e..cede831 100644
34968 --- a/drivers/atm/fore200e.c
34969 +++ b/drivers/atm/fore200e.c
34970 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34971 #endif
34972 /* check error condition */
34973 if (*entry->status & STATUS_ERROR)
34974 - atomic_inc(&vcc->stats->tx_err);
34975 + atomic_inc_unchecked(&vcc->stats->tx_err);
34976 else
34977 - atomic_inc(&vcc->stats->tx);
34978 + atomic_inc_unchecked(&vcc->stats->tx);
34979 }
34980 }
34981
34982 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34983 if (skb == NULL) {
34984 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
34985
34986 - atomic_inc(&vcc->stats->rx_drop);
34987 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34988 return -ENOMEM;
34989 }
34990
34991 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34992
34993 dev_kfree_skb_any(skb);
34994
34995 - atomic_inc(&vcc->stats->rx_drop);
34996 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34997 return -ENOMEM;
34998 }
34999
35000 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35001
35002 vcc->push(vcc, skb);
35003 - atomic_inc(&vcc->stats->rx);
35004 + atomic_inc_unchecked(&vcc->stats->rx);
35005
35006 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35007
35008 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35009 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35010 fore200e->atm_dev->number,
35011 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35012 - atomic_inc(&vcc->stats->rx_err);
35013 + atomic_inc_unchecked(&vcc->stats->rx_err);
35014 }
35015 }
35016
35017 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35018 goto retry_here;
35019 }
35020
35021 - atomic_inc(&vcc->stats->tx_err);
35022 + atomic_inc_unchecked(&vcc->stats->tx_err);
35023
35024 fore200e->tx_sat++;
35025 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35026 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35027 index 507362a..a845e57 100644
35028 --- a/drivers/atm/he.c
35029 +++ b/drivers/atm/he.c
35030 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35031
35032 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35033 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35034 - atomic_inc(&vcc->stats->rx_drop);
35035 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35036 goto return_host_buffers;
35037 }
35038
35039 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35040 RBRQ_LEN_ERR(he_dev->rbrq_head)
35041 ? "LEN_ERR" : "",
35042 vcc->vpi, vcc->vci);
35043 - atomic_inc(&vcc->stats->rx_err);
35044 + atomic_inc_unchecked(&vcc->stats->rx_err);
35045 goto return_host_buffers;
35046 }
35047
35048 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35049 vcc->push(vcc, skb);
35050 spin_lock(&he_dev->global_lock);
35051
35052 - atomic_inc(&vcc->stats->rx);
35053 + atomic_inc_unchecked(&vcc->stats->rx);
35054
35055 return_host_buffers:
35056 ++pdus_assembled;
35057 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35058 tpd->vcc->pop(tpd->vcc, tpd->skb);
35059 else
35060 dev_kfree_skb_any(tpd->skb);
35061 - atomic_inc(&tpd->vcc->stats->tx_err);
35062 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35063 }
35064 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35065 return;
35066 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35067 vcc->pop(vcc, skb);
35068 else
35069 dev_kfree_skb_any(skb);
35070 - atomic_inc(&vcc->stats->tx_err);
35071 + atomic_inc_unchecked(&vcc->stats->tx_err);
35072 return -EINVAL;
35073 }
35074
35075 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35076 vcc->pop(vcc, skb);
35077 else
35078 dev_kfree_skb_any(skb);
35079 - atomic_inc(&vcc->stats->tx_err);
35080 + atomic_inc_unchecked(&vcc->stats->tx_err);
35081 return -EINVAL;
35082 }
35083 #endif
35084 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35085 vcc->pop(vcc, skb);
35086 else
35087 dev_kfree_skb_any(skb);
35088 - atomic_inc(&vcc->stats->tx_err);
35089 + atomic_inc_unchecked(&vcc->stats->tx_err);
35090 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35091 return -ENOMEM;
35092 }
35093 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35094 vcc->pop(vcc, skb);
35095 else
35096 dev_kfree_skb_any(skb);
35097 - atomic_inc(&vcc->stats->tx_err);
35098 + atomic_inc_unchecked(&vcc->stats->tx_err);
35099 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35100 return -ENOMEM;
35101 }
35102 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35103 __enqueue_tpd(he_dev, tpd, cid);
35104 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35105
35106 - atomic_inc(&vcc->stats->tx);
35107 + atomic_inc_unchecked(&vcc->stats->tx);
35108
35109 return 0;
35110 }
35111 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35112 index 1dc0519..1aadaf7 100644
35113 --- a/drivers/atm/horizon.c
35114 +++ b/drivers/atm/horizon.c
35115 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35116 {
35117 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35118 // VC layer stats
35119 - atomic_inc(&vcc->stats->rx);
35120 + atomic_inc_unchecked(&vcc->stats->rx);
35121 __net_timestamp(skb);
35122 // end of our responsibility
35123 vcc->push (vcc, skb);
35124 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35125 dev->tx_iovec = NULL;
35126
35127 // VC layer stats
35128 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35129 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35130
35131 // free the skb
35132 hrz_kfree_skb (skb);
35133 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35134 index 272f009..a18ba55 100644
35135 --- a/drivers/atm/idt77252.c
35136 +++ b/drivers/atm/idt77252.c
35137 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35138 else
35139 dev_kfree_skb(skb);
35140
35141 - atomic_inc(&vcc->stats->tx);
35142 + atomic_inc_unchecked(&vcc->stats->tx);
35143 }
35144
35145 atomic_dec(&scq->used);
35146 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35147 if ((sb = dev_alloc_skb(64)) == NULL) {
35148 printk("%s: Can't allocate buffers for aal0.\n",
35149 card->name);
35150 - atomic_add(i, &vcc->stats->rx_drop);
35151 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35152 break;
35153 }
35154 if (!atm_charge(vcc, sb->truesize)) {
35155 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35156 card->name);
35157 - atomic_add(i - 1, &vcc->stats->rx_drop);
35158 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35159 dev_kfree_skb(sb);
35160 break;
35161 }
35162 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35163 ATM_SKB(sb)->vcc = vcc;
35164 __net_timestamp(sb);
35165 vcc->push(vcc, sb);
35166 - atomic_inc(&vcc->stats->rx);
35167 + atomic_inc_unchecked(&vcc->stats->rx);
35168
35169 cell += ATM_CELL_PAYLOAD;
35170 }
35171 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35172 "(CDC: %08x)\n",
35173 card->name, len, rpp->len, readl(SAR_REG_CDC));
35174 recycle_rx_pool_skb(card, rpp);
35175 - atomic_inc(&vcc->stats->rx_err);
35176 + atomic_inc_unchecked(&vcc->stats->rx_err);
35177 return;
35178 }
35179 if (stat & SAR_RSQE_CRC) {
35180 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35181 recycle_rx_pool_skb(card, rpp);
35182 - atomic_inc(&vcc->stats->rx_err);
35183 + atomic_inc_unchecked(&vcc->stats->rx_err);
35184 return;
35185 }
35186 if (skb_queue_len(&rpp->queue) > 1) {
35187 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35188 RXPRINTK("%s: Can't alloc RX skb.\n",
35189 card->name);
35190 recycle_rx_pool_skb(card, rpp);
35191 - atomic_inc(&vcc->stats->rx_err);
35192 + atomic_inc_unchecked(&vcc->stats->rx_err);
35193 return;
35194 }
35195 if (!atm_charge(vcc, skb->truesize)) {
35196 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35197 __net_timestamp(skb);
35198
35199 vcc->push(vcc, skb);
35200 - atomic_inc(&vcc->stats->rx);
35201 + atomic_inc_unchecked(&vcc->stats->rx);
35202
35203 return;
35204 }
35205 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35206 __net_timestamp(skb);
35207
35208 vcc->push(vcc, skb);
35209 - atomic_inc(&vcc->stats->rx);
35210 + atomic_inc_unchecked(&vcc->stats->rx);
35211
35212 if (skb->truesize > SAR_FB_SIZE_3)
35213 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35214 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35215 if (vcc->qos.aal != ATM_AAL0) {
35216 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35217 card->name, vpi, vci);
35218 - atomic_inc(&vcc->stats->rx_drop);
35219 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35220 goto drop;
35221 }
35222
35223 if ((sb = dev_alloc_skb(64)) == NULL) {
35224 printk("%s: Can't allocate buffers for AAL0.\n",
35225 card->name);
35226 - atomic_inc(&vcc->stats->rx_err);
35227 + atomic_inc_unchecked(&vcc->stats->rx_err);
35228 goto drop;
35229 }
35230
35231 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35232 ATM_SKB(sb)->vcc = vcc;
35233 __net_timestamp(sb);
35234 vcc->push(vcc, sb);
35235 - atomic_inc(&vcc->stats->rx);
35236 + atomic_inc_unchecked(&vcc->stats->rx);
35237
35238 drop:
35239 skb_pull(queue, 64);
35240 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35241
35242 if (vc == NULL) {
35243 printk("%s: NULL connection in send().\n", card->name);
35244 - atomic_inc(&vcc->stats->tx_err);
35245 + atomic_inc_unchecked(&vcc->stats->tx_err);
35246 dev_kfree_skb(skb);
35247 return -EINVAL;
35248 }
35249 if (!test_bit(VCF_TX, &vc->flags)) {
35250 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35251 - atomic_inc(&vcc->stats->tx_err);
35252 + atomic_inc_unchecked(&vcc->stats->tx_err);
35253 dev_kfree_skb(skb);
35254 return -EINVAL;
35255 }
35256 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35257 break;
35258 default:
35259 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35260 - atomic_inc(&vcc->stats->tx_err);
35261 + atomic_inc_unchecked(&vcc->stats->tx_err);
35262 dev_kfree_skb(skb);
35263 return -EINVAL;
35264 }
35265
35266 if (skb_shinfo(skb)->nr_frags != 0) {
35267 printk("%s: No scatter-gather yet.\n", card->name);
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 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35274
35275 err = queue_skb(card, vc, skb, oam);
35276 if (err) {
35277 - atomic_inc(&vcc->stats->tx_err);
35278 + atomic_inc_unchecked(&vcc->stats->tx_err);
35279 dev_kfree_skb(skb);
35280 return err;
35281 }
35282 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35283 skb = dev_alloc_skb(64);
35284 if (!skb) {
35285 printk("%s: Out of memory in send_oam().\n", card->name);
35286 - atomic_inc(&vcc->stats->tx_err);
35287 + atomic_inc_unchecked(&vcc->stats->tx_err);
35288 return -ENOMEM;
35289 }
35290 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35291 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35292 index 4217f29..88f547a 100644
35293 --- a/drivers/atm/iphase.c
35294 +++ b/drivers/atm/iphase.c
35295 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35296 status = (u_short) (buf_desc_ptr->desc_mode);
35297 if (status & (RX_CER | RX_PTE | RX_OFL))
35298 {
35299 - atomic_inc(&vcc->stats->rx_err);
35300 + atomic_inc_unchecked(&vcc->stats->rx_err);
35301 IF_ERR(printk("IA: bad packet, dropping it");)
35302 if (status & RX_CER) {
35303 IF_ERR(printk(" cause: packet CRC error\n");)
35304 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35305 len = dma_addr - buf_addr;
35306 if (len > iadev->rx_buf_sz) {
35307 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35308 - atomic_inc(&vcc->stats->rx_err);
35309 + atomic_inc_unchecked(&vcc->stats->rx_err);
35310 goto out_free_desc;
35311 }
35312
35313 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35314 ia_vcc = INPH_IA_VCC(vcc);
35315 if (ia_vcc == NULL)
35316 {
35317 - atomic_inc(&vcc->stats->rx_err);
35318 + atomic_inc_unchecked(&vcc->stats->rx_err);
35319 atm_return(vcc, skb->truesize);
35320 dev_kfree_skb_any(skb);
35321 goto INCR_DLE;
35322 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35323 if ((length > iadev->rx_buf_sz) || (length >
35324 (skb->len - sizeof(struct cpcs_trailer))))
35325 {
35326 - atomic_inc(&vcc->stats->rx_err);
35327 + atomic_inc_unchecked(&vcc->stats->rx_err);
35328 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35329 length, skb->len);)
35330 atm_return(vcc, skb->truesize);
35331 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35332
35333 IF_RX(printk("rx_dle_intr: skb push");)
35334 vcc->push(vcc,skb);
35335 - atomic_inc(&vcc->stats->rx);
35336 + atomic_inc_unchecked(&vcc->stats->rx);
35337 iadev->rx_pkt_cnt++;
35338 }
35339 INCR_DLE:
35340 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35341 {
35342 struct k_sonet_stats *stats;
35343 stats = &PRIV(_ia_dev[board])->sonet_stats;
35344 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35345 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35346 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35347 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35348 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35349 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35350 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35351 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35352 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35353 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35354 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35355 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35356 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35357 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35358 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35359 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35360 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35361 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35362 }
35363 ia_cmds.status = 0;
35364 break;
35365 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35366 if ((desc == 0) || (desc > iadev->num_tx_desc))
35367 {
35368 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35369 - atomic_inc(&vcc->stats->tx);
35370 + atomic_inc_unchecked(&vcc->stats->tx);
35371 if (vcc->pop)
35372 vcc->pop(vcc, skb);
35373 else
35374 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35375 ATM_DESC(skb) = vcc->vci;
35376 skb_queue_tail(&iadev->tx_dma_q, skb);
35377
35378 - atomic_inc(&vcc->stats->tx);
35379 + atomic_inc_unchecked(&vcc->stats->tx);
35380 iadev->tx_pkt_cnt++;
35381 /* Increment transaction counter */
35382 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35383
35384 #if 0
35385 /* add flow control logic */
35386 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35387 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35388 if (iavcc->vc_desc_cnt > 10) {
35389 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35390 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35391 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35392 index fa7d701..1e404c7 100644
35393 --- a/drivers/atm/lanai.c
35394 +++ b/drivers/atm/lanai.c
35395 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35396 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35397 lanai_endtx(lanai, lvcc);
35398 lanai_free_skb(lvcc->tx.atmvcc, skb);
35399 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35400 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35401 }
35402
35403 /* Try to fill the buffer - don't call unless there is backlog */
35404 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35405 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35406 __net_timestamp(skb);
35407 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35408 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35409 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35410 out:
35411 lvcc->rx.buf.ptr = end;
35412 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35413 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35414 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35415 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35416 lanai->stats.service_rxnotaal5++;
35417 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35418 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35419 return 0;
35420 }
35421 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35422 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35423 int bytes;
35424 read_unlock(&vcc_sklist_lock);
35425 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35426 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35427 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35428 lvcc->stats.x.aal5.service_trash++;
35429 bytes = (SERVICE_GET_END(s) * 16) -
35430 (((unsigned long) lvcc->rx.buf.ptr) -
35431 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35432 }
35433 if (s & SERVICE_STREAM) {
35434 read_unlock(&vcc_sklist_lock);
35435 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35436 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35437 lvcc->stats.x.aal5.service_stream++;
35438 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35439 "PDU on VCI %d!\n", lanai->number, vci);
35440 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35441 return 0;
35442 }
35443 DPRINTK("got rx crc error on vci %d\n", vci);
35444 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35445 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35446 lvcc->stats.x.aal5.service_rxcrc++;
35447 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35448 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35449 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35450 index 6587dc2..149833d 100644
35451 --- a/drivers/atm/nicstar.c
35452 +++ b/drivers/atm/nicstar.c
35453 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35454 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35455 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35456 card->index);
35457 - atomic_inc(&vcc->stats->tx_err);
35458 + atomic_inc_unchecked(&vcc->stats->tx_err);
35459 dev_kfree_skb_any(skb);
35460 return -EINVAL;
35461 }
35462 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35463 if (!vc->tx) {
35464 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35465 card->index);
35466 - atomic_inc(&vcc->stats->tx_err);
35467 + atomic_inc_unchecked(&vcc->stats->tx_err);
35468 dev_kfree_skb_any(skb);
35469 return -EINVAL;
35470 }
35471 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35472 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35473 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35474 card->index);
35475 - atomic_inc(&vcc->stats->tx_err);
35476 + atomic_inc_unchecked(&vcc->stats->tx_err);
35477 dev_kfree_skb_any(skb);
35478 return -EINVAL;
35479 }
35480
35481 if (skb_shinfo(skb)->nr_frags != 0) {
35482 printk("nicstar%d: No scatter-gather yet.\n", 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 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35489 }
35490
35491 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35492 - atomic_inc(&vcc->stats->tx_err);
35493 + atomic_inc_unchecked(&vcc->stats->tx_err);
35494 dev_kfree_skb_any(skb);
35495 return -EIO;
35496 }
35497 - atomic_inc(&vcc->stats->tx);
35498 + atomic_inc_unchecked(&vcc->stats->tx);
35499
35500 return 0;
35501 }
35502 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35503 printk
35504 ("nicstar%d: Can't allocate buffers for aal0.\n",
35505 card->index);
35506 - atomic_add(i, &vcc->stats->rx_drop);
35507 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35508 break;
35509 }
35510 if (!atm_charge(vcc, sb->truesize)) {
35511 RXPRINTK
35512 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35513 card->index);
35514 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35515 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35516 dev_kfree_skb_any(sb);
35517 break;
35518 }
35519 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35520 ATM_SKB(sb)->vcc = vcc;
35521 __net_timestamp(sb);
35522 vcc->push(vcc, sb);
35523 - atomic_inc(&vcc->stats->rx);
35524 + atomic_inc_unchecked(&vcc->stats->rx);
35525 cell += ATM_CELL_PAYLOAD;
35526 }
35527
35528 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35529 if (iovb == NULL) {
35530 printk("nicstar%d: Out of iovec buffers.\n",
35531 card->index);
35532 - atomic_inc(&vcc->stats->rx_drop);
35533 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35534 recycle_rx_buf(card, skb);
35535 return;
35536 }
35537 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35538 small or large buffer itself. */
35539 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35540 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35541 - atomic_inc(&vcc->stats->rx_err);
35542 + atomic_inc_unchecked(&vcc->stats->rx_err);
35543 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35544 NS_MAX_IOVECS);
35545 NS_PRV_IOVCNT(iovb) = 0;
35546 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35547 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35548 card->index);
35549 which_list(card, skb);
35550 - atomic_inc(&vcc->stats->rx_err);
35551 + atomic_inc_unchecked(&vcc->stats->rx_err);
35552 recycle_rx_buf(card, skb);
35553 vc->rx_iov = NULL;
35554 recycle_iov_buf(card, iovb);
35555 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35556 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35557 card->index);
35558 which_list(card, skb);
35559 - atomic_inc(&vcc->stats->rx_err);
35560 + atomic_inc_unchecked(&vcc->stats->rx_err);
35561 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35562 NS_PRV_IOVCNT(iovb));
35563 vc->rx_iov = NULL;
35564 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35565 printk(" - PDU size mismatch.\n");
35566 else
35567 printk(".\n");
35568 - atomic_inc(&vcc->stats->rx_err);
35569 + atomic_inc_unchecked(&vcc->stats->rx_err);
35570 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35571 NS_PRV_IOVCNT(iovb));
35572 vc->rx_iov = NULL;
35573 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35574 /* skb points to a small buffer */
35575 if (!atm_charge(vcc, skb->truesize)) {
35576 push_rxbufs(card, skb);
35577 - atomic_inc(&vcc->stats->rx_drop);
35578 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35579 } else {
35580 skb_put(skb, len);
35581 dequeue_sm_buf(card, skb);
35582 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35583 ATM_SKB(skb)->vcc = vcc;
35584 __net_timestamp(skb);
35585 vcc->push(vcc, skb);
35586 - atomic_inc(&vcc->stats->rx);
35587 + atomic_inc_unchecked(&vcc->stats->rx);
35588 }
35589 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35590 struct sk_buff *sb;
35591 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35592 if (len <= NS_SMBUFSIZE) {
35593 if (!atm_charge(vcc, sb->truesize)) {
35594 push_rxbufs(card, sb);
35595 - atomic_inc(&vcc->stats->rx_drop);
35596 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35597 } else {
35598 skb_put(sb, len);
35599 dequeue_sm_buf(card, sb);
35600 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35601 ATM_SKB(sb)->vcc = vcc;
35602 __net_timestamp(sb);
35603 vcc->push(vcc, sb);
35604 - atomic_inc(&vcc->stats->rx);
35605 + atomic_inc_unchecked(&vcc->stats->rx);
35606 }
35607
35608 push_rxbufs(card, skb);
35609 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35610
35611 if (!atm_charge(vcc, skb->truesize)) {
35612 push_rxbufs(card, skb);
35613 - atomic_inc(&vcc->stats->rx_drop);
35614 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35615 } else {
35616 dequeue_lg_buf(card, skb);
35617 #ifdef NS_USE_DESTRUCTORS
35618 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35619 ATM_SKB(skb)->vcc = vcc;
35620 __net_timestamp(skb);
35621 vcc->push(vcc, skb);
35622 - atomic_inc(&vcc->stats->rx);
35623 + atomic_inc_unchecked(&vcc->stats->rx);
35624 }
35625
35626 push_rxbufs(card, sb);
35627 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35628 printk
35629 ("nicstar%d: Out of huge buffers.\n",
35630 card->index);
35631 - atomic_inc(&vcc->stats->rx_drop);
35632 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35633 recycle_iovec_rx_bufs(card,
35634 (struct iovec *)
35635 iovb->data,
35636 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35637 card->hbpool.count++;
35638 } else
35639 dev_kfree_skb_any(hb);
35640 - atomic_inc(&vcc->stats->rx_drop);
35641 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35642 } else {
35643 /* Copy the small buffer to the huge buffer */
35644 sb = (struct sk_buff *)iov->iov_base;
35645 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35646 #endif /* NS_USE_DESTRUCTORS */
35647 __net_timestamp(hb);
35648 vcc->push(vcc, hb);
35649 - atomic_inc(&vcc->stats->rx);
35650 + atomic_inc_unchecked(&vcc->stats->rx);
35651 }
35652 }
35653
35654 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35655 index 32784d1..4a8434a 100644
35656 --- a/drivers/atm/solos-pci.c
35657 +++ b/drivers/atm/solos-pci.c
35658 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35659 }
35660 atm_charge(vcc, skb->truesize);
35661 vcc->push(vcc, skb);
35662 - atomic_inc(&vcc->stats->rx);
35663 + atomic_inc_unchecked(&vcc->stats->rx);
35664 break;
35665
35666 case PKT_STATUS:
35667 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35668 vcc = SKB_CB(oldskb)->vcc;
35669
35670 if (vcc) {
35671 - atomic_inc(&vcc->stats->tx);
35672 + atomic_inc_unchecked(&vcc->stats->tx);
35673 solos_pop(vcc, oldskb);
35674 } else {
35675 dev_kfree_skb_irq(oldskb);
35676 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35677 index 0215934..ce9f5b1 100644
35678 --- a/drivers/atm/suni.c
35679 +++ b/drivers/atm/suni.c
35680 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35681
35682
35683 #define ADD_LIMITED(s,v) \
35684 - atomic_add((v),&stats->s); \
35685 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35686 + atomic_add_unchecked((v),&stats->s); \
35687 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35688
35689
35690 static void suni_hz(unsigned long from_timer)
35691 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35692 index 5120a96..e2572bd 100644
35693 --- a/drivers/atm/uPD98402.c
35694 +++ b/drivers/atm/uPD98402.c
35695 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35696 struct sonet_stats tmp;
35697 int error = 0;
35698
35699 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35700 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35701 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35702 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35703 if (zero && !error) {
35704 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35705
35706
35707 #define ADD_LIMITED(s,v) \
35708 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35709 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35710 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35711 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35712 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35713 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35714
35715
35716 static void stat_event(struct atm_dev *dev)
35717 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35718 if (reason & uPD98402_INT_PFM) stat_event(dev);
35719 if (reason & uPD98402_INT_PCO) {
35720 (void) GET(PCOCR); /* clear interrupt cause */
35721 - atomic_add(GET(HECCT),
35722 + atomic_add_unchecked(GET(HECCT),
35723 &PRIV(dev)->sonet_stats.uncorr_hcs);
35724 }
35725 if ((reason & uPD98402_INT_RFO) &&
35726 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35727 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35728 uPD98402_INT_LOS),PIMR); /* enable them */
35729 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35730 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35731 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35732 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35733 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35734 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35735 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35736 return 0;
35737 }
35738
35739 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35740 index 969c3c2..9b72956 100644
35741 --- a/drivers/atm/zatm.c
35742 +++ b/drivers/atm/zatm.c
35743 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35744 }
35745 if (!size) {
35746 dev_kfree_skb_irq(skb);
35747 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35748 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35749 continue;
35750 }
35751 if (!atm_charge(vcc,skb->truesize)) {
35752 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35753 skb->len = size;
35754 ATM_SKB(skb)->vcc = vcc;
35755 vcc->push(vcc,skb);
35756 - atomic_inc(&vcc->stats->rx);
35757 + atomic_inc_unchecked(&vcc->stats->rx);
35758 }
35759 zout(pos & 0xffff,MTA(mbx));
35760 #if 0 /* probably a stupid idea */
35761 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35762 skb_queue_head(&zatm_vcc->backlog,skb);
35763 break;
35764 }
35765 - atomic_inc(&vcc->stats->tx);
35766 + atomic_inc_unchecked(&vcc->stats->tx);
35767 wake_up(&zatm_vcc->tx_wait);
35768 }
35769
35770 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35771 index d414331..b4dd4ba 100644
35772 --- a/drivers/base/bus.c
35773 +++ b/drivers/base/bus.c
35774 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35775 return -EINVAL;
35776
35777 mutex_lock(&subsys->p->mutex);
35778 - list_add_tail(&sif->node, &subsys->p->interfaces);
35779 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35780 if (sif->add_dev) {
35781 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35782 while ((dev = subsys_dev_iter_next(&iter)))
35783 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35784 subsys = sif->subsys;
35785
35786 mutex_lock(&subsys->p->mutex);
35787 - list_del_init(&sif->node);
35788 + pax_list_del_init((struct list_head *)&sif->node);
35789 if (sif->remove_dev) {
35790 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35791 while ((dev = subsys_dev_iter_next(&iter)))
35792 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35793 index 7413d06..79155fa 100644
35794 --- a/drivers/base/devtmpfs.c
35795 +++ b/drivers/base/devtmpfs.c
35796 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35797 if (!thread)
35798 return 0;
35799
35800 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35801 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35802 if (err)
35803 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35804 else
35805 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35806 *err = sys_unshare(CLONE_NEWNS);
35807 if (*err)
35808 goto out;
35809 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35810 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35811 if (*err)
35812 goto out;
35813 - sys_chdir("/.."); /* will traverse into overmounted root */
35814 - sys_chroot(".");
35815 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35816 + sys_chroot((char __force_user *)".");
35817 complete(&setup_done);
35818 while (1) {
35819 spin_lock(&req_lock);
35820 diff --git a/drivers/base/node.c b/drivers/base/node.c
35821 index 7616a77c..8f57f51 100644
35822 --- a/drivers/base/node.c
35823 +++ b/drivers/base/node.c
35824 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35825 struct node_attr {
35826 struct device_attribute attr;
35827 enum node_states state;
35828 -};
35829 +} __do_const;
35830
35831 static ssize_t show_node_state(struct device *dev,
35832 struct device_attribute *attr, char *buf)
35833 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35834 index bfb8955..42c9b9a 100644
35835 --- a/drivers/base/power/domain.c
35836 +++ b/drivers/base/power/domain.c
35837 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35838 {
35839 struct cpuidle_driver *cpuidle_drv;
35840 struct gpd_cpu_data *cpu_data;
35841 - struct cpuidle_state *idle_state;
35842 + cpuidle_state_no_const *idle_state;
35843 int ret = 0;
35844
35845 if (IS_ERR_OR_NULL(genpd) || state < 0)
35846 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35847 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35848 {
35849 struct gpd_cpu_data *cpu_data;
35850 - struct cpuidle_state *idle_state;
35851 + cpuidle_state_no_const *idle_state;
35852 int ret = 0;
35853
35854 if (IS_ERR_OR_NULL(genpd))
35855 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35856 index a53ebd2..8f73eeb 100644
35857 --- a/drivers/base/power/sysfs.c
35858 +++ b/drivers/base/power/sysfs.c
35859 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35860 return -EIO;
35861 }
35862 }
35863 - return sprintf(buf, p);
35864 + return sprintf(buf, "%s", p);
35865 }
35866
35867 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35868 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35869 index 2d56f41..8830f19 100644
35870 --- a/drivers/base/power/wakeup.c
35871 +++ b/drivers/base/power/wakeup.c
35872 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35873 * They need to be modified together atomically, so it's better to use one
35874 * atomic variable to hold them both.
35875 */
35876 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35877 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35878
35879 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35880 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35881
35882 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35883 {
35884 - unsigned int comb = atomic_read(&combined_event_count);
35885 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35886
35887 *cnt = (comb >> IN_PROGRESS_BITS);
35888 *inpr = comb & MAX_IN_PROGRESS;
35889 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35890 ws->start_prevent_time = ws->last_time;
35891
35892 /* Increment the counter of events in progress. */
35893 - cec = atomic_inc_return(&combined_event_count);
35894 + cec = atomic_inc_return_unchecked(&combined_event_count);
35895
35896 trace_wakeup_source_activate(ws->name, cec);
35897 }
35898 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35899 * Increment the counter of registered wakeup events and decrement the
35900 * couter of wakeup events in progress simultaneously.
35901 */
35902 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35903 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35904 trace_wakeup_source_deactivate(ws->name, cec);
35905
35906 split_counters(&cnt, &inpr);
35907 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35908 index e8d11b6..7b1b36f 100644
35909 --- a/drivers/base/syscore.c
35910 +++ b/drivers/base/syscore.c
35911 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35912 void register_syscore_ops(struct syscore_ops *ops)
35913 {
35914 mutex_lock(&syscore_ops_lock);
35915 - list_add_tail(&ops->node, &syscore_ops_list);
35916 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35917 mutex_unlock(&syscore_ops_lock);
35918 }
35919 EXPORT_SYMBOL_GPL(register_syscore_ops);
35920 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35921 void unregister_syscore_ops(struct syscore_ops *ops)
35922 {
35923 mutex_lock(&syscore_ops_lock);
35924 - list_del(&ops->node);
35925 + pax_list_del((struct list_head *)&ops->node);
35926 mutex_unlock(&syscore_ops_lock);
35927 }
35928 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35929 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35930 index 62b6c2c..4a11354 100644
35931 --- a/drivers/block/cciss.c
35932 +++ b/drivers/block/cciss.c
35933 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
35934 int err;
35935 u32 cp;
35936
35937 + memset(&arg64, 0, sizeof(arg64));
35938 +
35939 err = 0;
35940 err |=
35941 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
35942 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
35943 while (!list_empty(&h->reqQ)) {
35944 c = list_entry(h->reqQ.next, CommandList_struct, list);
35945 /* can't do anything if fifo is full */
35946 - if ((h->access.fifo_full(h))) {
35947 + if ((h->access->fifo_full(h))) {
35948 dev_warn(&h->pdev->dev, "fifo full\n");
35949 break;
35950 }
35951 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
35952 h->Qdepth--;
35953
35954 /* Tell the controller execute command */
35955 - h->access.submit_command(h, c);
35956 + h->access->submit_command(h, c);
35957
35958 /* Put job onto the completed Q */
35959 addQ(&h->cmpQ, c);
35960 @@ -3446,17 +3448,17 @@ startio:
35961
35962 static inline unsigned long get_next_completion(ctlr_info_t *h)
35963 {
35964 - return h->access.command_completed(h);
35965 + return h->access->command_completed(h);
35966 }
35967
35968 static inline int interrupt_pending(ctlr_info_t *h)
35969 {
35970 - return h->access.intr_pending(h);
35971 + return h->access->intr_pending(h);
35972 }
35973
35974 static inline long interrupt_not_for_us(ctlr_info_t *h)
35975 {
35976 - return ((h->access.intr_pending(h) == 0) ||
35977 + return ((h->access->intr_pending(h) == 0) ||
35978 (h->interrupts_enabled == 0));
35979 }
35980
35981 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
35982 u32 a;
35983
35984 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
35985 - return h->access.command_completed(h);
35986 + return h->access->command_completed(h);
35987
35988 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
35989 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
35990 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
35991 trans_support & CFGTBL_Trans_use_short_tags);
35992
35993 /* Change the access methods to the performant access methods */
35994 - h->access = SA5_performant_access;
35995 + h->access = &SA5_performant_access;
35996 h->transMethod = CFGTBL_Trans_Performant;
35997
35998 return;
35999 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36000 if (prod_index < 0)
36001 return -ENODEV;
36002 h->product_name = products[prod_index].product_name;
36003 - h->access = *(products[prod_index].access);
36004 + h->access = products[prod_index].access;
36005
36006 if (cciss_board_disabled(h)) {
36007 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36008 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
36009 }
36010
36011 /* make sure the board interrupts are off */
36012 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36013 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36014 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36015 if (rc)
36016 goto clean2;
36017 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
36018 * fake ones to scoop up any residual completions.
36019 */
36020 spin_lock_irqsave(&h->lock, flags);
36021 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36022 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36023 spin_unlock_irqrestore(&h->lock, flags);
36024 free_irq(h->intr[h->intr_mode], h);
36025 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36026 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
36027 dev_info(&h->pdev->dev, "Board READY.\n");
36028 dev_info(&h->pdev->dev,
36029 "Waiting for stale completions to drain.\n");
36030 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36031 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36032 msleep(10000);
36033 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36034 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36035
36036 rc = controller_reset_failed(h->cfgtable);
36037 if (rc)
36038 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
36039 cciss_scsi_setup(h);
36040
36041 /* Turn the interrupts on so we can service requests */
36042 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36043 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36044
36045 /* Get the firmware version */
36046 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36047 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36048 kfree(flush_buf);
36049 if (return_code != IO_OK)
36050 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36051 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36052 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36053 free_irq(h->intr[h->intr_mode], h);
36054 }
36055
36056 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36057 index 7fda30e..eb5dfe0 100644
36058 --- a/drivers/block/cciss.h
36059 +++ b/drivers/block/cciss.h
36060 @@ -101,7 +101,7 @@ struct ctlr_info
36061 /* information about each logical volume */
36062 drive_info_struct *drv[CISS_MAX_LUN];
36063
36064 - struct access_method access;
36065 + struct access_method *access;
36066
36067 /* queue and queue Info */
36068 struct list_head reqQ;
36069 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36070 index 639d26b..fd6ad1f 100644
36071 --- a/drivers/block/cpqarray.c
36072 +++ b/drivers/block/cpqarray.c
36073 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36074 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36075 goto Enomem4;
36076 }
36077 - hba[i]->access.set_intr_mask(hba[i], 0);
36078 + hba[i]->access->set_intr_mask(hba[i], 0);
36079 if (request_irq(hba[i]->intr, do_ida_intr,
36080 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36081 {
36082 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36083 add_timer(&hba[i]->timer);
36084
36085 /* Enable IRQ now that spinlock and rate limit timer are set up */
36086 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36087 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36088
36089 for(j=0; j<NWD; j++) {
36090 struct gendisk *disk = ida_gendisk[i][j];
36091 @@ -694,7 +694,7 @@ DBGINFO(
36092 for(i=0; i<NR_PRODUCTS; i++) {
36093 if (board_id == products[i].board_id) {
36094 c->product_name = products[i].product_name;
36095 - c->access = *(products[i].access);
36096 + c->access = products[i].access;
36097 break;
36098 }
36099 }
36100 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36101 hba[ctlr]->intr = intr;
36102 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36103 hba[ctlr]->product_name = products[j].product_name;
36104 - hba[ctlr]->access = *(products[j].access);
36105 + hba[ctlr]->access = products[j].access;
36106 hba[ctlr]->ctlr = ctlr;
36107 hba[ctlr]->board_id = board_id;
36108 hba[ctlr]->pci_dev = NULL; /* not PCI */
36109 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36110
36111 while((c = h->reqQ) != NULL) {
36112 /* Can't do anything if we're busy */
36113 - if (h->access.fifo_full(h) == 0)
36114 + if (h->access->fifo_full(h) == 0)
36115 return;
36116
36117 /* Get the first entry from the request Q */
36118 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36119 h->Qdepth--;
36120
36121 /* Tell the controller to do our bidding */
36122 - h->access.submit_command(h, c);
36123 + h->access->submit_command(h, c);
36124
36125 /* Get onto the completion Q */
36126 addQ(&h->cmpQ, c);
36127 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36128 unsigned long flags;
36129 __u32 a,a1;
36130
36131 - istat = h->access.intr_pending(h);
36132 + istat = h->access->intr_pending(h);
36133 /* Is this interrupt for us? */
36134 if (istat == 0)
36135 return IRQ_NONE;
36136 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36137 */
36138 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36139 if (istat & FIFO_NOT_EMPTY) {
36140 - while((a = h->access.command_completed(h))) {
36141 + while((a = h->access->command_completed(h))) {
36142 a1 = a; a &= ~3;
36143 if ((c = h->cmpQ) == NULL)
36144 {
36145 @@ -1193,6 +1193,7 @@ out_passthru:
36146 ida_pci_info_struct pciinfo;
36147
36148 if (!arg) return -EINVAL;
36149 + memset(&pciinfo, 0, sizeof(pciinfo));
36150 pciinfo.bus = host->pci_dev->bus->number;
36151 pciinfo.dev_fn = host->pci_dev->devfn;
36152 pciinfo.board_id = host->board_id;
36153 @@ -1447,11 +1448,11 @@ static int sendcmd(
36154 /*
36155 * Disable interrupt
36156 */
36157 - info_p->access.set_intr_mask(info_p, 0);
36158 + info_p->access->set_intr_mask(info_p, 0);
36159 /* Make sure there is room in the command FIFO */
36160 /* Actually it should be completely empty at this time. */
36161 for (i = 200000; i > 0; i--) {
36162 - temp = info_p->access.fifo_full(info_p);
36163 + temp = info_p->access->fifo_full(info_p);
36164 if (temp != 0) {
36165 break;
36166 }
36167 @@ -1464,7 +1465,7 @@ DBG(
36168 /*
36169 * Send the cmd
36170 */
36171 - info_p->access.submit_command(info_p, c);
36172 + info_p->access->submit_command(info_p, c);
36173 complete = pollcomplete(ctlr);
36174
36175 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36176 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36177 * we check the new geometry. Then turn interrupts back on when
36178 * we're done.
36179 */
36180 - host->access.set_intr_mask(host, 0);
36181 + host->access->set_intr_mask(host, 0);
36182 getgeometry(ctlr);
36183 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36184 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36185
36186 for(i=0; i<NWD; i++) {
36187 struct gendisk *disk = ida_gendisk[ctlr][i];
36188 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
36189 /* Wait (up to 2 seconds) for a command to complete */
36190
36191 for (i = 200000; i > 0; i--) {
36192 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36193 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36194 if (done == 0) {
36195 udelay(10); /* a short fixed delay */
36196 } else
36197 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36198 index be73e9d..7fbf140 100644
36199 --- a/drivers/block/cpqarray.h
36200 +++ b/drivers/block/cpqarray.h
36201 @@ -99,7 +99,7 @@ struct ctlr_info {
36202 drv_info_t drv[NWD];
36203 struct proc_dir_entry *proc;
36204
36205 - struct access_method access;
36206 + struct access_method *access;
36207
36208 cmdlist_t *reqQ;
36209 cmdlist_t *cmpQ;
36210 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36211 index 2d7f608..11245fe 100644
36212 --- a/drivers/block/drbd/drbd_int.h
36213 +++ b/drivers/block/drbd/drbd_int.h
36214 @@ -582,7 +582,7 @@ struct drbd_epoch {
36215 struct drbd_tconn *tconn;
36216 struct list_head list;
36217 unsigned int barrier_nr;
36218 - atomic_t epoch_size; /* increased on every request added. */
36219 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36220 atomic_t active; /* increased on every req. added, and dec on every finished. */
36221 unsigned long flags;
36222 };
36223 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36224 unsigned int al_tr_number;
36225 int al_tr_cycle;
36226 wait_queue_head_t seq_wait;
36227 - atomic_t packet_seq;
36228 + atomic_unchecked_t packet_seq;
36229 unsigned int peer_seq;
36230 spinlock_t peer_seq_lock;
36231 unsigned int minor;
36232 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36233 char __user *uoptval;
36234 int err;
36235
36236 - uoptval = (char __user __force *)optval;
36237 + uoptval = (char __force_user *)optval;
36238
36239 set_fs(KERNEL_DS);
36240 if (level == SOL_SOCKET)
36241 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36242 index 55635ed..40e837c 100644
36243 --- a/drivers/block/drbd/drbd_main.c
36244 +++ b/drivers/block/drbd/drbd_main.c
36245 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36246 p->sector = sector;
36247 p->block_id = block_id;
36248 p->blksize = blksize;
36249 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36250 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36251 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36252 }
36253
36254 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36255 return -EIO;
36256 p->sector = cpu_to_be64(req->i.sector);
36257 p->block_id = (unsigned long)req;
36258 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36259 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36260 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36261 if (mdev->state.conn >= C_SYNC_SOURCE &&
36262 mdev->state.conn <= C_PAUSED_SYNC_T)
36263 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36264 {
36265 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36266
36267 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36268 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36269 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36270 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36271 kfree(tconn->current_epoch);
36272
36273 idr_destroy(&tconn->volumes);
36274 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36275 index 8cc1e64..ba7ffa9 100644
36276 --- a/drivers/block/drbd/drbd_nl.c
36277 +++ b/drivers/block/drbd/drbd_nl.c
36278 @@ -3440,7 +3440,7 @@ out:
36279
36280 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36281 {
36282 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36283 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36284 struct sk_buff *msg;
36285 struct drbd_genlmsghdr *d_out;
36286 unsigned seq;
36287 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36288 return;
36289 }
36290
36291 - seq = atomic_inc_return(&drbd_genl_seq);
36292 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36293 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36294 if (!msg)
36295 goto failed;
36296 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36297 index cc29cd3..d4b058b 100644
36298 --- a/drivers/block/drbd/drbd_receiver.c
36299 +++ b/drivers/block/drbd/drbd_receiver.c
36300 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36301 {
36302 int err;
36303
36304 - atomic_set(&mdev->packet_seq, 0);
36305 + atomic_set_unchecked(&mdev->packet_seq, 0);
36306 mdev->peer_seq = 0;
36307
36308 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36309 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36310 do {
36311 next_epoch = NULL;
36312
36313 - epoch_size = atomic_read(&epoch->epoch_size);
36314 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36315
36316 switch (ev & ~EV_CLEANUP) {
36317 case EV_PUT:
36318 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36319 rv = FE_DESTROYED;
36320 } else {
36321 epoch->flags = 0;
36322 - atomic_set(&epoch->epoch_size, 0);
36323 + atomic_set_unchecked(&epoch->epoch_size, 0);
36324 /* atomic_set(&epoch->active, 0); is already zero */
36325 if (rv == FE_STILL_LIVE)
36326 rv = FE_RECYCLED;
36327 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36328 conn_wait_active_ee_empty(tconn);
36329 drbd_flush(tconn);
36330
36331 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36332 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36333 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36334 if (epoch)
36335 break;
36336 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36337 }
36338
36339 epoch->flags = 0;
36340 - atomic_set(&epoch->epoch_size, 0);
36341 + atomic_set_unchecked(&epoch->epoch_size, 0);
36342 atomic_set(&epoch->active, 0);
36343
36344 spin_lock(&tconn->epoch_lock);
36345 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36346 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36347 list_add(&epoch->list, &tconn->current_epoch->list);
36348 tconn->current_epoch = epoch;
36349 tconn->epochs++;
36350 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36351
36352 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36353 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36354 - atomic_inc(&tconn->current_epoch->epoch_size);
36355 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36356 err2 = drbd_drain_block(mdev, pi->size);
36357 if (!err)
36358 err = err2;
36359 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36360
36361 spin_lock(&tconn->epoch_lock);
36362 peer_req->epoch = tconn->current_epoch;
36363 - atomic_inc(&peer_req->epoch->epoch_size);
36364 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36365 atomic_inc(&peer_req->epoch->active);
36366 spin_unlock(&tconn->epoch_lock);
36367
36368 @@ -4347,7 +4347,7 @@ struct data_cmd {
36369 int expect_payload;
36370 size_t pkt_size;
36371 int (*fn)(struct drbd_tconn *, struct packet_info *);
36372 -};
36373 +} __do_const;
36374
36375 static struct data_cmd drbd_cmd_handler[] = {
36376 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36377 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36378 if (!list_empty(&tconn->current_epoch->list))
36379 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36380 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36381 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36382 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36383 tconn->send.seen_any_write_yet = false;
36384
36385 conn_info(tconn, "Connection closed\n");
36386 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36387 struct asender_cmd {
36388 size_t pkt_size;
36389 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36390 -};
36391 +} __do_const;
36392
36393 static struct asender_cmd asender_tbl[] = {
36394 [P_PING] = { 0, got_Ping },
36395 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36396 index 40e7155..df5c79a 100644
36397 --- a/drivers/block/loop.c
36398 +++ b/drivers/block/loop.c
36399 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36400
36401 file_start_write(file);
36402 set_fs(get_ds());
36403 - bw = file->f_op->write(file, buf, len, &pos);
36404 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36405 set_fs(old_fs);
36406 file_end_write(file);
36407 if (likely(bw == len))
36408 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36409 index f5d0ea1..c62380a 100644
36410 --- a/drivers/block/pktcdvd.c
36411 +++ b/drivers/block/pktcdvd.c
36412 @@ -84,7 +84,7 @@
36413 #define MAX_SPEED 0xffff
36414
36415 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36416 - ~(sector_t)((pd)->settings.size - 1))
36417 + ~(sector_t)((pd)->settings.size - 1UL))
36418
36419 static DEFINE_MUTEX(pktcdvd_mutex);
36420 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36421 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36422 index 8a3aff7..d7538c2 100644
36423 --- a/drivers/cdrom/cdrom.c
36424 +++ b/drivers/cdrom/cdrom.c
36425 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36426 ENSURE(reset, CDC_RESET);
36427 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36428 cdi->mc_flags = 0;
36429 - cdo->n_minors = 0;
36430 cdi->options = CDO_USE_FFLAGS;
36431
36432 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36433 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36434 else
36435 cdi->cdda_method = CDDA_OLD;
36436
36437 - if (!cdo->generic_packet)
36438 - cdo->generic_packet = cdrom_dummy_generic_packet;
36439 + if (!cdo->generic_packet) {
36440 + pax_open_kernel();
36441 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36442 + pax_close_kernel();
36443 + }
36444
36445 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36446 mutex_lock(&cdrom_mutex);
36447 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36448 if (cdi->exit)
36449 cdi->exit(cdi);
36450
36451 - cdi->ops->n_minors--;
36452 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36453 }
36454
36455 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36456 */
36457 nr = nframes;
36458 do {
36459 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36460 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36461 if (cgc.buffer)
36462 break;
36463
36464 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36465 struct cdrom_device_info *cdi;
36466 int ret;
36467
36468 - ret = scnprintf(info + *pos, max_size - *pos, header);
36469 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36470 if (!ret)
36471 return 1;
36472
36473 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36474 index 5980cb9..6d7bd7e 100644
36475 --- a/drivers/cdrom/gdrom.c
36476 +++ b/drivers/cdrom/gdrom.c
36477 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36478 .audio_ioctl = gdrom_audio_ioctl,
36479 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36480 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36481 - .n_minors = 1,
36482 };
36483
36484 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36485 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36486 index 1421997..33f5d6d 100644
36487 --- a/drivers/char/Kconfig
36488 +++ b/drivers/char/Kconfig
36489 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36490
36491 config DEVKMEM
36492 bool "/dev/kmem virtual device support"
36493 - default y
36494 + default n
36495 + depends on !GRKERNSEC_KMEM
36496 help
36497 Say Y here if you want to support the /dev/kmem device. The
36498 /dev/kmem device is rarely used, but can be used for certain
36499 @@ -570,6 +571,7 @@ config DEVPORT
36500 bool
36501 depends on !M68K
36502 depends on ISA || PCI
36503 + depends on !GRKERNSEC_KMEM
36504 default y
36505
36506 source "drivers/s390/char/Kconfig"
36507 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36508 index a48e05b..6bac831 100644
36509 --- a/drivers/char/agp/compat_ioctl.c
36510 +++ b/drivers/char/agp/compat_ioctl.c
36511 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36512 return -ENOMEM;
36513 }
36514
36515 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36516 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36517 sizeof(*usegment) * ureserve.seg_count)) {
36518 kfree(usegment);
36519 kfree(ksegment);
36520 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36521 index 1b19239..b87b143 100644
36522 --- a/drivers/char/agp/frontend.c
36523 +++ b/drivers/char/agp/frontend.c
36524 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36525 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36526 return -EFAULT;
36527
36528 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36529 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36530 return -EFAULT;
36531
36532 client = agp_find_client_by_pid(reserve.pid);
36533 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36534 if (segment == NULL)
36535 return -ENOMEM;
36536
36537 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36538 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36539 sizeof(struct agp_segment) * reserve.seg_count)) {
36540 kfree(segment);
36541 return -EFAULT;
36542 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36543 index 4f94375..413694e 100644
36544 --- a/drivers/char/genrtc.c
36545 +++ b/drivers/char/genrtc.c
36546 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36547 switch (cmd) {
36548
36549 case RTC_PLL_GET:
36550 + memset(&pll, 0, sizeof(pll));
36551 if (get_rtc_pll(&pll))
36552 return -EINVAL;
36553 else
36554 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36555 index 448ce5e..3a76625 100644
36556 --- a/drivers/char/hpet.c
36557 +++ b/drivers/char/hpet.c
36558 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36559 }
36560
36561 static int
36562 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36563 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36564 struct hpet_info *info)
36565 {
36566 struct hpet_timer __iomem *timer;
36567 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36568 index 86fe45c..c0ea948 100644
36569 --- a/drivers/char/hw_random/intel-rng.c
36570 +++ b/drivers/char/hw_random/intel-rng.c
36571 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36572
36573 if (no_fwh_detect)
36574 return -ENODEV;
36575 - printk(warning);
36576 + printk("%s", warning);
36577 return -EBUSY;
36578 }
36579
36580 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36581 index 4445fa1..7c6de37 100644
36582 --- a/drivers/char/ipmi/ipmi_msghandler.c
36583 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36584 @@ -420,7 +420,7 @@ struct ipmi_smi {
36585 struct proc_dir_entry *proc_dir;
36586 char proc_dir_name[10];
36587
36588 - atomic_t stats[IPMI_NUM_STATS];
36589 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36590
36591 /*
36592 * run_to_completion duplicate of smb_info, smi_info
36593 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36594
36595
36596 #define ipmi_inc_stat(intf, stat) \
36597 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36598 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36599 #define ipmi_get_stat(intf, stat) \
36600 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36601 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36602
36603 static int is_lan_addr(struct ipmi_addr *addr)
36604 {
36605 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36606 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36607 init_waitqueue_head(&intf->waitq);
36608 for (i = 0; i < IPMI_NUM_STATS; i++)
36609 - atomic_set(&intf->stats[i], 0);
36610 + atomic_set_unchecked(&intf->stats[i], 0);
36611
36612 intf->proc_dir = NULL;
36613
36614 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36615 index af4b23f..79806fc 100644
36616 --- a/drivers/char/ipmi/ipmi_si_intf.c
36617 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36618 @@ -275,7 +275,7 @@ struct smi_info {
36619 unsigned char slave_addr;
36620
36621 /* Counters and things for the proc filesystem. */
36622 - atomic_t stats[SI_NUM_STATS];
36623 + atomic_unchecked_t stats[SI_NUM_STATS];
36624
36625 struct task_struct *thread;
36626
36627 @@ -284,9 +284,9 @@ struct smi_info {
36628 };
36629
36630 #define smi_inc_stat(smi, stat) \
36631 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36632 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36633 #define smi_get_stat(smi, stat) \
36634 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36635 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36636
36637 #define SI_MAX_PARMS 4
36638
36639 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36640 atomic_set(&new_smi->req_events, 0);
36641 new_smi->run_to_completion = 0;
36642 for (i = 0; i < SI_NUM_STATS; i++)
36643 - atomic_set(&new_smi->stats[i], 0);
36644 + atomic_set_unchecked(&new_smi->stats[i], 0);
36645
36646 new_smi->interrupt_disabled = 1;
36647 atomic_set(&new_smi->stop_operation, 0);
36648 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36649 index f895a8c..2bc9147 100644
36650 --- a/drivers/char/mem.c
36651 +++ b/drivers/char/mem.c
36652 @@ -18,6 +18,7 @@
36653 #include <linux/raw.h>
36654 #include <linux/tty.h>
36655 #include <linux/capability.h>
36656 +#include <linux/security.h>
36657 #include <linux/ptrace.h>
36658 #include <linux/device.h>
36659 #include <linux/highmem.h>
36660 @@ -37,6 +38,10 @@
36661
36662 #define DEVPORT_MINOR 4
36663
36664 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36665 +extern const struct file_operations grsec_fops;
36666 +#endif
36667 +
36668 static inline unsigned long size_inside_page(unsigned long start,
36669 unsigned long size)
36670 {
36671 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36672
36673 while (cursor < to) {
36674 if (!devmem_is_allowed(pfn)) {
36675 +#ifdef CONFIG_GRKERNSEC_KMEM
36676 + gr_handle_mem_readwrite(from, to);
36677 +#else
36678 printk(KERN_INFO
36679 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36680 current->comm, from, to);
36681 +#endif
36682 return 0;
36683 }
36684 cursor += PAGE_SIZE;
36685 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36686 }
36687 return 1;
36688 }
36689 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36690 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36691 +{
36692 + return 0;
36693 +}
36694 #else
36695 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36696 {
36697 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36698
36699 while (count > 0) {
36700 unsigned long remaining;
36701 + char *temp;
36702
36703 sz = size_inside_page(p, count);
36704
36705 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36706 if (!ptr)
36707 return -EFAULT;
36708
36709 - remaining = copy_to_user(buf, ptr, sz);
36710 +#ifdef CONFIG_PAX_USERCOPY
36711 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36712 + if (!temp) {
36713 + unxlate_dev_mem_ptr(p, ptr);
36714 + return -ENOMEM;
36715 + }
36716 + memcpy(temp, ptr, sz);
36717 +#else
36718 + temp = ptr;
36719 +#endif
36720 +
36721 + remaining = copy_to_user(buf, temp, sz);
36722 +
36723 +#ifdef CONFIG_PAX_USERCOPY
36724 + kfree(temp);
36725 +#endif
36726 +
36727 unxlate_dev_mem_ptr(p, ptr);
36728 if (remaining)
36729 return -EFAULT;
36730 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36731 size_t count, loff_t *ppos)
36732 {
36733 unsigned long p = *ppos;
36734 - ssize_t low_count, read, sz;
36735 + ssize_t low_count, read, sz, err = 0;
36736 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36737 - int err = 0;
36738
36739 read = 0;
36740 if (p < (unsigned long) high_memory) {
36741 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36742 }
36743 #endif
36744 while (low_count > 0) {
36745 + char *temp;
36746 +
36747 sz = size_inside_page(p, low_count);
36748
36749 /*
36750 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36751 */
36752 kbuf = xlate_dev_kmem_ptr((char *)p);
36753
36754 - if (copy_to_user(buf, kbuf, sz))
36755 +#ifdef CONFIG_PAX_USERCOPY
36756 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36757 + if (!temp)
36758 + return -ENOMEM;
36759 + memcpy(temp, kbuf, sz);
36760 +#else
36761 + temp = kbuf;
36762 +#endif
36763 +
36764 + err = copy_to_user(buf, temp, sz);
36765 +
36766 +#ifdef CONFIG_PAX_USERCOPY
36767 + kfree(temp);
36768 +#endif
36769 +
36770 + if (err)
36771 return -EFAULT;
36772 buf += sz;
36773 p += sz;
36774 @@ -822,6 +869,9 @@ static const struct memdev {
36775 #ifdef CONFIG_PRINTK
36776 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36777 #endif
36778 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36779 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36780 +#endif
36781 };
36782
36783 static int memory_open(struct inode *inode, struct file *filp)
36784 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36785 continue;
36786
36787 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36788 - NULL, devlist[minor].name);
36789 + NULL, "%s", devlist[minor].name);
36790 }
36791
36792 return tty_init();
36793 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36794 index 9df78e2..01ba9ae 100644
36795 --- a/drivers/char/nvram.c
36796 +++ b/drivers/char/nvram.c
36797 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36798
36799 spin_unlock_irq(&rtc_lock);
36800
36801 - if (copy_to_user(buf, contents, tmp - contents))
36802 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36803 return -EFAULT;
36804
36805 *ppos = i;
36806 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36807 index 5c5cc00..ac9edb7 100644
36808 --- a/drivers/char/pcmcia/synclink_cs.c
36809 +++ b/drivers/char/pcmcia/synclink_cs.c
36810 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36811
36812 if (debug_level >= DEBUG_LEVEL_INFO)
36813 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36814 - __FILE__, __LINE__, info->device_name, port->count);
36815 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36816
36817 - WARN_ON(!port->count);
36818 + WARN_ON(!atomic_read(&port->count));
36819
36820 if (tty_port_close_start(port, tty, filp) == 0)
36821 goto cleanup;
36822 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36823 cleanup:
36824 if (debug_level >= DEBUG_LEVEL_INFO)
36825 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36826 - tty->driver->name, port->count);
36827 + tty->driver->name, atomic_read(&port->count));
36828 }
36829
36830 /* Wait until the transmitter is empty.
36831 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36832
36833 if (debug_level >= DEBUG_LEVEL_INFO)
36834 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36835 - __FILE__, __LINE__, tty->driver->name, port->count);
36836 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36837
36838 /* If port is closing, signal caller to try again */
36839 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36840 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36841 goto cleanup;
36842 }
36843 spin_lock(&port->lock);
36844 - port->count++;
36845 + atomic_inc(&port->count);
36846 spin_unlock(&port->lock);
36847 spin_unlock_irqrestore(&info->netlock, flags);
36848
36849 - if (port->count == 1) {
36850 + if (atomic_read(&port->count) == 1) {
36851 /* 1st open on this device, init hardware */
36852 retval = startup(info, tty);
36853 if (retval < 0)
36854 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36855 unsigned short new_crctype;
36856
36857 /* return error if TTY interface open */
36858 - if (info->port.count)
36859 + if (atomic_read(&info->port.count))
36860 return -EBUSY;
36861
36862 switch (encoding)
36863 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36864
36865 /* arbitrate between network and tty opens */
36866 spin_lock_irqsave(&info->netlock, flags);
36867 - if (info->port.count != 0 || info->netcount != 0) {
36868 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36869 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36870 spin_unlock_irqrestore(&info->netlock, flags);
36871 return -EBUSY;
36872 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36873 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36874
36875 /* return error if TTY interface open */
36876 - if (info->port.count)
36877 + if (atomic_read(&info->port.count))
36878 return -EBUSY;
36879
36880 if (cmd != SIOCWANDEV)
36881 diff --git a/drivers/char/random.c b/drivers/char/random.c
36882 index 0d91fe5..f8e37b0 100644
36883 --- a/drivers/char/random.c
36884 +++ b/drivers/char/random.c
36885 @@ -272,8 +272,13 @@
36886 /*
36887 * Configuration information
36888 */
36889 +#ifdef CONFIG_GRKERNSEC_RANDNET
36890 +#define INPUT_POOL_WORDS 512
36891 +#define OUTPUT_POOL_WORDS 128
36892 +#else
36893 #define INPUT_POOL_WORDS 128
36894 #define OUTPUT_POOL_WORDS 32
36895 +#endif
36896 #define SEC_XFER_SIZE 512
36897 #define EXTRACT_SIZE 10
36898
36899 @@ -313,10 +318,17 @@ static struct poolinfo {
36900 int poolwords;
36901 int tap1, tap2, tap3, tap4, tap5;
36902 } poolinfo_table[] = {
36903 +#ifdef CONFIG_GRKERNSEC_RANDNET
36904 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36905 + { 512, 411, 308, 208, 104, 1 },
36906 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36907 + { 128, 103, 76, 51, 25, 1 },
36908 +#else
36909 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36910 { 128, 103, 76, 51, 25, 1 },
36911 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36912 { 32, 26, 20, 14, 7, 1 },
36913 +#endif
36914 #if 0
36915 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36916 { 2048, 1638, 1231, 819, 411, 1 },
36917 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36918 input_rotate += i ? 7 : 14;
36919 }
36920
36921 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36922 - ACCESS_ONCE(r->add_ptr) = i;
36923 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36924 + ACCESS_ONCE_RW(r->add_ptr) = i;
36925 smp_wmb();
36926
36927 if (out)
36928 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36929
36930 extract_buf(r, tmp);
36931 i = min_t(int, nbytes, EXTRACT_SIZE);
36932 - if (copy_to_user(buf, tmp, i)) {
36933 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36934 ret = -EFAULT;
36935 break;
36936 }
36937 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36938 #include <linux/sysctl.h>
36939
36940 static int min_read_thresh = 8, min_write_thresh;
36941 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36942 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36943 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36944 static char sysctl_bootid[16];
36945
36946 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36947 static int proc_do_uuid(struct ctl_table *table, int write,
36948 void __user *buffer, size_t *lenp, loff_t *ppos)
36949 {
36950 - struct ctl_table fake_table;
36951 + ctl_table_no_const fake_table;
36952 unsigned char buf[64], tmp_uuid[16], *uuid;
36953
36954 uuid = table->data;
36955 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36956 index bf2349db..5456d53 100644
36957 --- a/drivers/char/sonypi.c
36958 +++ b/drivers/char/sonypi.c
36959 @@ -54,6 +54,7 @@
36960
36961 #include <asm/uaccess.h>
36962 #include <asm/io.h>
36963 +#include <asm/local.h>
36964
36965 #include <linux/sonypi.h>
36966
36967 @@ -490,7 +491,7 @@ static struct sonypi_device {
36968 spinlock_t fifo_lock;
36969 wait_queue_head_t fifo_proc_list;
36970 struct fasync_struct *fifo_async;
36971 - int open_count;
36972 + local_t open_count;
36973 int model;
36974 struct input_dev *input_jog_dev;
36975 struct input_dev *input_key_dev;
36976 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
36977 static int sonypi_misc_release(struct inode *inode, struct file *file)
36978 {
36979 mutex_lock(&sonypi_device.lock);
36980 - sonypi_device.open_count--;
36981 + local_dec(&sonypi_device.open_count);
36982 mutex_unlock(&sonypi_device.lock);
36983 return 0;
36984 }
36985 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
36986 {
36987 mutex_lock(&sonypi_device.lock);
36988 /* Flush input queue on first open */
36989 - if (!sonypi_device.open_count)
36990 + if (!local_read(&sonypi_device.open_count))
36991 kfifo_reset(&sonypi_device.fifo);
36992 - sonypi_device.open_count++;
36993 + local_inc(&sonypi_device.open_count);
36994 mutex_unlock(&sonypi_device.lock);
36995
36996 return 0;
36997 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
36998 index 64420b3..5c40b56 100644
36999 --- a/drivers/char/tpm/tpm_acpi.c
37000 +++ b/drivers/char/tpm/tpm_acpi.c
37001 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37002 virt = acpi_os_map_memory(start, len);
37003 if (!virt) {
37004 kfree(log->bios_event_log);
37005 + log->bios_event_log = NULL;
37006 printk("%s: ERROR - Unable to map memory\n", __func__);
37007 return -EIO;
37008 }
37009
37010 - memcpy_fromio(log->bios_event_log, virt, len);
37011 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37012
37013 acpi_os_unmap_memory(virt, len);
37014 return 0;
37015 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37016 index 84ddc55..1d32f1e 100644
37017 --- a/drivers/char/tpm/tpm_eventlog.c
37018 +++ b/drivers/char/tpm/tpm_eventlog.c
37019 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37020 event = addr;
37021
37022 if ((event->event_type == 0 && event->event_size == 0) ||
37023 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37024 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37025 return NULL;
37026
37027 return addr;
37028 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37029 return NULL;
37030
37031 if ((event->event_type == 0 && event->event_size == 0) ||
37032 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37033 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37034 return NULL;
37035
37036 (*pos)++;
37037 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37038 int i;
37039
37040 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37041 - seq_putc(m, data[i]);
37042 + if (!seq_putc(m, data[i]))
37043 + return -EFAULT;
37044
37045 return 0;
37046 }
37047 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37048 index fc45567..fa2a590 100644
37049 --- a/drivers/char/virtio_console.c
37050 +++ b/drivers/char/virtio_console.c
37051 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37052 if (to_user) {
37053 ssize_t ret;
37054
37055 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37056 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37057 if (ret)
37058 return -EFAULT;
37059 } else {
37060 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37061 if (!port_has_data(port) && !port->host_connected)
37062 return 0;
37063
37064 - return fill_readbuf(port, ubuf, count, true);
37065 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37066 }
37067
37068 static int wait_port_writable(struct port *port, bool nonblock)
37069 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37070 index a33f46f..a720eed 100644
37071 --- a/drivers/clk/clk-composite.c
37072 +++ b/drivers/clk/clk-composite.c
37073 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37074 struct clk *clk;
37075 struct clk_init_data init;
37076 struct clk_composite *composite;
37077 - struct clk_ops *clk_composite_ops;
37078 + clk_ops_no_const *clk_composite_ops;
37079
37080 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37081 if (!composite) {
37082 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37083 index 5bb848c..f00ff83 100644
37084 --- a/drivers/clk/socfpga/clk.c
37085 +++ b/drivers/clk/socfpga/clk.c
37086 @@ -22,6 +22,7 @@
37087 #include <linux/clk-provider.h>
37088 #include <linux/io.h>
37089 #include <linux/of.h>
37090 +#include <asm/pgtable.h>
37091
37092 /* Clock Manager offsets */
37093 #define CLKMGR_CTRL 0x0
37094 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37095 streq(clk_name, "periph_pll") ||
37096 streq(clk_name, "sdram_pll")) {
37097 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37098 - clk_pll_ops.enable = clk_gate_ops.enable;
37099 - clk_pll_ops.disable = clk_gate_ops.disable;
37100 + pax_open_kernel();
37101 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37102 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37103 + pax_close_kernel();
37104 }
37105
37106 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37107 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37108 index 3926402..37b580d 100644
37109 --- a/drivers/cpufreq/acpi-cpufreq.c
37110 +++ b/drivers/cpufreq/acpi-cpufreq.c
37111 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37112 return sprintf(buf, "%u\n", boost_enabled);
37113 }
37114
37115 -static struct global_attr global_boost = __ATTR(boost, 0644,
37116 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37117 show_global_boost,
37118 store_global_boost);
37119
37120 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37121 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37122 per_cpu(acfreq_data, cpu) = data;
37123
37124 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37125 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37126 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37127 + pax_open_kernel();
37128 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37129 + pax_close_kernel();
37130 + }
37131
37132 result = acpi_processor_register_performance(data->acpi_data, cpu);
37133 if (result)
37134 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37135 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37136 break;
37137 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37138 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37139 + pax_open_kernel();
37140 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37141 + pax_close_kernel();
37142 policy->cur = get_cur_freq_on_cpu(cpu);
37143 break;
37144 default:
37145 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37146 acpi_processor_notify_smm(THIS_MODULE);
37147
37148 /* Check for APERF/MPERF support in hardware */
37149 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37150 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37151 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37152 + pax_open_kernel();
37153 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37154 + pax_close_kernel();
37155 + }
37156
37157 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37158 for (i = 0; i < perf->state_count; i++)
37159 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37160 index f0a5e2b..0a7ee46 100644
37161 --- a/drivers/cpufreq/cpufreq.c
37162 +++ b/drivers/cpufreq/cpufreq.c
37163 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37164 return NOTIFY_OK;
37165 }
37166
37167 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37168 +static struct notifier_block cpufreq_cpu_notifier = {
37169 .notifier_call = cpufreq_cpu_callback,
37170 };
37171
37172 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37173
37174 pr_debug("trying to register driver %s\n", driver_data->name);
37175
37176 - if (driver_data->setpolicy)
37177 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37178 + if (driver_data->setpolicy) {
37179 + pax_open_kernel();
37180 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37181 + pax_close_kernel();
37182 + }
37183
37184 write_lock_irqsave(&cpufreq_driver_lock, flags);
37185 if (cpufreq_driver) {
37186 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37187 index e59afaa..a53a3ff 100644
37188 --- a/drivers/cpufreq/cpufreq_governor.c
37189 +++ b/drivers/cpufreq/cpufreq_governor.c
37190 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37191 struct dbs_data *dbs_data;
37192 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37193 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37194 - struct od_ops *od_ops = NULL;
37195 + const struct od_ops *od_ops = NULL;
37196 struct od_dbs_tuners *od_tuners = NULL;
37197 struct cs_dbs_tuners *cs_tuners = NULL;
37198 struct cpu_dbs_common_info *cpu_cdbs;
37199 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37200
37201 if ((cdata->governor == GOV_CONSERVATIVE) &&
37202 (!policy->governor->initialized)) {
37203 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37204 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37205
37206 cpufreq_register_notifier(cs_ops->notifier_block,
37207 CPUFREQ_TRANSITION_NOTIFIER);
37208 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37209
37210 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37211 (policy->governor->initialized == 1)) {
37212 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37213 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37214
37215 cpufreq_unregister_notifier(cs_ops->notifier_block,
37216 CPUFREQ_TRANSITION_NOTIFIER);
37217 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37218 index d5f12b4..eb30af1 100644
37219 --- a/drivers/cpufreq/cpufreq_governor.h
37220 +++ b/drivers/cpufreq/cpufreq_governor.h
37221 @@ -204,7 +204,7 @@ struct common_dbs_data {
37222 void (*exit)(struct dbs_data *dbs_data);
37223
37224 /* Governor specific ops, see below */
37225 - void *gov_ops;
37226 + const void *gov_ops;
37227 };
37228
37229 /* Governer Per policy data */
37230 @@ -224,7 +224,7 @@ struct od_ops {
37231 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37232 unsigned int freq_next, unsigned int relation);
37233 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37234 -};
37235 +} __no_const;
37236
37237 struct cs_ops {
37238 struct notifier_block *notifier_block;
37239 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37240 index c087347..989aa2e 100644
37241 --- a/drivers/cpufreq/cpufreq_ondemand.c
37242 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37243 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37244
37245 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37246
37247 -static struct od_ops od_ops = {
37248 +static struct od_ops od_ops __read_only = {
37249 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37250 .powersave_bias_target = generic_powersave_bias_target,
37251 .freq_increase = dbs_freq_increase,
37252 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37253 (struct cpufreq_policy *, unsigned int, unsigned int),
37254 unsigned int powersave_bias)
37255 {
37256 - od_ops.powersave_bias_target = f;
37257 + pax_open_kernel();
37258 + *(void **)&od_ops.powersave_bias_target = f;
37259 + pax_close_kernel();
37260 od_set_powersave_bias(powersave_bias);
37261 }
37262 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37263
37264 void od_unregister_powersave_bias_handler(void)
37265 {
37266 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37267 + pax_open_kernel();
37268 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37269 + pax_close_kernel();
37270 od_set_powersave_bias(0);
37271 }
37272 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37273 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37274 index d37568c..fbb19a1 100644
37275 --- a/drivers/cpufreq/cpufreq_stats.c
37276 +++ b/drivers/cpufreq/cpufreq_stats.c
37277 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37278 }
37279
37280 /* priority=1 so this will get called before cpufreq_remove_dev */
37281 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37282 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37283 .notifier_call = cpufreq_stat_cpu_callback,
37284 .priority = 1,
37285 };
37286 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37287 index 9ee7817..17b658e 100644
37288 --- a/drivers/cpufreq/p4-clockmod.c
37289 +++ b/drivers/cpufreq/p4-clockmod.c
37290 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37291 case 0x0F: /* Core Duo */
37292 case 0x16: /* Celeron Core */
37293 case 0x1C: /* Atom */
37294 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37295 + pax_open_kernel();
37296 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37297 + pax_close_kernel();
37298 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37299 case 0x0D: /* Pentium M (Dothan) */
37300 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37301 + pax_open_kernel();
37302 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37303 + pax_close_kernel();
37304 /* fall through */
37305 case 0x09: /* Pentium M (Banias) */
37306 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37307 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37308
37309 /* on P-4s, the TSC runs with constant frequency independent whether
37310 * throttling is active or not. */
37311 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37312 + pax_open_kernel();
37313 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37314 + pax_close_kernel();
37315
37316 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37317 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37318 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37319 index 880ee29..2445bc6 100644
37320 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37321 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37322 @@ -18,14 +18,12 @@
37323 #include <asm/head.h>
37324 #include <asm/timer.h>
37325
37326 -static struct cpufreq_driver *cpufreq_us3_driver;
37327 -
37328 struct us3_freq_percpu_info {
37329 struct cpufreq_frequency_table table[4];
37330 };
37331
37332 /* Indexed by cpu number. */
37333 -static struct us3_freq_percpu_info *us3_freq_table;
37334 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37335
37336 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37337 * in the Safari config register.
37338 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37339
37340 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37341 {
37342 - if (cpufreq_us3_driver)
37343 - us3_set_cpu_divider_index(policy, 0);
37344 + us3_set_cpu_divider_index(policy->cpu, 0);
37345
37346 return 0;
37347 }
37348
37349 +static int __init us3_freq_init(void);
37350 +static void __exit us3_freq_exit(void);
37351 +
37352 +static struct cpufreq_driver cpufreq_us3_driver = {
37353 + .init = us3_freq_cpu_init,
37354 + .verify = us3_freq_verify,
37355 + .target = us3_freq_target,
37356 + .get = us3_freq_get,
37357 + .exit = us3_freq_cpu_exit,
37358 + .owner = THIS_MODULE,
37359 + .name = "UltraSPARC-III",
37360 +
37361 +};
37362 +
37363 static int __init us3_freq_init(void)
37364 {
37365 unsigned long manuf, impl, ver;
37366 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37367 (impl == CHEETAH_IMPL ||
37368 impl == CHEETAH_PLUS_IMPL ||
37369 impl == JAGUAR_IMPL ||
37370 - impl == PANTHER_IMPL)) {
37371 - struct cpufreq_driver *driver;
37372 -
37373 - ret = -ENOMEM;
37374 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37375 - if (!driver)
37376 - goto err_out;
37377 -
37378 - us3_freq_table = kzalloc(
37379 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37380 - GFP_KERNEL);
37381 - if (!us3_freq_table)
37382 - goto err_out;
37383 -
37384 - driver->init = us3_freq_cpu_init;
37385 - driver->verify = us3_freq_verify;
37386 - driver->target = us3_freq_target;
37387 - driver->get = us3_freq_get;
37388 - driver->exit = us3_freq_cpu_exit;
37389 - driver->owner = THIS_MODULE,
37390 - strcpy(driver->name, "UltraSPARC-III");
37391 -
37392 - cpufreq_us3_driver = driver;
37393 - ret = cpufreq_register_driver(driver);
37394 - if (ret)
37395 - goto err_out;
37396 -
37397 - return 0;
37398 -
37399 -err_out:
37400 - if (driver) {
37401 - kfree(driver);
37402 - cpufreq_us3_driver = NULL;
37403 - }
37404 - kfree(us3_freq_table);
37405 - us3_freq_table = NULL;
37406 - return ret;
37407 - }
37408 + impl == PANTHER_IMPL))
37409 + return cpufreq_register_driver(&cpufreq_us3_driver);
37410
37411 return -ENODEV;
37412 }
37413
37414 static void __exit us3_freq_exit(void)
37415 {
37416 - if (cpufreq_us3_driver) {
37417 - cpufreq_unregister_driver(cpufreq_us3_driver);
37418 - kfree(cpufreq_us3_driver);
37419 - cpufreq_us3_driver = NULL;
37420 - kfree(us3_freq_table);
37421 - us3_freq_table = NULL;
37422 - }
37423 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37424 }
37425
37426 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37427 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37428 index 0915e71..53376ed 100644
37429 --- a/drivers/cpufreq/speedstep-centrino.c
37430 +++ b/drivers/cpufreq/speedstep-centrino.c
37431 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37432 !cpu_has(cpu, X86_FEATURE_EST))
37433 return -ENODEV;
37434
37435 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37436 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37437 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37438 + pax_open_kernel();
37439 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37440 + pax_close_kernel();
37441 + }
37442
37443 if (policy->cpu != 0)
37444 return -ENODEV;
37445 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37446 index fdc432f..98e64e2 100644
37447 --- a/drivers/cpuidle/cpuidle.c
37448 +++ b/drivers/cpuidle/cpuidle.c
37449 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37450
37451 static void poll_idle_init(struct cpuidle_driver *drv)
37452 {
37453 - struct cpuidle_state *state = &drv->states[0];
37454 + cpuidle_state_no_const *state = &drv->states[0];
37455
37456 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37457 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37458 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37459 index ea2f8e7..70ac501 100644
37460 --- a/drivers/cpuidle/governor.c
37461 +++ b/drivers/cpuidle/governor.c
37462 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37463 mutex_lock(&cpuidle_lock);
37464 if (__cpuidle_find_governor(gov->name) == NULL) {
37465 ret = 0;
37466 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37467 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37468 if (!cpuidle_curr_governor ||
37469 cpuidle_curr_governor->rating < gov->rating)
37470 cpuidle_switch_governor(gov);
37471 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37472 new_gov = cpuidle_replace_governor(gov->rating);
37473 cpuidle_switch_governor(new_gov);
37474 }
37475 - list_del(&gov->governor_list);
37476 + pax_list_del((struct list_head *)&gov->governor_list);
37477 mutex_unlock(&cpuidle_lock);
37478 }
37479
37480 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37481 index 428754a..8bdf9cc 100644
37482 --- a/drivers/cpuidle/sysfs.c
37483 +++ b/drivers/cpuidle/sysfs.c
37484 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37485 NULL
37486 };
37487
37488 -static struct attribute_group cpuidle_attr_group = {
37489 +static attribute_group_no_const cpuidle_attr_group = {
37490 .attrs = cpuidle_default_attrs,
37491 .name = "cpuidle",
37492 };
37493 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37494 index 12fea3e..1e28f47 100644
37495 --- a/drivers/crypto/hifn_795x.c
37496 +++ b/drivers/crypto/hifn_795x.c
37497 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37498 MODULE_PARM_DESC(hifn_pll_ref,
37499 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37500
37501 -static atomic_t hifn_dev_number;
37502 +static atomic_unchecked_t hifn_dev_number;
37503
37504 #define ACRYPTO_OP_DECRYPT 0
37505 #define ACRYPTO_OP_ENCRYPT 1
37506 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37507 goto err_out_disable_pci_device;
37508
37509 snprintf(name, sizeof(name), "hifn%d",
37510 - atomic_inc_return(&hifn_dev_number)-1);
37511 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37512
37513 err = pci_request_regions(pdev, name);
37514 if (err)
37515 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37516 index e94e619..f7e249c 100644
37517 --- a/drivers/devfreq/devfreq.c
37518 +++ b/drivers/devfreq/devfreq.c
37519 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37520 goto err_out;
37521 }
37522
37523 - list_add(&governor->node, &devfreq_governor_list);
37524 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37525
37526 list_for_each_entry(devfreq, &devfreq_list, node) {
37527 int ret = 0;
37528 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37529 }
37530 }
37531
37532 - list_del(&governor->node);
37533 + pax_list_del((struct list_head *)&governor->node);
37534 err_out:
37535 mutex_unlock(&devfreq_list_lock);
37536
37537 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37538 index 5039fbc..841169f 100644
37539 --- a/drivers/dma/sh/shdma.c
37540 +++ b/drivers/dma/sh/shdma.c
37541 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37542 return ret;
37543 }
37544
37545 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37546 +static struct notifier_block sh_dmae_nmi_notifier = {
37547 .notifier_call = sh_dmae_nmi_handler,
37548
37549 /* Run before NMI debug handler and KGDB */
37550 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37551 index 211021d..201d47f 100644
37552 --- a/drivers/edac/edac_device.c
37553 +++ b/drivers/edac/edac_device.c
37554 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37555 */
37556 int edac_device_alloc_index(void)
37557 {
37558 - static atomic_t device_indexes = ATOMIC_INIT(0);
37559 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37560
37561 - return atomic_inc_return(&device_indexes) - 1;
37562 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37563 }
37564 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37565
37566 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37567 index e7c32c4..6397af1 100644
37568 --- a/drivers/edac/edac_mc_sysfs.c
37569 +++ b/drivers/edac/edac_mc_sysfs.c
37570 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37571 struct dev_ch_attribute {
37572 struct device_attribute attr;
37573 int channel;
37574 -};
37575 +} __do_const;
37576
37577 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37578 struct dev_ch_attribute dev_attr_legacy_##_name = \
37579 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37580 }
37581
37582 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37583 + pax_open_kernel();
37584 if (mci->get_sdram_scrub_rate) {
37585 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37586 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37587 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37588 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37589 }
37590 if (mci->set_sdram_scrub_rate) {
37591 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37592 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37593 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37594 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37595 }
37596 + pax_close_kernel();
37597 err = device_create_file(&mci->dev,
37598 &dev_attr_sdram_scrub_rate);
37599 if (err) {
37600 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37601 index dd370f9..0281629 100644
37602 --- a/drivers/edac/edac_pci.c
37603 +++ b/drivers/edac/edac_pci.c
37604 @@ -29,7 +29,7 @@
37605
37606 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37607 static LIST_HEAD(edac_pci_list);
37608 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37609 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37610
37611 /*
37612 * edac_pci_alloc_ctl_info
37613 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37614 */
37615 int edac_pci_alloc_index(void)
37616 {
37617 - return atomic_inc_return(&pci_indexes) - 1;
37618 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37619 }
37620 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37621
37622 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37623 index e8658e4..22746d6 100644
37624 --- a/drivers/edac/edac_pci_sysfs.c
37625 +++ b/drivers/edac/edac_pci_sysfs.c
37626 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37627 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37628 static int edac_pci_poll_msec = 1000; /* one second workq period */
37629
37630 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37631 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37632 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37633 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37634
37635 static struct kobject *edac_pci_top_main_kobj;
37636 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37637 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37638 void *value;
37639 ssize_t(*show) (void *, char *);
37640 ssize_t(*store) (void *, const char *, size_t);
37641 -};
37642 +} __do_const;
37643
37644 /* Set of show/store abstract level functions for PCI Parity object */
37645 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37646 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37647 edac_printk(KERN_CRIT, EDAC_PCI,
37648 "Signaled System Error on %s\n",
37649 pci_name(dev));
37650 - atomic_inc(&pci_nonparity_count);
37651 + atomic_inc_unchecked(&pci_nonparity_count);
37652 }
37653
37654 if (status & (PCI_STATUS_PARITY)) {
37655 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37656 "Master Data Parity Error on %s\n",
37657 pci_name(dev));
37658
37659 - atomic_inc(&pci_parity_count);
37660 + atomic_inc_unchecked(&pci_parity_count);
37661 }
37662
37663 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37664 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37665 "Detected Parity Error on %s\n",
37666 pci_name(dev));
37667
37668 - atomic_inc(&pci_parity_count);
37669 + atomic_inc_unchecked(&pci_parity_count);
37670 }
37671 }
37672
37673 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37674 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37675 "Signaled System Error on %s\n",
37676 pci_name(dev));
37677 - atomic_inc(&pci_nonparity_count);
37678 + atomic_inc_unchecked(&pci_nonparity_count);
37679 }
37680
37681 if (status & (PCI_STATUS_PARITY)) {
37682 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37683 "Master Data Parity Error on "
37684 "%s\n", pci_name(dev));
37685
37686 - atomic_inc(&pci_parity_count);
37687 + atomic_inc_unchecked(&pci_parity_count);
37688 }
37689
37690 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37691 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37692 "Detected Parity Error on %s\n",
37693 pci_name(dev));
37694
37695 - atomic_inc(&pci_parity_count);
37696 + atomic_inc_unchecked(&pci_parity_count);
37697 }
37698 }
37699 }
37700 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37701 if (!check_pci_errors)
37702 return;
37703
37704 - before_count = atomic_read(&pci_parity_count);
37705 + before_count = atomic_read_unchecked(&pci_parity_count);
37706
37707 /* scan all PCI devices looking for a Parity Error on devices and
37708 * bridges.
37709 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37710 /* Only if operator has selected panic on PCI Error */
37711 if (edac_pci_get_panic_on_pe()) {
37712 /* If the count is different 'after' from 'before' */
37713 - if (before_count != atomic_read(&pci_parity_count))
37714 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37715 panic("EDAC: PCI Parity Error");
37716 }
37717 }
37718 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37719 index 51b7e3a..aa8a3e8 100644
37720 --- a/drivers/edac/mce_amd.h
37721 +++ b/drivers/edac/mce_amd.h
37722 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37723 bool (*mc0_mce)(u16, u8);
37724 bool (*mc1_mce)(u16, u8);
37725 bool (*mc2_mce)(u16, u8);
37726 -};
37727 +} __no_const;
37728
37729 void amd_report_gart_errors(bool);
37730 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37731 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37732 index 57ea7f4..af06b76 100644
37733 --- a/drivers/firewire/core-card.c
37734 +++ b/drivers/firewire/core-card.c
37735 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37736 const struct fw_card_driver *driver,
37737 struct device *device)
37738 {
37739 - static atomic_t index = ATOMIC_INIT(-1);
37740 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37741
37742 - card->index = atomic_inc_return(&index);
37743 + card->index = atomic_inc_return_unchecked(&index);
37744 card->driver = driver;
37745 card->device = device;
37746 card->current_tlabel = 0;
37747 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37748
37749 void fw_core_remove_card(struct fw_card *card)
37750 {
37751 - struct fw_card_driver dummy_driver = dummy_driver_template;
37752 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37753
37754 card->driver->update_phy_reg(card, 4,
37755 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37756 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37757 index de4aa40..49ab1f2 100644
37758 --- a/drivers/firewire/core-device.c
37759 +++ b/drivers/firewire/core-device.c
37760 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37761 struct config_rom_attribute {
37762 struct device_attribute attr;
37763 u32 key;
37764 -};
37765 +} __do_const;
37766
37767 static ssize_t show_immediate(struct device *dev,
37768 struct device_attribute *dattr, char *buf)
37769 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37770 index 28a94c7..58da63a 100644
37771 --- a/drivers/firewire/core-transaction.c
37772 +++ b/drivers/firewire/core-transaction.c
37773 @@ -38,6 +38,7 @@
37774 #include <linux/timer.h>
37775 #include <linux/types.h>
37776 #include <linux/workqueue.h>
37777 +#include <linux/sched.h>
37778
37779 #include <asm/byteorder.h>
37780
37781 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37782 index 515a42c..5ecf3ba 100644
37783 --- a/drivers/firewire/core.h
37784 +++ b/drivers/firewire/core.h
37785 @@ -111,6 +111,7 @@ struct fw_card_driver {
37786
37787 int (*stop_iso)(struct fw_iso_context *ctx);
37788 };
37789 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37790
37791 void fw_card_initialize(struct fw_card *card,
37792 const struct fw_card_driver *driver, struct device *device);
37793 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37794 index 94a58a0..f5eba42 100644
37795 --- a/drivers/firmware/dmi-id.c
37796 +++ b/drivers/firmware/dmi-id.c
37797 @@ -16,7 +16,7 @@
37798 struct dmi_device_attribute{
37799 struct device_attribute dev_attr;
37800 int field;
37801 -};
37802 +} __do_const;
37803 #define to_dmi_dev_attr(_dev_attr) \
37804 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37805
37806 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37807 index 232fa8f..386c255 100644
37808 --- a/drivers/firmware/dmi_scan.c
37809 +++ b/drivers/firmware/dmi_scan.c
37810 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
37811 }
37812 }
37813 else {
37814 - /*
37815 - * no iounmap() for that ioremap(); it would be a no-op, but
37816 - * it's so early in setup that sucker gets confused into doing
37817 - * what it shouldn't if we actually call it.
37818 - */
37819 p = dmi_ioremap(0xF0000, 0x10000);
37820 if (p == NULL)
37821 goto error;
37822 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37823 if (buf == NULL)
37824 return -1;
37825
37826 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37827 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37828
37829 iounmap(buf);
37830 return 0;
37831 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37832 index 5145fa3..0d3babd 100644
37833 --- a/drivers/firmware/efi/efi.c
37834 +++ b/drivers/firmware/efi/efi.c
37835 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37836 };
37837
37838 static struct efivars generic_efivars;
37839 -static struct efivar_operations generic_ops;
37840 +static efivar_operations_no_const generic_ops __read_only;
37841
37842 static int generic_ops_register(void)
37843 {
37844 - generic_ops.get_variable = efi.get_variable;
37845 - generic_ops.set_variable = efi.set_variable;
37846 - generic_ops.get_next_variable = efi.get_next_variable;
37847 - generic_ops.query_variable_store = efi_query_variable_store;
37848 + pax_open_kernel();
37849 + *(void **)&generic_ops.get_variable = efi.get_variable;
37850 + *(void **)&generic_ops.set_variable = efi.set_variable;
37851 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37852 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37853 + pax_close_kernel();
37854
37855 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37856 }
37857 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37858 index 8a7432a..28fb839 100644
37859 --- a/drivers/firmware/efi/efivars.c
37860 +++ b/drivers/firmware/efi/efivars.c
37861 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37862 static int
37863 create_efivars_bin_attributes(void)
37864 {
37865 - struct bin_attribute *attr;
37866 + bin_attribute_no_const *attr;
37867 int error;
37868
37869 /* new_var */
37870 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37871 index 2a90ba6..07f3733 100644
37872 --- a/drivers/firmware/google/memconsole.c
37873 +++ b/drivers/firmware/google/memconsole.c
37874 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37875 if (!found_memconsole())
37876 return -ENODEV;
37877
37878 - memconsole_bin_attr.size = memconsole_length;
37879 + pax_open_kernel();
37880 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37881 + pax_close_kernel();
37882
37883 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37884
37885 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37886 index 2729e3d..f9deca1 100644
37887 --- a/drivers/gpio/gpio-ich.c
37888 +++ b/drivers/gpio/gpio-ich.c
37889 @@ -71,7 +71,7 @@ struct ichx_desc {
37890 /* Some chipsets have quirks, let these use their own request/get */
37891 int (*request)(struct gpio_chip *chip, unsigned offset);
37892 int (*get)(struct gpio_chip *chip, unsigned offset);
37893 -};
37894 +} __do_const;
37895
37896 static struct {
37897 spinlock_t lock;
37898 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37899 index 9902732..64b62dd 100644
37900 --- a/drivers/gpio/gpio-vr41xx.c
37901 +++ b/drivers/gpio/gpio-vr41xx.c
37902 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37903 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37904 maskl, pendl, maskh, pendh);
37905
37906 - atomic_inc(&irq_err_count);
37907 + atomic_inc_unchecked(&irq_err_count);
37908
37909 return -EINVAL;
37910 }
37911 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37912 index 6a64749..0767a9f 100644
37913 --- a/drivers/gpu/drm/drm_crtc_helper.c
37914 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37915 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37916 struct drm_crtc *tmp;
37917 int crtc_mask = 1;
37918
37919 - WARN(!crtc, "checking null crtc?\n");
37920 + BUG_ON(!crtc);
37921
37922 dev = crtc->dev;
37923
37924 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37925 index 99fcd7c..13cf6c5 100644
37926 --- a/drivers/gpu/drm/drm_drv.c
37927 +++ b/drivers/gpu/drm/drm_drv.c
37928 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
37929 /**
37930 * Copy and IOCTL return string to user space
37931 */
37932 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37933 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37934 {
37935 int len;
37936
37937 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
37938 struct drm_file *file_priv = filp->private_data;
37939 struct drm_device *dev;
37940 const struct drm_ioctl_desc *ioctl = NULL;
37941 - drm_ioctl_t *func;
37942 + drm_ioctl_no_const_t func;
37943 unsigned int nr = DRM_IOCTL_NR(cmd);
37944 int retcode = -EINVAL;
37945 char stack_kdata[128];
37946 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
37947 return -ENODEV;
37948
37949 atomic_inc(&dev->ioctl_count);
37950 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37951 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37952 ++file_priv->ioctl_count;
37953
37954 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37955 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37956 index 3a24385..4e426e0 100644
37957 --- a/drivers/gpu/drm/drm_fops.c
37958 +++ b/drivers/gpu/drm/drm_fops.c
37959 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
37960 }
37961
37962 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37963 - atomic_set(&dev->counts[i], 0);
37964 + atomic_set_unchecked(&dev->counts[i], 0);
37965
37966 dev->sigdata.lock = NULL;
37967
37968 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
37969 if (drm_device_is_unplugged(dev))
37970 return -ENODEV;
37971
37972 - if (!dev->open_count++)
37973 + if (local_inc_return(&dev->open_count) == 1)
37974 need_setup = 1;
37975 mutex_lock(&dev->struct_mutex);
37976 old_imapping = inode->i_mapping;
37977 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
37978 retcode = drm_open_helper(inode, filp, dev);
37979 if (retcode)
37980 goto err_undo;
37981 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
37982 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
37983 if (need_setup) {
37984 retcode = drm_setup(dev);
37985 if (retcode)
37986 @@ -166,7 +166,7 @@ err_undo:
37987 iput(container_of(dev->dev_mapping, struct inode, i_data));
37988 dev->dev_mapping = old_mapping;
37989 mutex_unlock(&dev->struct_mutex);
37990 - dev->open_count--;
37991 + local_dec(&dev->open_count);
37992 return retcode;
37993 }
37994 EXPORT_SYMBOL(drm_open);
37995 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
37996
37997 mutex_lock(&drm_global_mutex);
37998
37999 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38000 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38001
38002 if (dev->driver->preclose)
38003 dev->driver->preclose(dev, file_priv);
38004 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38005 * Begin inline drm_release
38006 */
38007
38008 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38009 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38010 task_pid_nr(current),
38011 (long)old_encode_dev(file_priv->minor->device),
38012 - dev->open_count);
38013 + local_read(&dev->open_count));
38014
38015 /* Release any auth tokens that might point to this file_priv,
38016 (do that under the drm_global_mutex) */
38017 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38018 * End inline drm_release
38019 */
38020
38021 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38022 - if (!--dev->open_count) {
38023 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38024 + if (local_dec_and_test(&dev->open_count)) {
38025 if (atomic_read(&dev->ioctl_count)) {
38026 DRM_ERROR("Device busy: %d\n",
38027 atomic_read(&dev->ioctl_count));
38028 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38029 index f731116..629842c 100644
38030 --- a/drivers/gpu/drm/drm_global.c
38031 +++ b/drivers/gpu/drm/drm_global.c
38032 @@ -36,7 +36,7 @@
38033 struct drm_global_item {
38034 struct mutex mutex;
38035 void *object;
38036 - int refcount;
38037 + atomic_t refcount;
38038 };
38039
38040 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38041 @@ -49,7 +49,7 @@ void drm_global_init(void)
38042 struct drm_global_item *item = &glob[i];
38043 mutex_init(&item->mutex);
38044 item->object = NULL;
38045 - item->refcount = 0;
38046 + atomic_set(&item->refcount, 0);
38047 }
38048 }
38049
38050 @@ -59,7 +59,7 @@ void drm_global_release(void)
38051 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38052 struct drm_global_item *item = &glob[i];
38053 BUG_ON(item->object != NULL);
38054 - BUG_ON(item->refcount != 0);
38055 + BUG_ON(atomic_read(&item->refcount) != 0);
38056 }
38057 }
38058
38059 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38060 void *object;
38061
38062 mutex_lock(&item->mutex);
38063 - if (item->refcount == 0) {
38064 + if (atomic_read(&item->refcount) == 0) {
38065 item->object = kzalloc(ref->size, GFP_KERNEL);
38066 if (unlikely(item->object == NULL)) {
38067 ret = -ENOMEM;
38068 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38069 goto out_err;
38070
38071 }
38072 - ++item->refcount;
38073 + atomic_inc(&item->refcount);
38074 ref->object = item->object;
38075 object = item->object;
38076 mutex_unlock(&item->mutex);
38077 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38078 struct drm_global_item *item = &glob[ref->global_type];
38079
38080 mutex_lock(&item->mutex);
38081 - BUG_ON(item->refcount == 0);
38082 + BUG_ON(atomic_read(&item->refcount) == 0);
38083 BUG_ON(ref->object != item->object);
38084 - if (--item->refcount == 0) {
38085 + if (atomic_dec_and_test(&item->refcount)) {
38086 ref->release(ref);
38087 item->object = NULL;
38088 }
38089 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38090 index d4b20ce..77a8d41 100644
38091 --- a/drivers/gpu/drm/drm_info.c
38092 +++ b/drivers/gpu/drm/drm_info.c
38093 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38094 struct drm_local_map *map;
38095 struct drm_map_list *r_list;
38096
38097 - /* Hardcoded from _DRM_FRAME_BUFFER,
38098 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38099 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38100 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38101 + static const char * const types[] = {
38102 + [_DRM_FRAME_BUFFER] = "FB",
38103 + [_DRM_REGISTERS] = "REG",
38104 + [_DRM_SHM] = "SHM",
38105 + [_DRM_AGP] = "AGP",
38106 + [_DRM_SCATTER_GATHER] = "SG",
38107 + [_DRM_CONSISTENT] = "PCI",
38108 + [_DRM_GEM] = "GEM" };
38109 const char *type;
38110 int i;
38111
38112 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38113 map = r_list->map;
38114 if (!map)
38115 continue;
38116 - if (map->type < 0 || map->type > 5)
38117 + if (map->type >= ARRAY_SIZE(types))
38118 type = "??";
38119 else
38120 type = types[map->type];
38121 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38122 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38123 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38124 vma->vm_flags & VM_IO ? 'i' : '-',
38125 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38126 + 0);
38127 +#else
38128 vma->vm_pgoff);
38129 +#endif
38130
38131 #if defined(__i386__)
38132 pgprot = pgprot_val(vma->vm_page_prot);
38133 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38134 index 2f4c434..dd12cd2 100644
38135 --- a/drivers/gpu/drm/drm_ioc32.c
38136 +++ b/drivers/gpu/drm/drm_ioc32.c
38137 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38138 request = compat_alloc_user_space(nbytes);
38139 if (!access_ok(VERIFY_WRITE, request, nbytes))
38140 return -EFAULT;
38141 - list = (struct drm_buf_desc *) (request + 1);
38142 + list = (struct drm_buf_desc __user *) (request + 1);
38143
38144 if (__put_user(count, &request->count)
38145 || __put_user(list, &request->list))
38146 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38147 request = compat_alloc_user_space(nbytes);
38148 if (!access_ok(VERIFY_WRITE, request, nbytes))
38149 return -EFAULT;
38150 - list = (struct drm_buf_pub *) (request + 1);
38151 + list = (struct drm_buf_pub __user *) (request + 1);
38152
38153 if (__put_user(count, &request->count)
38154 || __put_user(list, &request->list))
38155 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38156 return 0;
38157 }
38158
38159 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38160 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38161 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38162 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38163 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38164 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38165 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38166 {
38167 unsigned int nr = DRM_IOCTL_NR(cmd);
38168 - drm_ioctl_compat_t *fn;
38169 int ret;
38170
38171 /* Assume that ioctls without an explicit compat routine will just
38172 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38173 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38174 return drm_ioctl(filp, cmd, arg);
38175
38176 - fn = drm_compat_ioctls[nr];
38177 -
38178 - if (fn != NULL)
38179 - ret = (*fn) (filp, cmd, arg);
38180 + if (drm_compat_ioctls[nr] != NULL)
38181 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38182 else
38183 ret = drm_ioctl(filp, cmd, arg);
38184
38185 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38186 index ffd7a7b..a64643e 100644
38187 --- a/drivers/gpu/drm/drm_ioctl.c
38188 +++ b/drivers/gpu/drm/drm_ioctl.c
38189 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38190 stats->data[i].value =
38191 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38192 else
38193 - stats->data[i].value = atomic_read(&dev->counts[i]);
38194 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38195 stats->data[i].type = dev->types[i];
38196 }
38197
38198 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38199 index d752c96..fe08455 100644
38200 --- a/drivers/gpu/drm/drm_lock.c
38201 +++ b/drivers/gpu/drm/drm_lock.c
38202 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38203 if (drm_lock_take(&master->lock, lock->context)) {
38204 master->lock.file_priv = file_priv;
38205 master->lock.lock_time = jiffies;
38206 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38207 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38208 break; /* Got lock */
38209 }
38210
38211 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38212 return -EINVAL;
38213 }
38214
38215 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38216 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38217
38218 if (drm_lock_free(&master->lock, lock->context)) {
38219 /* FIXME: Should really bail out here. */
38220 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38221 index 327ca19..684d3c0 100644
38222 --- a/drivers/gpu/drm/drm_stub.c
38223 +++ b/drivers/gpu/drm/drm_stub.c
38224 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38225
38226 drm_device_set_unplugged(dev);
38227
38228 - if (dev->open_count == 0) {
38229 + if (local_read(&dev->open_count) == 0) {
38230 drm_put_dev(dev);
38231 }
38232 mutex_unlock(&drm_global_mutex);
38233 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38234 index 2290b3b..22056a1 100644
38235 --- a/drivers/gpu/drm/drm_sysfs.c
38236 +++ b/drivers/gpu/drm/drm_sysfs.c
38237 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38238 int drm_sysfs_device_add(struct drm_minor *minor)
38239 {
38240 int err;
38241 - char *minor_str;
38242 + const char *minor_str;
38243
38244 minor->kdev.parent = minor->dev->dev;
38245
38246 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38247 index ada49ed..29275a0 100644
38248 --- a/drivers/gpu/drm/i810/i810_dma.c
38249 +++ b/drivers/gpu/drm/i810/i810_dma.c
38250 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38251 dma->buflist[vertex->idx],
38252 vertex->discard, vertex->used);
38253
38254 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38255 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38256 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38257 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38258 sarea_priv->last_enqueue = dev_priv->counter - 1;
38259 sarea_priv->last_dispatch = (int)hw_status[5];
38260
38261 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38262 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38263 mc->last_render);
38264
38265 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38266 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38267 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38268 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38269 sarea_priv->last_enqueue = dev_priv->counter - 1;
38270 sarea_priv->last_dispatch = (int)hw_status[5];
38271
38272 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38273 index 6e0acad..93c8289 100644
38274 --- a/drivers/gpu/drm/i810/i810_drv.h
38275 +++ b/drivers/gpu/drm/i810/i810_drv.h
38276 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38277 int page_flipping;
38278
38279 wait_queue_head_t irq_queue;
38280 - atomic_t irq_received;
38281 - atomic_t irq_emitted;
38282 + atomic_unchecked_t irq_received;
38283 + atomic_unchecked_t irq_emitted;
38284
38285 int front_offset;
38286 } drm_i810_private_t;
38287 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38288 index 47d6c74..279123f 100644
38289 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38290 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38291 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38292 I915_READ(GTIMR));
38293 }
38294 seq_printf(m, "Interrupts received: %d\n",
38295 - atomic_read(&dev_priv->irq_received));
38296 + atomic_read_unchecked(&dev_priv->irq_received));
38297 for_each_ring(ring, dev_priv, i) {
38298 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38299 seq_printf(m,
38300 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38301 index f466980..8f2883f 100644
38302 --- a/drivers/gpu/drm/i915/i915_dma.c
38303 +++ b/drivers/gpu/drm/i915/i915_dma.c
38304 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38305 bool can_switch;
38306
38307 spin_lock(&dev->count_lock);
38308 - can_switch = (dev->open_count == 0);
38309 + can_switch = (local_read(&dev->open_count) == 0);
38310 spin_unlock(&dev->count_lock);
38311 return can_switch;
38312 }
38313 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38314 index 1929bff..dab130d 100644
38315 --- a/drivers/gpu/drm/i915/i915_drv.h
38316 +++ b/drivers/gpu/drm/i915/i915_drv.h
38317 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38318 drm_dma_handle_t *status_page_dmah;
38319 struct resource mch_res;
38320
38321 - atomic_t irq_received;
38322 + atomic_unchecked_t irq_received;
38323
38324 /* protects the irq masks */
38325 spinlock_t irq_lock;
38326 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38327 index 87a3227..cd13d8f 100644
38328 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38329 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38330 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38331
38332 static int
38333 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38334 - int count)
38335 + unsigned int count)
38336 {
38337 - int i;
38338 + unsigned int i;
38339 int relocs_total = 0;
38340 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38341
38342 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38343 index 3c59584..500f2e9 100644
38344 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38345 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38346 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38347 (unsigned long)request);
38348 }
38349
38350 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38351 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38352 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38353 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38354 [DRM_I915_GETPARAM] = compat_i915_getparam,
38355 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38356 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38357 {
38358 unsigned int nr = DRM_IOCTL_NR(cmd);
38359 - drm_ioctl_compat_t *fn = NULL;
38360 int ret;
38361
38362 if (nr < DRM_COMMAND_BASE)
38363 return drm_compat_ioctl(filp, cmd, arg);
38364
38365 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38366 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38367 -
38368 - if (fn != NULL)
38369 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38370 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38371 ret = (*fn) (filp, cmd, arg);
38372 - else
38373 + } else
38374 ret = drm_ioctl(filp, cmd, arg);
38375
38376 return ret;
38377 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38378 index 3d92a7c..9a9cfd7 100644
38379 --- a/drivers/gpu/drm/i915/i915_irq.c
38380 +++ b/drivers/gpu/drm/i915/i915_irq.c
38381 @@ -970,7 +970,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38382 int pipe;
38383 u32 pipe_stats[I915_MAX_PIPES];
38384
38385 - atomic_inc(&dev_priv->irq_received);
38386 + atomic_inc_unchecked(&dev_priv->irq_received);
38387
38388 while (true) {
38389 iir = I915_READ(VLV_IIR);
38390 @@ -1187,7 +1187,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38391 irqreturn_t ret = IRQ_NONE;
38392 int i;
38393
38394 - atomic_inc(&dev_priv->irq_received);
38395 + atomic_inc_unchecked(&dev_priv->irq_received);
38396
38397 /* We get interrupts on unclaimed registers, so check for this before we
38398 * do any I915_{READ,WRITE}. */
38399 @@ -1307,7 +1307,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38400 int ret = IRQ_NONE;
38401 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38402
38403 - atomic_inc(&dev_priv->irq_received);
38404 + atomic_inc_unchecked(&dev_priv->irq_received);
38405
38406 /* disable master interrupt before clearing iir */
38407 de_ier = I915_READ(DEIER);
38408 @@ -2566,7 +2566,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38409 {
38410 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38411
38412 - atomic_set(&dev_priv->irq_received, 0);
38413 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38414
38415 I915_WRITE(HWSTAM, 0xeffe);
38416
38417 @@ -2588,7 +2588,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38418 {
38419 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38420
38421 - atomic_set(&dev_priv->irq_received, 0);
38422 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38423
38424 I915_WRITE(HWSTAM, 0xeffe);
38425
38426 @@ -2616,7 +2616,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38427 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38428 int pipe;
38429
38430 - atomic_set(&dev_priv->irq_received, 0);
38431 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38432
38433 /* VLV magic */
38434 I915_WRITE(VLV_IMR, 0);
38435 @@ -2928,7 +2928,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38436 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38437 int pipe;
38438
38439 - atomic_set(&dev_priv->irq_received, 0);
38440 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38441
38442 for_each_pipe(pipe)
38443 I915_WRITE(PIPESTAT(pipe), 0);
38444 @@ -3007,7 +3007,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38445 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38446 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38447
38448 - atomic_inc(&dev_priv->irq_received);
38449 + atomic_inc_unchecked(&dev_priv->irq_received);
38450
38451 iir = I915_READ16(IIR);
38452 if (iir == 0)
38453 @@ -3082,7 +3082,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38454 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38455 int pipe;
38456
38457 - atomic_set(&dev_priv->irq_received, 0);
38458 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38459
38460 if (I915_HAS_HOTPLUG(dev)) {
38461 I915_WRITE(PORT_HOTPLUG_EN, 0);
38462 @@ -3181,7 +3181,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38463 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38464 int pipe, ret = IRQ_NONE;
38465
38466 - atomic_inc(&dev_priv->irq_received);
38467 + atomic_inc_unchecked(&dev_priv->irq_received);
38468
38469 iir = I915_READ(IIR);
38470 do {
38471 @@ -3305,7 +3305,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38472 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38473 int pipe;
38474
38475 - atomic_set(&dev_priv->irq_received, 0);
38476 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38477
38478 I915_WRITE(PORT_HOTPLUG_EN, 0);
38479 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38480 @@ -3414,7 +3414,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38481 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38482 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38483
38484 - atomic_inc(&dev_priv->irq_received);
38485 + atomic_inc_unchecked(&dev_priv->irq_received);
38486
38487 iir = I915_READ(IIR);
38488
38489 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38490 index be79f47..95e150b 100644
38491 --- a/drivers/gpu/drm/i915/intel_display.c
38492 +++ b/drivers/gpu/drm/i915/intel_display.c
38493 @@ -9418,13 +9418,13 @@ struct intel_quirk {
38494 int subsystem_vendor;
38495 int subsystem_device;
38496 void (*hook)(struct drm_device *dev);
38497 -};
38498 +} __do_const;
38499
38500 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38501 struct intel_dmi_quirk {
38502 void (*hook)(struct drm_device *dev);
38503 const struct dmi_system_id (*dmi_id_list)[];
38504 -};
38505 +} __do_const;
38506
38507 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38508 {
38509 @@ -9432,18 +9432,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38510 return 1;
38511 }
38512
38513 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38514 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38515 {
38516 - .dmi_id_list = &(const struct dmi_system_id[]) {
38517 - {
38518 - .callback = intel_dmi_reverse_brightness,
38519 - .ident = "NCR Corporation",
38520 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38521 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38522 - },
38523 - },
38524 - { } /* terminating entry */
38525 + .callback = intel_dmi_reverse_brightness,
38526 + .ident = "NCR Corporation",
38527 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38528 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38529 },
38530 + },
38531 + { } /* terminating entry */
38532 +};
38533 +
38534 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38535 + {
38536 + .dmi_id_list = &intel_dmi_quirks_table,
38537 .hook = quirk_invert_brightness,
38538 },
38539 };
38540 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38541 index 54558a0..2d97005 100644
38542 --- a/drivers/gpu/drm/mga/mga_drv.h
38543 +++ b/drivers/gpu/drm/mga/mga_drv.h
38544 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38545 u32 clear_cmd;
38546 u32 maccess;
38547
38548 - atomic_t vbl_received; /**< Number of vblanks received. */
38549 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38550 wait_queue_head_t fence_queue;
38551 - atomic_t last_fence_retired;
38552 + atomic_unchecked_t last_fence_retired;
38553 u32 next_fence_to_post;
38554
38555 unsigned int fb_cpp;
38556 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38557 index 709e90d..89a1c0d 100644
38558 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38559 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38560 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38561 return 0;
38562 }
38563
38564 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38565 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38566 [DRM_MGA_INIT] = compat_mga_init,
38567 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38568 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38569 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38570 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38571 {
38572 unsigned int nr = DRM_IOCTL_NR(cmd);
38573 - drm_ioctl_compat_t *fn = NULL;
38574 int ret;
38575
38576 if (nr < DRM_COMMAND_BASE)
38577 return drm_compat_ioctl(filp, cmd, arg);
38578
38579 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38580 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38581 -
38582 - if (fn != NULL)
38583 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38584 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38585 ret = (*fn) (filp, cmd, arg);
38586 - else
38587 + } else
38588 ret = drm_ioctl(filp, cmd, arg);
38589
38590 return ret;
38591 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38592 index 598c281..60d590e 100644
38593 --- a/drivers/gpu/drm/mga/mga_irq.c
38594 +++ b/drivers/gpu/drm/mga/mga_irq.c
38595 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38596 if (crtc != 0)
38597 return 0;
38598
38599 - return atomic_read(&dev_priv->vbl_received);
38600 + return atomic_read_unchecked(&dev_priv->vbl_received);
38601 }
38602
38603
38604 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38605 /* VBLANK interrupt */
38606 if (status & MGA_VLINEPEN) {
38607 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38608 - atomic_inc(&dev_priv->vbl_received);
38609 + atomic_inc_unchecked(&dev_priv->vbl_received);
38610 drm_handle_vblank(dev, 0);
38611 handled = 1;
38612 }
38613 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38614 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38615 MGA_WRITE(MGA_PRIMEND, prim_end);
38616
38617 - atomic_inc(&dev_priv->last_fence_retired);
38618 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38619 DRM_WAKEUP(&dev_priv->fence_queue);
38620 handled = 1;
38621 }
38622 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38623 * using fences.
38624 */
38625 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38626 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38627 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38628 - *sequence) <= (1 << 23)));
38629
38630 *sequence = cur_fence;
38631 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38632 index 3e72876..d1c15ad 100644
38633 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38634 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38635 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38636 struct bit_table {
38637 const char id;
38638 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38639 -};
38640 +} __no_const;
38641
38642 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38643
38644 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38645 index 41ff7e0..fa854ef 100644
38646 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38647 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38648 @@ -92,7 +92,6 @@ struct nouveau_drm {
38649 struct drm_global_reference mem_global_ref;
38650 struct ttm_bo_global_ref bo_global_ref;
38651 struct ttm_bo_device bdev;
38652 - atomic_t validate_sequence;
38653 int (*move)(struct nouveau_channel *,
38654 struct ttm_buffer_object *,
38655 struct ttm_mem_reg *, struct ttm_mem_reg *);
38656 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38657 index 08214bc..9208577 100644
38658 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38659 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38660 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38661 unsigned long arg)
38662 {
38663 unsigned int nr = DRM_IOCTL_NR(cmd);
38664 - drm_ioctl_compat_t *fn = NULL;
38665 + drm_ioctl_compat_t fn = NULL;
38666 int ret;
38667
38668 if (nr < DRM_COMMAND_BASE)
38669 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38670 index 25d3495..d81aaf6 100644
38671 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38672 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38673 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38674 bool can_switch;
38675
38676 spin_lock(&dev->count_lock);
38677 - can_switch = (dev->open_count == 0);
38678 + can_switch = (local_read(&dev->open_count) == 0);
38679 spin_unlock(&dev->count_lock);
38680 return can_switch;
38681 }
38682 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38683 index 1dfd84c..104896c 100644
38684 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38685 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38686 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38687 }
38688 }
38689
38690 -static struct vm_operations_struct qxl_ttm_vm_ops;
38691 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38692 static const struct vm_operations_struct *ttm_vm_ops;
38693
38694 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38695 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38696 return r;
38697 if (unlikely(ttm_vm_ops == NULL)) {
38698 ttm_vm_ops = vma->vm_ops;
38699 + pax_open_kernel();
38700 qxl_ttm_vm_ops = *ttm_vm_ops;
38701 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38702 + pax_close_kernel();
38703 }
38704 vma->vm_ops = &qxl_ttm_vm_ops;
38705 return 0;
38706 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38707 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38708 {
38709 #if defined(CONFIG_DEBUG_FS)
38710 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38711 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38712 - unsigned i;
38713 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38714 + {
38715 + .name = "qxl_mem_mm",
38716 + .show = &qxl_mm_dump_table,
38717 + },
38718 + {
38719 + .name = "qxl_surf_mm",
38720 + .show = &qxl_mm_dump_table,
38721 + }
38722 + };
38723
38724 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38725 - if (i == 0)
38726 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38727 - else
38728 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38729 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38730 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38731 - qxl_mem_types_list[i].driver_features = 0;
38732 - if (i == 0)
38733 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38734 - else
38735 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38736 + pax_open_kernel();
38737 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38738 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38739 + pax_close_kernel();
38740
38741 - }
38742 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38743 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38744 #else
38745 return 0;
38746 #endif
38747 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38748 index d4660cf..70dbe65 100644
38749 --- a/drivers/gpu/drm/r128/r128_cce.c
38750 +++ b/drivers/gpu/drm/r128/r128_cce.c
38751 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38752
38753 /* GH: Simple idle check.
38754 */
38755 - atomic_set(&dev_priv->idle_count, 0);
38756 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38757
38758 /* We don't support anything other than bus-mastering ring mode,
38759 * but the ring can be in either AGP or PCI space for the ring
38760 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38761 index 930c71b..499aded 100644
38762 --- a/drivers/gpu/drm/r128/r128_drv.h
38763 +++ b/drivers/gpu/drm/r128/r128_drv.h
38764 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38765 int is_pci;
38766 unsigned long cce_buffers_offset;
38767
38768 - atomic_t idle_count;
38769 + atomic_unchecked_t idle_count;
38770
38771 int page_flipping;
38772 int current_page;
38773 u32 crtc_offset;
38774 u32 crtc_offset_cntl;
38775
38776 - atomic_t vbl_received;
38777 + atomic_unchecked_t vbl_received;
38778
38779 u32 color_fmt;
38780 unsigned int front_offset;
38781 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38782 index a954c54..9cc595c 100644
38783 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38784 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38785 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38786 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38787 }
38788
38789 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38790 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38791 [DRM_R128_INIT] = compat_r128_init,
38792 [DRM_R128_DEPTH] = compat_r128_depth,
38793 [DRM_R128_STIPPLE] = compat_r128_stipple,
38794 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38795 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38796 {
38797 unsigned int nr = DRM_IOCTL_NR(cmd);
38798 - drm_ioctl_compat_t *fn = NULL;
38799 int ret;
38800
38801 if (nr < DRM_COMMAND_BASE)
38802 return drm_compat_ioctl(filp, cmd, arg);
38803
38804 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38805 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38806 -
38807 - if (fn != NULL)
38808 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38809 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38810 ret = (*fn) (filp, cmd, arg);
38811 - else
38812 + } else
38813 ret = drm_ioctl(filp, cmd, arg);
38814
38815 return ret;
38816 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38817 index 2ea4f09..d391371 100644
38818 --- a/drivers/gpu/drm/r128/r128_irq.c
38819 +++ b/drivers/gpu/drm/r128/r128_irq.c
38820 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38821 if (crtc != 0)
38822 return 0;
38823
38824 - return atomic_read(&dev_priv->vbl_received);
38825 + return atomic_read_unchecked(&dev_priv->vbl_received);
38826 }
38827
38828 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38829 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38830 /* VBLANK interrupt */
38831 if (status & R128_CRTC_VBLANK_INT) {
38832 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38833 - atomic_inc(&dev_priv->vbl_received);
38834 + atomic_inc_unchecked(&dev_priv->vbl_received);
38835 drm_handle_vblank(dev, 0);
38836 return IRQ_HANDLED;
38837 }
38838 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38839 index 19bb7e6..de7e2a2 100644
38840 --- a/drivers/gpu/drm/r128/r128_state.c
38841 +++ b/drivers/gpu/drm/r128/r128_state.c
38842 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38843
38844 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38845 {
38846 - if (atomic_read(&dev_priv->idle_count) == 0)
38847 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38848 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38849 else
38850 - atomic_set(&dev_priv->idle_count, 0);
38851 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38852 }
38853
38854 #endif
38855 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38856 index af85299..ed9ac8d 100644
38857 --- a/drivers/gpu/drm/radeon/mkregtable.c
38858 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38859 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38860 regex_t mask_rex;
38861 regmatch_t match[4];
38862 char buf[1024];
38863 - size_t end;
38864 + long end;
38865 int len;
38866 int done = 0;
38867 int r;
38868 unsigned o;
38869 struct offset *offset;
38870 char last_reg_s[10];
38871 - int last_reg;
38872 + unsigned long last_reg;
38873
38874 if (regcomp
38875 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38876 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38877 index 63398ae..669e045 100644
38878 --- a/drivers/gpu/drm/radeon/radeon_device.c
38879 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38880 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38881 bool can_switch;
38882
38883 spin_lock(&dev->count_lock);
38884 - can_switch = (dev->open_count == 0);
38885 + can_switch = (local_read(&dev->open_count) == 0);
38886 spin_unlock(&dev->count_lock);
38887 return can_switch;
38888 }
38889 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38890 index b369d42..8dd04eb 100644
38891 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38892 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38893 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38894
38895 /* SW interrupt */
38896 wait_queue_head_t swi_queue;
38897 - atomic_t swi_emitted;
38898 + atomic_unchecked_t swi_emitted;
38899 int vblank_crtc;
38900 uint32_t irq_enable_reg;
38901 uint32_t r500_disp_irq_reg;
38902 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38903 index c180df8..5fd8186 100644
38904 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38905 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38906 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38907 request = compat_alloc_user_space(sizeof(*request));
38908 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38909 || __put_user(req32.param, &request->param)
38910 - || __put_user((void __user *)(unsigned long)req32.value,
38911 + || __put_user((unsigned long)req32.value,
38912 &request->value))
38913 return -EFAULT;
38914
38915 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38916 #define compat_radeon_cp_setparam NULL
38917 #endif /* X86_64 || IA64 */
38918
38919 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38920 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38921 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38922 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38923 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38924 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38925 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38926 {
38927 unsigned int nr = DRM_IOCTL_NR(cmd);
38928 - drm_ioctl_compat_t *fn = NULL;
38929 int ret;
38930
38931 if (nr < DRM_COMMAND_BASE)
38932 return drm_compat_ioctl(filp, cmd, arg);
38933
38934 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38935 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38936 -
38937 - if (fn != NULL)
38938 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38939 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38940 ret = (*fn) (filp, cmd, arg);
38941 - else
38942 + } else
38943 ret = drm_ioctl(filp, cmd, arg);
38944
38945 return ret;
38946 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38947 index 8d68e97..9dcfed8 100644
38948 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38949 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38950 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38951 unsigned int ret;
38952 RING_LOCALS;
38953
38954 - atomic_inc(&dev_priv->swi_emitted);
38955 - ret = atomic_read(&dev_priv->swi_emitted);
38956 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38957 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
38958
38959 BEGIN_RING(4);
38960 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
38961 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
38962 drm_radeon_private_t *dev_priv =
38963 (drm_radeon_private_t *) dev->dev_private;
38964
38965 - atomic_set(&dev_priv->swi_emitted, 0);
38966 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
38967 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
38968
38969 dev->max_vblank_count = 0x001fffff;
38970 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
38971 index 4d20910..6726b6d 100644
38972 --- a/drivers/gpu/drm/radeon/radeon_state.c
38973 +++ b/drivers/gpu/drm/radeon/radeon_state.c
38974 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
38975 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
38976 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
38977
38978 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
38979 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
38980 sarea_priv->nbox * sizeof(depth_boxes[0])))
38981 return -EFAULT;
38982
38983 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
38984 {
38985 drm_radeon_private_t *dev_priv = dev->dev_private;
38986 drm_radeon_getparam_t *param = data;
38987 - int value;
38988 + int value = 0;
38989
38990 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
38991
38992 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
38993 index 6c0ce89..57a2529 100644
38994 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
38995 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
38996 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
38997 man->size = size >> PAGE_SHIFT;
38998 }
38999
39000 -static struct vm_operations_struct radeon_ttm_vm_ops;
39001 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39002 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39003
39004 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39005 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39006 }
39007 if (unlikely(ttm_vm_ops == NULL)) {
39008 ttm_vm_ops = vma->vm_ops;
39009 + pax_open_kernel();
39010 radeon_ttm_vm_ops = *ttm_vm_ops;
39011 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39012 + pax_close_kernel();
39013 }
39014 vma->vm_ops = &radeon_ttm_vm_ops;
39015 return 0;
39016 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39017 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39018 {
39019 #if defined(CONFIG_DEBUG_FS)
39020 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39021 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39022 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39023 + {
39024 + .name = "radeon_vram_mm",
39025 + .show = &radeon_mm_dump_table,
39026 + },
39027 + {
39028 + .name = "radeon_gtt_mm",
39029 + .show = &radeon_mm_dump_table,
39030 + },
39031 + {
39032 + .name = "ttm_page_pool",
39033 + .show = &ttm_page_alloc_debugfs,
39034 + },
39035 + {
39036 + .name = "ttm_dma_page_pool",
39037 + .show = &ttm_dma_page_alloc_debugfs,
39038 + },
39039 + };
39040 unsigned i;
39041
39042 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39043 - if (i == 0)
39044 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39045 - else
39046 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39047 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39048 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39049 - radeon_mem_types_list[i].driver_features = 0;
39050 - if (i == 0)
39051 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39052 - else
39053 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39054 -
39055 - }
39056 - /* Add ttm page pool to debugfs */
39057 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39058 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39059 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39060 - radeon_mem_types_list[i].driver_features = 0;
39061 - radeon_mem_types_list[i++].data = NULL;
39062 + pax_open_kernel();
39063 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39064 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39065 + pax_close_kernel();
39066 #ifdef CONFIG_SWIOTLB
39067 - if (swiotlb_nr_tbl()) {
39068 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39069 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39070 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39071 - radeon_mem_types_list[i].driver_features = 0;
39072 - radeon_mem_types_list[i++].data = NULL;
39073 - }
39074 + if (swiotlb_nr_tbl())
39075 + i++;
39076 #endif
39077 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39078
39079 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39080 index d8ddfb3..609de1d 100644
39081 --- a/drivers/gpu/drm/radeon/rs690.c
39082 +++ b/drivers/gpu/drm/radeon/rs690.c
39083 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39084 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39085 rdev->pm.sideport_bandwidth.full)
39086 max_bandwidth = rdev->pm.sideport_bandwidth;
39087 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39088 + read_delay_latency.full = dfixed_const(800 * 1000);
39089 read_delay_latency.full = dfixed_div(read_delay_latency,
39090 rdev->pm.igp_sideport_mclk);
39091 + a.full = dfixed_const(370);
39092 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39093 } else {
39094 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39095 rdev->pm.k8_bandwidth.full)
39096 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39097 index dbc2def..0a9f710 100644
39098 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39099 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39100 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39101 zone->glob = glob;
39102 glob->zone_kernel = zone;
39103 ret = kobject_init_and_add(
39104 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39105 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39106 if (unlikely(ret != 0)) {
39107 kobject_put(&zone->kobj);
39108 return ret;
39109 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39110 zone->glob = glob;
39111 glob->zone_dma32 = zone;
39112 ret = kobject_init_and_add(
39113 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39114 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39115 if (unlikely(ret != 0)) {
39116 kobject_put(&zone->kobj);
39117 return ret;
39118 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39119 index bd2a3b4..122d9ad 100644
39120 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39121 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39122 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39123 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39124 struct shrink_control *sc)
39125 {
39126 - static atomic_t start_pool = ATOMIC_INIT(0);
39127 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39128 unsigned i;
39129 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39130 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39131 struct ttm_page_pool *pool;
39132 int shrink_pages = sc->nr_to_scan;
39133
39134 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39135 index 97e9d61..bf23c461 100644
39136 --- a/drivers/gpu/drm/udl/udl_fb.c
39137 +++ b/drivers/gpu/drm/udl/udl_fb.c
39138 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39139 fb_deferred_io_cleanup(info);
39140 kfree(info->fbdefio);
39141 info->fbdefio = NULL;
39142 - info->fbops->fb_mmap = udl_fb_mmap;
39143 }
39144
39145 pr_warn("released /dev/fb%d user=%d count=%d\n",
39146 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39147 index 893a650..6190d3b 100644
39148 --- a/drivers/gpu/drm/via/via_drv.h
39149 +++ b/drivers/gpu/drm/via/via_drv.h
39150 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39151 typedef uint32_t maskarray_t[5];
39152
39153 typedef struct drm_via_irq {
39154 - atomic_t irq_received;
39155 + atomic_unchecked_t irq_received;
39156 uint32_t pending_mask;
39157 uint32_t enable_mask;
39158 wait_queue_head_t irq_queue;
39159 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39160 struct timeval last_vblank;
39161 int last_vblank_valid;
39162 unsigned usec_per_vblank;
39163 - atomic_t vbl_received;
39164 + atomic_unchecked_t vbl_received;
39165 drm_via_state_t hc_state;
39166 char pci_buf[VIA_PCI_BUF_SIZE];
39167 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39168 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39169 index ac98964..5dbf512 100644
39170 --- a/drivers/gpu/drm/via/via_irq.c
39171 +++ b/drivers/gpu/drm/via/via_irq.c
39172 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39173 if (crtc != 0)
39174 return 0;
39175
39176 - return atomic_read(&dev_priv->vbl_received);
39177 + return atomic_read_unchecked(&dev_priv->vbl_received);
39178 }
39179
39180 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39181 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39182
39183 status = VIA_READ(VIA_REG_INTERRUPT);
39184 if (status & VIA_IRQ_VBLANK_PENDING) {
39185 - atomic_inc(&dev_priv->vbl_received);
39186 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39187 + atomic_inc_unchecked(&dev_priv->vbl_received);
39188 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39189 do_gettimeofday(&cur_vblank);
39190 if (dev_priv->last_vblank_valid) {
39191 dev_priv->usec_per_vblank =
39192 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39193 dev_priv->last_vblank = cur_vblank;
39194 dev_priv->last_vblank_valid = 1;
39195 }
39196 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39197 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39198 DRM_DEBUG("US per vblank is: %u\n",
39199 dev_priv->usec_per_vblank);
39200 }
39201 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39202
39203 for (i = 0; i < dev_priv->num_irqs; ++i) {
39204 if (status & cur_irq->pending_mask) {
39205 - atomic_inc(&cur_irq->irq_received);
39206 + atomic_inc_unchecked(&cur_irq->irq_received);
39207 DRM_WAKEUP(&cur_irq->irq_queue);
39208 handled = 1;
39209 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39210 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39211 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39212 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39213 masks[irq][4]));
39214 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39215 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39216 } else {
39217 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39218 (((cur_irq_sequence =
39219 - atomic_read(&cur_irq->irq_received)) -
39220 + atomic_read_unchecked(&cur_irq->irq_received)) -
39221 *sequence) <= (1 << 23)));
39222 }
39223 *sequence = cur_irq_sequence;
39224 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39225 }
39226
39227 for (i = 0; i < dev_priv->num_irqs; ++i) {
39228 - atomic_set(&cur_irq->irq_received, 0);
39229 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39230 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39231 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39232 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39233 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39234 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39235 case VIA_IRQ_RELATIVE:
39236 irqwait->request.sequence +=
39237 - atomic_read(&cur_irq->irq_received);
39238 + atomic_read_unchecked(&cur_irq->irq_received);
39239 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39240 case VIA_IRQ_ABSOLUTE:
39241 break;
39242 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39243 index 13aeda7..4a952d1 100644
39244 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39245 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39246 @@ -290,7 +290,7 @@ struct vmw_private {
39247 * Fencing and IRQs.
39248 */
39249
39250 - atomic_t marker_seq;
39251 + atomic_unchecked_t marker_seq;
39252 wait_queue_head_t fence_queue;
39253 wait_queue_head_t fifo_queue;
39254 int fence_queue_waiters; /* Protected by hw_mutex */
39255 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39256 index 3eb1486..0a47ee9 100644
39257 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39258 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39259 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39260 (unsigned int) min,
39261 (unsigned int) fifo->capabilities);
39262
39263 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39264 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39265 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39266 vmw_marker_queue_init(&fifo->marker_queue);
39267 return vmw_fifo_send_fence(dev_priv, &dummy);
39268 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39269 if (reserveable)
39270 iowrite32(bytes, fifo_mem +
39271 SVGA_FIFO_RESERVED);
39272 - return fifo_mem + (next_cmd >> 2);
39273 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39274 } else {
39275 need_bounce = true;
39276 }
39277 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39278
39279 fm = vmw_fifo_reserve(dev_priv, bytes);
39280 if (unlikely(fm == NULL)) {
39281 - *seqno = atomic_read(&dev_priv->marker_seq);
39282 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39283 ret = -ENOMEM;
39284 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39285 false, 3*HZ);
39286 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39287 }
39288
39289 do {
39290 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39291 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39292 } while (*seqno == 0);
39293
39294 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39295 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39296 index c509d40..3b640c3 100644
39297 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39298 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39299 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39300 int ret;
39301
39302 num_clips = arg->num_clips;
39303 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39304 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39305
39306 if (unlikely(num_clips == 0))
39307 return 0;
39308 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39309 int ret;
39310
39311 num_clips = arg->num_clips;
39312 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39313 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39314
39315 if (unlikely(num_clips == 0))
39316 return 0;
39317 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39318 index 4640adb..e1384ed 100644
39319 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39320 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39321 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39322 * emitted. Then the fence is stale and signaled.
39323 */
39324
39325 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39326 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39327 > VMW_FENCE_WRAP);
39328
39329 return ret;
39330 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39331
39332 if (fifo_idle)
39333 down_read(&fifo_state->rwsem);
39334 - signal_seq = atomic_read(&dev_priv->marker_seq);
39335 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39336 ret = 0;
39337
39338 for (;;) {
39339 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39340 index 8a8725c2..afed796 100644
39341 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39342 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39343 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39344 while (!vmw_lag_lt(queue, us)) {
39345 spin_lock(&queue->lock);
39346 if (list_empty(&queue->head))
39347 - seqno = atomic_read(&dev_priv->marker_seq);
39348 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39349 else {
39350 marker = list_first_entry(&queue->head,
39351 struct vmw_marker, head);
39352 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39353 index 5360e5a..c2c0d26 100644
39354 --- a/drivers/gpu/host1x/drm/dc.c
39355 +++ b/drivers/gpu/host1x/drm/dc.c
39356 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39357 }
39358
39359 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39360 - dc->debugfs_files[i].data = dc;
39361 + *(void **)&dc->debugfs_files[i].data = dc;
39362
39363 err = drm_debugfs_create_files(dc->debugfs_files,
39364 ARRAY_SIZE(debugfs_files),
39365 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39366 index 36668d1..9f4ccb0 100644
39367 --- a/drivers/hid/hid-core.c
39368 +++ b/drivers/hid/hid-core.c
39369 @@ -63,6 +63,8 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type,
39370 struct hid_report_enum *report_enum = device->report_enum + type;
39371 struct hid_report *report;
39372
39373 + if (id >= HID_MAX_IDS)
39374 + return NULL;
39375 if (report_enum->report_id_hash[id])
39376 return report_enum->report_id_hash[id];
39377
39378 @@ -404,8 +406,10 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
39379
39380 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
39381 parser->global.report_id = item_udata(item);
39382 - if (parser->global.report_id == 0) {
39383 - hid_err(parser->device, "report_id 0 is invalid\n");
39384 + if (parser->global.report_id == 0 ||
39385 + parser->global.report_id >= HID_MAX_IDS) {
39386 + hid_err(parser->device, "report_id %u is invalid\n",
39387 + parser->global.report_id);
39388 return -1;
39389 }
39390 return 0;
39391 @@ -575,7 +579,7 @@ static void hid_close_report(struct hid_device *device)
39392 for (i = 0; i < HID_REPORT_TYPES; i++) {
39393 struct hid_report_enum *report_enum = device->report_enum + i;
39394
39395 - for (j = 0; j < 256; j++) {
39396 + for (j = 0; j < HID_MAX_IDS; j++) {
39397 struct hid_report *report = report_enum->report_id_hash[j];
39398 if (report)
39399 hid_free_report(report);
39400 @@ -755,6 +759,56 @@ int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
39401 }
39402 EXPORT_SYMBOL_GPL(hid_parse_report);
39403
39404 +static const char * const hid_report_names[] = {
39405 + "HID_INPUT_REPORT",
39406 + "HID_OUTPUT_REPORT",
39407 + "HID_FEATURE_REPORT",
39408 +};
39409 +/**
39410 + * hid_validate_report - validate existing device report
39411 + *
39412 + * @device: hid device
39413 + * @type: which report type to examine
39414 + * @id: which report ID to examine (0 for first)
39415 + * @fields: expected number of fields
39416 + * @report_counts: expected number of values per field
39417 + *
39418 + * Validate the report details after parsing.
39419 + */
39420 +struct hid_report *hid_validate_report(struct hid_device *hid,
39421 + unsigned int type, unsigned int id,
39422 + unsigned int fields,
39423 + unsigned int report_counts)
39424 +{
39425 + struct hid_report *report;
39426 + unsigned int i;
39427 +
39428 + if (type > HID_FEATURE_REPORT) {
39429 + hid_err(hid, "invalid HID report %u\n", type);
39430 + return NULL;
39431 + }
39432 +
39433 + report = hid->report_enum[type].report_id_hash[id];
39434 + if (!report) {
39435 + hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
39436 + return NULL;
39437 + }
39438 + if (report->maxfield < fields) {
39439 + hid_err(hid, "not enough fields in %s %u\n",
39440 + hid_report_names[type], id);
39441 + return NULL;
39442 + }
39443 + for (i = 0; i < fields; i++) {
39444 + if (report->field[i]->report_count < report_counts) {
39445 + hid_err(hid, "not enough values in %s %u fields\n",
39446 + hid_report_names[type], id);
39447 + return NULL;
39448 + }
39449 + }
39450 + return report;
39451 +}
39452 +EXPORT_SYMBOL_GPL(hid_validate_report);
39453 +
39454 /**
39455 * hid_open_report - open a driver-specific device report
39456 *
39457 @@ -1152,7 +1206,12 @@ EXPORT_SYMBOL_GPL(hid_output_report);
39458
39459 int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
39460 {
39461 - unsigned size = field->report_size;
39462 + unsigned size;
39463 +
39464 + if (!field)
39465 + return -1;
39466 +
39467 + size = field->report_size;
39468
39469 hid_dump_input(field->report->device, field->usage + offset, value);
39470
39471 @@ -2285,7 +2344,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39472
39473 int hid_add_device(struct hid_device *hdev)
39474 {
39475 - static atomic_t id = ATOMIC_INIT(0);
39476 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39477 int ret;
39478
39479 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39480 @@ -2319,7 +2378,7 @@ int hid_add_device(struct hid_device *hdev)
39481 /* XXX hack, any other cleaner solution after the driver core
39482 * is converted to allow more than 20 bytes as the device name? */
39483 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39484 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39485 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39486
39487 hid_debug_register(hdev, dev_name(&hdev->dev));
39488 ret = device_add(&hdev->dev);
39489 diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
39490 index 07837f5..b697ada 100644
39491 --- a/drivers/hid/hid-lenovo-tpkbd.c
39492 +++ b/drivers/hid/hid-lenovo-tpkbd.c
39493 @@ -341,6 +341,11 @@ static int tpkbd_probe_tp(struct hid_device *hdev)
39494 char *name_mute, *name_micmute;
39495 int ret;
39496
39497 + /* Validate required reports. */
39498 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, 4, 4, 1) ||
39499 + !hid_validate_report(hdev, HID_OUTPUT_REPORT, 3, 1, 2))
39500 + return -ENODEV;
39501 +
39502 if (sysfs_create_group(&hdev->dev.kobj,
39503 &tpkbd_attr_group_pointer)) {
39504 hid_warn(hdev, "Could not create sysfs group\n");
39505 diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
39506 index b3cd150..9805197 100644
39507 --- a/drivers/hid/hid-lg2ff.c
39508 +++ b/drivers/hid/hid-lg2ff.c
39509 @@ -64,26 +64,13 @@ int lg2ff_init(struct hid_device *hid)
39510 struct hid_report *report;
39511 struct hid_input *hidinput = list_entry(hid->inputs.next,
39512 struct hid_input, list);
39513 - struct list_head *report_list =
39514 - &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39515 struct input_dev *dev = hidinput->input;
39516 int error;
39517
39518 - if (list_empty(report_list)) {
39519 - hid_err(hid, "no output report found\n");
39520 + /* Check that the report looks ok */
39521 + report = hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7);
39522 + if (!report)
39523 return -ENODEV;
39524 - }
39525 -
39526 - report = list_entry(report_list->next, struct hid_report, list);
39527 -
39528 - if (report->maxfield < 1) {
39529 - hid_err(hid, "output report is empty\n");
39530 - return -ENODEV;
39531 - }
39532 - if (report->field[0]->report_count < 7) {
39533 - hid_err(hid, "not enough values in the field\n");
39534 - return -ENODEV;
39535 - }
39536
39537 lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL);
39538 if (!lg2ff)
39539 diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c
39540 index e52f181..53ac79b 100644
39541 --- a/drivers/hid/hid-lg3ff.c
39542 +++ b/drivers/hid/hid-lg3ff.c
39543 @@ -66,10 +66,11 @@ static int hid_lg3ff_play(struct input_dev *dev, void *data,
39544 int x, y;
39545
39546 /*
39547 - * Maxusage should always be 63 (maximum fields)
39548 - * likely a better way to ensure this data is clean
39549 + * Available values in the field should always be 63, but we only use up to
39550 + * 35. Instead, clear the entire area, however big it is.
39551 */
39552 - memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage);
39553 + memset(report->field[0]->value, 0,
39554 + sizeof(__s32) * report->field[0]->report_count);
39555
39556 switch (effect->type) {
39557 case FF_CONSTANT:
39558 @@ -129,32 +130,14 @@ static const signed short ff3_joystick_ac[] = {
39559 int lg3ff_init(struct hid_device *hid)
39560 {
39561 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
39562 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39563 struct input_dev *dev = hidinput->input;
39564 - struct hid_report *report;
39565 - struct hid_field *field;
39566 const signed short *ff_bits = ff3_joystick_ac;
39567 int error;
39568 int i;
39569
39570 - /* Find the report to use */
39571 - if (list_empty(report_list)) {
39572 - hid_err(hid, "No output report found\n");
39573 - return -1;
39574 - }
39575 -
39576 /* Check that the report looks ok */
39577 - report = list_entry(report_list->next, struct hid_report, list);
39578 - if (!report) {
39579 - hid_err(hid, "NULL output report\n");
39580 - return -1;
39581 - }
39582 -
39583 - field = report->field[0];
39584 - if (!field) {
39585 - hid_err(hid, "NULL field\n");
39586 - return -1;
39587 - }
39588 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 35))
39589 + return -ENODEV;
39590
39591 /* Assume single fixed device G940 */
39592 for (i = 0; ff_bits[i] >= 0; i++)
39593 diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
39594 index 0ddae2a..8b89f0f 100644
39595 --- a/drivers/hid/hid-lg4ff.c
39596 +++ b/drivers/hid/hid-lg4ff.c
39597 @@ -484,34 +484,16 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde
39598 int lg4ff_init(struct hid_device *hid)
39599 {
39600 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
39601 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39602 struct input_dev *dev = hidinput->input;
39603 - struct hid_report *report;
39604 - struct hid_field *field;
39605 struct lg4ff_device_entry *entry;
39606 struct lg_drv_data *drv_data;
39607 struct usb_device_descriptor *udesc;
39608 int error, i, j;
39609 __u16 bcdDevice, rev_maj, rev_min;
39610
39611 - /* Find the report to use */
39612 - if (list_empty(report_list)) {
39613 - hid_err(hid, "No output report found\n");
39614 - return -1;
39615 - }
39616 -
39617 /* Check that the report looks ok */
39618 - report = list_entry(report_list->next, struct hid_report, list);
39619 - if (!report) {
39620 - hid_err(hid, "NULL output report\n");
39621 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7))
39622 return -1;
39623 - }
39624 -
39625 - field = report->field[0];
39626 - if (!field) {
39627 - hid_err(hid, "NULL field\n");
39628 - return -1;
39629 - }
39630
39631 /* Check what wheel has been connected */
39632 for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) {
39633 diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
39634 index d7ea8c8..a84fb40 100644
39635 --- a/drivers/hid/hid-lgff.c
39636 +++ b/drivers/hid/hid-lgff.c
39637 @@ -128,27 +128,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
39638 int lgff_init(struct hid_device* hid)
39639 {
39640 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
39641 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39642 struct input_dev *dev = hidinput->input;
39643 - struct hid_report *report;
39644 - struct hid_field *field;
39645 const signed short *ff_bits = ff_joystick;
39646 int error;
39647 int i;
39648
39649 - /* Find the report to use */
39650 - if (list_empty(report_list)) {
39651 - hid_err(hid, "No output report found\n");
39652 - return -1;
39653 - }
39654 -
39655 /* Check that the report looks ok */
39656 - report = list_entry(report_list->next, struct hid_report, list);
39657 - field = report->field[0];
39658 - if (!field) {
39659 - hid_err(hid, "NULL field\n");
39660 - return -1;
39661 - }
39662 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7))
39663 + return -ENODEV;
39664
39665 for (i = 0; i < ARRAY_SIZE(devices); i++) {
39666 if (dev->id.vendor == devices[i].idVendor &&
39667 diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
39668 index cd33084..7b99c2a 100644
39669 --- a/drivers/hid/hid-logitech-dj.c
39670 +++ b/drivers/hid/hid-logitech-dj.c
39671 @@ -461,7 +461,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
39672 struct hid_report *report;
39673 struct hid_report_enum *output_report_enum;
39674 u8 *data = (u8 *)(&dj_report->device_index);
39675 - int i;
39676 + unsigned int i, length;
39677
39678 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
39679 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT];
39680 @@ -471,7 +471,9 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
39681 return -ENODEV;
39682 }
39683
39684 - for (i = 0; i < report->field[0]->report_count; i++)
39685 + length = min_t(size_t, sizeof(*dj_report) - 1,
39686 + report->field[0]->report_count);
39687 + for (i = 0; i < length; i++)
39688 report->field[0]->value[i] = data[i];
39689
39690 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
39691 @@ -783,6 +785,12 @@ static int logi_dj_probe(struct hid_device *hdev,
39692 goto hid_parse_fail;
39693 }
39694
39695 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT,
39696 + 1, 3)) {
39697 + retval = -ENODEV;
39698 + goto hid_parse_fail;
39699 + }
39700 +
39701 /* Starts the usb device and connects to upper interfaces hiddev and
39702 * hidraw */
39703 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
39704 diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
39705 index cb0e361..2aa275e 100644
39706 --- a/drivers/hid/hid-multitouch.c
39707 +++ b/drivers/hid/hid-multitouch.c
39708 @@ -330,9 +330,18 @@ static void mt_feature_mapping(struct hid_device *hdev,
39709 break;
39710 }
39711 }
39712 + /* Ignore if value index is out of bounds. */
39713 + if (td->inputmode_index < 0 ||
39714 + td->inputmode_index >= field->report_count) {
39715 + dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n");
39716 + td->inputmode = -1;
39717 + }
39718
39719 break;
39720 case HID_DG_CONTACTMAX:
39721 + /* Ignore if value count is out of bounds. */
39722 + if (field->report_count < 1)
39723 + break;
39724 td->maxcontact_report_id = field->report->id;
39725 td->maxcontacts = field->value[0];
39726 if (!td->maxcontacts &&
39727 @@ -743,15 +752,21 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
39728 unsigned count;
39729 int r, n;
39730
39731 + if (report->maxfield == 0)
39732 + return;
39733 +
39734 /*
39735 * Includes multi-packet support where subsequent
39736 * packets are sent with zero contactcount.
39737 */
39738 - if (td->cc_index >= 0) {
39739 - struct hid_field *field = report->field[td->cc_index];
39740 - int value = field->value[td->cc_value_index];
39741 - if (value)
39742 - td->num_expected = value;
39743 + if (td->cc_index >= 0 && td->cc_index < report->maxfield) {
39744 + field = report->field[td->cc_index];
39745 + if (td->cc_value_index >= 0 &&
39746 + td->cc_value_index < field->report_count) {
39747 + int value = field->value[td->cc_value_index];
39748 + if (value)
39749 + td->num_expected = value;
39750 + }
39751 }
39752
39753 for (r = 0; r < report->maxfield; r++) {
39754 diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
39755 index ef95102..5482156 100644
39756 --- a/drivers/hid/hid-ntrig.c
39757 +++ b/drivers/hid/hid-ntrig.c
39758 @@ -115,7 +115,8 @@ static inline int ntrig_get_mode(struct hid_device *hdev)
39759 struct hid_report *report = hdev->report_enum[HID_FEATURE_REPORT].
39760 report_id_hash[0x0d];
39761
39762 - if (!report)
39763 + if (!report || report->maxfield < 1 ||
39764 + report->field[0]->report_count < 1)
39765 return -EINVAL;
39766
39767 hid_hw_request(hdev, report, HID_REQ_GET_REPORT);
39768 diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
39769 index b48092d..72bba1e 100644
39770 --- a/drivers/hid/hid-picolcd_core.c
39771 +++ b/drivers/hid/hid-picolcd_core.c
39772 @@ -290,7 +290,7 @@ static ssize_t picolcd_operation_mode_store(struct device *dev,
39773 buf += 10;
39774 cnt -= 10;
39775 }
39776 - if (!report)
39777 + if (!report || report->maxfield < 1)
39778 return -EINVAL;
39779
39780 while (cnt > 0 && (buf[cnt-1] == '\n' || buf[cnt-1] == '\r'))
39781 diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
39782 index d29112f..2dcd7d9 100644
39783 --- a/drivers/hid/hid-pl.c
39784 +++ b/drivers/hid/hid-pl.c
39785 @@ -132,8 +132,14 @@ static int plff_init(struct hid_device *hid)
39786 strong = &report->field[0]->value[2];
39787 weak = &report->field[0]->value[3];
39788 debug("detected single-field device");
39789 - } else if (report->maxfield >= 4 && report->field[0]->maxusage == 1 &&
39790 - report->field[0]->usage[0].hid == (HID_UP_LED | 0x43)) {
39791 + } else if (report->field[0]->maxusage == 1 &&
39792 + report->field[0]->usage[0].hid ==
39793 + (HID_UP_LED | 0x43) &&
39794 + report->maxfield >= 4 &&
39795 + report->field[0]->report_count >= 1 &&
39796 + report->field[1]->report_count >= 1 &&
39797 + report->field[2]->report_count >= 1 &&
39798 + report->field[3]->report_count >= 1) {
39799 report->field[0]->value[0] = 0x00;
39800 report->field[1]->value[0] = 0x00;
39801 strong = &report->field[2]->value[0];
39802 diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
39803 index ca749810..aa34755 100644
39804 --- a/drivers/hid/hid-sensor-hub.c
39805 +++ b/drivers/hid/hid-sensor-hub.c
39806 @@ -221,7 +221,8 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
39807
39808 mutex_lock(&data->mutex);
39809 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
39810 - if (!report || (field_index >= report->maxfield)) {
39811 + if (!report || (field_index >= report->maxfield) ||
39812 + report->field[field_index]->report_count < 1) {
39813 ret = -EINVAL;
39814 goto done_proc;
39815 }
39816 diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c
39817 index d164911..ef42e86 100644
39818 --- a/drivers/hid/hid-steelseries.c
39819 +++ b/drivers/hid/hid-steelseries.c
39820 @@ -249,6 +249,11 @@ static int steelseries_srws1_probe(struct hid_device *hdev,
39821 goto err_free;
39822 }
39823
39824 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, 0, 1, 16)) {
39825 + ret = -ENODEV;
39826 + goto err_free;
39827 + }
39828 +
39829 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
39830 if (ret) {
39831 hid_err(hdev, "hw start failed\n");
39832 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39833 index c13fb5b..55a3802 100644
39834 --- a/drivers/hid/hid-wiimote-debug.c
39835 +++ b/drivers/hid/hid-wiimote-debug.c
39836 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39837 else if (size == 0)
39838 return -EIO;
39839
39840 - if (copy_to_user(u, buf, size))
39841 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39842 return -EFAULT;
39843
39844 *off += size;
39845 diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
39846 index 6ec28a3..b124991 100644
39847 --- a/drivers/hid/hid-zpff.c
39848 +++ b/drivers/hid/hid-zpff.c
39849 @@ -68,22 +68,12 @@ static int zpff_init(struct hid_device *hid)
39850 struct hid_report *report;
39851 struct hid_input *hidinput = list_entry(hid->inputs.next,
39852 struct hid_input, list);
39853 - struct list_head *report_list =
39854 - &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39855 struct input_dev *dev = hidinput->input;
39856 int error;
39857
39858 - if (list_empty(report_list)) {
39859 - hid_err(hid, "no output report found\n");
39860 + report = hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 4, 1);
39861 + if (!report)
39862 return -ENODEV;
39863 - }
39864 -
39865 - report = list_entry(report_list->next, struct hid_report, list);
39866 -
39867 - if (report->maxfield < 4) {
39868 - hid_err(hid, "not enough fields in report\n");
39869 - return -ENODEV;
39870 - }
39871
39872 zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL);
39873 if (!zpff)
39874 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39875 index fc307e0..2b255e8 100644
39876 --- a/drivers/hid/uhid.c
39877 +++ b/drivers/hid/uhid.c
39878 @@ -47,7 +47,7 @@ struct uhid_device {
39879 struct mutex report_lock;
39880 wait_queue_head_t report_wait;
39881 atomic_t report_done;
39882 - atomic_t report_id;
39883 + atomic_unchecked_t report_id;
39884 struct uhid_event report_buf;
39885 };
39886
39887 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39888
39889 spin_lock_irqsave(&uhid->qlock, flags);
39890 ev->type = UHID_FEATURE;
39891 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39892 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39893 ev->u.feature.rnum = rnum;
39894 ev->u.feature.rtype = report_type;
39895
39896 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39897 spin_lock_irqsave(&uhid->qlock, flags);
39898
39899 /* id for old report; drop it silently */
39900 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39901 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39902 goto unlock;
39903 if (atomic_read(&uhid->report_done))
39904 goto unlock;
39905 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39906 index 6de6c98..18319e9 100644
39907 --- a/drivers/hv/channel.c
39908 +++ b/drivers/hv/channel.c
39909 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39910 int ret = 0;
39911 int t;
39912
39913 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39914 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39915 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39916 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39917
39918 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39919 if (ret)
39920 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39921 index 88f4096..e50452e 100644
39922 --- a/drivers/hv/hv.c
39923 +++ b/drivers/hv/hv.c
39924 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39925 u64 output_address = (output) ? virt_to_phys(output) : 0;
39926 u32 output_address_hi = output_address >> 32;
39927 u32 output_address_lo = output_address & 0xFFFFFFFF;
39928 - void *hypercall_page = hv_context.hypercall_page;
39929 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39930
39931 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39932 "=a"(hv_status_lo) : "d" (control_hi),
39933 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39934 index deb5c25..ed2d4fd 100644
39935 --- a/drivers/hv/hv_balloon.c
39936 +++ b/drivers/hv/hv_balloon.c
39937 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39938
39939 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39940 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39941 -static atomic_t trans_id = ATOMIC_INIT(0);
39942 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39943
39944 static int dm_ring_size = (5 * PAGE_SIZE);
39945
39946 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39947 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39948 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39949 resp.hdr.size = sizeof(struct dm_hot_add_response);
39950 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39951 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39952
39953 #ifdef CONFIG_MEMORY_HOTPLUG
39954 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39955 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39956 memset(&status, 0, sizeof(struct dm_status));
39957 status.hdr.type = DM_STATUS_REPORT;
39958 status.hdr.size = sizeof(struct dm_status);
39959 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39960 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39961
39962 /*
39963 * The host expects the guest to report free memory.
39964 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39965 * send the status. This can happen if we were interrupted
39966 * after we picked our transaction ID.
39967 */
39968 - if (status.hdr.trans_id != atomic_read(&trans_id))
39969 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39970 return;
39971
39972 vmbus_sendpacket(dm->dev->channel, &status,
39973 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39974 bl_resp = (struct dm_balloon_response *)send_buffer;
39975 memset(send_buffer, 0, PAGE_SIZE);
39976 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39977 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39978 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39979 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39980 bl_resp->more_pages = 1;
39981
39982 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39983
39984 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39985 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39986 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39987 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39988 resp.hdr.size = sizeof(struct dm_unballoon_response);
39989
39990 vmbus_sendpacket(dm_device.dev->channel, &resp,
39991 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39992 memset(&version_req, 0, sizeof(struct dm_version_request));
39993 version_req.hdr.type = DM_VERSION_REQUEST;
39994 version_req.hdr.size = sizeof(struct dm_version_request);
39995 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39996 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39997 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39998 version_req.is_last_attempt = 1;
39999
40000 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
40001 memset(&version_req, 0, sizeof(struct dm_version_request));
40002 version_req.hdr.type = DM_VERSION_REQUEST;
40003 version_req.hdr.size = sizeof(struct dm_version_request);
40004 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40005 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40006 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
40007 version_req.is_last_attempt = 0;
40008
40009 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
40010 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
40011 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
40012 cap_msg.hdr.size = sizeof(struct dm_capabilities);
40013 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
40014 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40015
40016 cap_msg.caps.cap_bits.balloon = 1;
40017 cap_msg.caps.cap_bits.hot_add = 1;
40018 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
40019 index d84918f..7f38f9f 100644
40020 --- a/drivers/hv/hyperv_vmbus.h
40021 +++ b/drivers/hv/hyperv_vmbus.h
40022 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
40023 struct vmbus_connection {
40024 enum vmbus_connect_state conn_state;
40025
40026 - atomic_t next_gpadl_handle;
40027 + atomic_unchecked_t next_gpadl_handle;
40028
40029 /*
40030 * Represents channel interrupts. Each bit position represents a
40031 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
40032 index e8e071f..5b4b245 100644
40033 --- a/drivers/hv/vmbus_drv.c
40034 +++ b/drivers/hv/vmbus_drv.c
40035 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
40036 {
40037 int ret = 0;
40038
40039 - static atomic_t device_num = ATOMIC_INIT(0);
40040 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
40041
40042 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
40043 - atomic_inc_return(&device_num));
40044 + atomic_inc_return_unchecked(&device_num));
40045
40046 child_device_obj->device.bus = &hv_bus;
40047 child_device_obj->device.parent = &hv_acpi_dev->dev;
40048 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
40049 index 6351aba..dc4aaf4 100644
40050 --- a/drivers/hwmon/acpi_power_meter.c
40051 +++ b/drivers/hwmon/acpi_power_meter.c
40052 @@ -117,7 +117,7 @@ struct sensor_template {
40053 struct device_attribute *devattr,
40054 const char *buf, size_t count);
40055 int index;
40056 -};
40057 +} __do_const;
40058
40059 /* Averaging interval */
40060 static int update_avg_interval(struct acpi_power_meter_resource *resource)
40061 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
40062 struct sensor_template *attrs)
40063 {
40064 struct device *dev = &resource->acpi_dev->dev;
40065 - struct sensor_device_attribute *sensors =
40066 + sensor_device_attribute_no_const *sensors =
40067 &resource->sensors[resource->num_sensors];
40068 int res = 0;
40069
40070 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
40071 index 62c2e32..8f2859a 100644
40072 --- a/drivers/hwmon/applesmc.c
40073 +++ b/drivers/hwmon/applesmc.c
40074 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
40075 {
40076 struct applesmc_node_group *grp;
40077 struct applesmc_dev_attr *node;
40078 - struct attribute *attr;
40079 + attribute_no_const *attr;
40080 int ret, i;
40081
40082 for (grp = groups; grp->format; grp++) {
40083 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
40084 index b25c643..a13460d 100644
40085 --- a/drivers/hwmon/asus_atk0110.c
40086 +++ b/drivers/hwmon/asus_atk0110.c
40087 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
40088 struct atk_sensor_data {
40089 struct list_head list;
40090 struct atk_data *data;
40091 - struct device_attribute label_attr;
40092 - struct device_attribute input_attr;
40093 - struct device_attribute limit1_attr;
40094 - struct device_attribute limit2_attr;
40095 + device_attribute_no_const label_attr;
40096 + device_attribute_no_const input_attr;
40097 + device_attribute_no_const limit1_attr;
40098 + device_attribute_no_const limit2_attr;
40099 char label_attr_name[ATTR_NAME_SIZE];
40100 char input_attr_name[ATTR_NAME_SIZE];
40101 char limit1_attr_name[ATTR_NAME_SIZE];
40102 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
40103 static struct device_attribute atk_name_attr =
40104 __ATTR(name, 0444, atk_name_show, NULL);
40105
40106 -static void atk_init_attribute(struct device_attribute *attr, char *name,
40107 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
40108 sysfs_show_func show)
40109 {
40110 sysfs_attr_init(&attr->attr);
40111 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
40112 index 2e5e2dc..5208b31 100644
40113 --- a/drivers/hwmon/coretemp.c
40114 +++ b/drivers/hwmon/coretemp.c
40115 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
40116 return NOTIFY_OK;
40117 }
40118
40119 -static struct notifier_block coretemp_cpu_notifier __refdata = {
40120 +static struct notifier_block coretemp_cpu_notifier = {
40121 .notifier_call = coretemp_cpu_callback,
40122 };
40123
40124 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
40125 index 1429f6e..ee03d59 100644
40126 --- a/drivers/hwmon/ibmaem.c
40127 +++ b/drivers/hwmon/ibmaem.c
40128 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
40129 struct aem_rw_sensor_template *rw)
40130 {
40131 struct device *dev = &data->pdev->dev;
40132 - struct sensor_device_attribute *sensors = data->sensors;
40133 + sensor_device_attribute_no_const *sensors = data->sensors;
40134 int err;
40135
40136 /* Set up read-only sensors */
40137 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
40138 index 708081b..fe2d4ab 100644
40139 --- a/drivers/hwmon/iio_hwmon.c
40140 +++ b/drivers/hwmon/iio_hwmon.c
40141 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
40142 {
40143 struct device *dev = &pdev->dev;
40144 struct iio_hwmon_state *st;
40145 - struct sensor_device_attribute *a;
40146 + sensor_device_attribute_no_const *a;
40147 int ret, i;
40148 int in_i = 1, temp_i = 1, curr_i = 1;
40149 enum iio_chan_type type;
40150 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
40151 index 9add6092..ee7ba3f 100644
40152 --- a/drivers/hwmon/pmbus/pmbus_core.c
40153 +++ b/drivers/hwmon/pmbus/pmbus_core.c
40154 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
40155 return 0;
40156 }
40157
40158 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40159 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
40160 const char *name,
40161 umode_t mode,
40162 ssize_t (*show)(struct device *dev,
40163 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40164 dev_attr->store = store;
40165 }
40166
40167 -static void pmbus_attr_init(struct sensor_device_attribute *a,
40168 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
40169 const char *name,
40170 umode_t mode,
40171 ssize_t (*show)(struct device *dev,
40172 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
40173 u16 reg, u8 mask)
40174 {
40175 struct pmbus_boolean *boolean;
40176 - struct sensor_device_attribute *a;
40177 + sensor_device_attribute_no_const *a;
40178
40179 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
40180 if (!boolean)
40181 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
40182 bool update, bool readonly)
40183 {
40184 struct pmbus_sensor *sensor;
40185 - struct device_attribute *a;
40186 + device_attribute_no_const *a;
40187
40188 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
40189 if (!sensor)
40190 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
40191 const char *lstring, int index)
40192 {
40193 struct pmbus_label *label;
40194 - struct device_attribute *a;
40195 + device_attribute_no_const *a;
40196
40197 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
40198 if (!label)
40199 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
40200 index 2507f90..1645765 100644
40201 --- a/drivers/hwmon/sht15.c
40202 +++ b/drivers/hwmon/sht15.c
40203 @@ -169,7 +169,7 @@ struct sht15_data {
40204 int supply_uv;
40205 bool supply_uv_valid;
40206 struct work_struct update_supply_work;
40207 - atomic_t interrupt_handled;
40208 + atomic_unchecked_t interrupt_handled;
40209 };
40210
40211 /**
40212 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
40213 ret = gpio_direction_input(data->pdata->gpio_data);
40214 if (ret)
40215 return ret;
40216 - atomic_set(&data->interrupt_handled, 0);
40217 + atomic_set_unchecked(&data->interrupt_handled, 0);
40218
40219 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40220 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40221 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40222 /* Only relevant if the interrupt hasn't occurred. */
40223 - if (!atomic_read(&data->interrupt_handled))
40224 + if (!atomic_read_unchecked(&data->interrupt_handled))
40225 schedule_work(&data->read_work);
40226 }
40227 ret = wait_event_timeout(data->wait_queue,
40228 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40229
40230 /* First disable the interrupt */
40231 disable_irq_nosync(irq);
40232 - atomic_inc(&data->interrupt_handled);
40233 + atomic_inc_unchecked(&data->interrupt_handled);
40234 /* Then schedule a reading work struct */
40235 if (data->state != SHT15_READING_NOTHING)
40236 schedule_work(&data->read_work);
40237 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40238 * If not, then start the interrupt again - care here as could
40239 * have gone low in meantime so verify it hasn't!
40240 */
40241 - atomic_set(&data->interrupt_handled, 0);
40242 + atomic_set_unchecked(&data->interrupt_handled, 0);
40243 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40244 /* If still not occurred or another handler was scheduled */
40245 if (gpio_get_value(data->pdata->gpio_data)
40246 - || atomic_read(&data->interrupt_handled))
40247 + || atomic_read_unchecked(&data->interrupt_handled))
40248 return;
40249 }
40250
40251 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40252 index 38944e9..ae9e5ed 100644
40253 --- a/drivers/hwmon/via-cputemp.c
40254 +++ b/drivers/hwmon/via-cputemp.c
40255 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
40256 return NOTIFY_OK;
40257 }
40258
40259 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40260 +static struct notifier_block via_cputemp_cpu_notifier = {
40261 .notifier_call = via_cputemp_cpu_callback,
40262 };
40263
40264 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40265 index 07f01ac..d79ad3d 100644
40266 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40267 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40268 @@ -43,7 +43,7 @@
40269 extern struct i2c_adapter amd756_smbus;
40270
40271 static struct i2c_adapter *s4882_adapter;
40272 -static struct i2c_algorithm *s4882_algo;
40273 +static i2c_algorithm_no_const *s4882_algo;
40274
40275 /* Wrapper access functions for multiplexed SMBus */
40276 static DEFINE_MUTEX(amd756_lock);
40277 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40278 index 2ca268d..c6acbdf 100644
40279 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40280 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40281 @@ -41,7 +41,7 @@
40282 extern struct i2c_adapter *nforce2_smbus;
40283
40284 static struct i2c_adapter *s4985_adapter;
40285 -static struct i2c_algorithm *s4985_algo;
40286 +static i2c_algorithm_no_const *s4985_algo;
40287
40288 /* Wrapper access functions for multiplexed SMBus */
40289 static DEFINE_MUTEX(nforce2_lock);
40290 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40291 index c3ccdea..5b3dc1a 100644
40292 --- a/drivers/i2c/i2c-dev.c
40293 +++ b/drivers/i2c/i2c-dev.c
40294 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40295 break;
40296 }
40297
40298 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40299 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40300 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40301 if (IS_ERR(rdwr_pa[i].buf)) {
40302 res = PTR_ERR(rdwr_pa[i].buf);
40303 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40304 index 0b510ba..4fbb5085 100644
40305 --- a/drivers/ide/ide-cd.c
40306 +++ b/drivers/ide/ide-cd.c
40307 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40308 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40309 if ((unsigned long)buf & alignment
40310 || blk_rq_bytes(rq) & q->dma_pad_mask
40311 - || object_is_on_stack(buf))
40312 + || object_starts_on_stack(buf))
40313 drive->dma = 0;
40314 }
40315 }
40316 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40317 index e145931..08bfc59 100644
40318 --- a/drivers/iio/industrialio-core.c
40319 +++ b/drivers/iio/industrialio-core.c
40320 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40321 }
40322
40323 static
40324 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40325 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40326 const char *postfix,
40327 struct iio_chan_spec const *chan,
40328 ssize_t (*readfunc)(struct device *dev,
40329 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40330 index 784b97c..c9ceadf 100644
40331 --- a/drivers/infiniband/core/cm.c
40332 +++ b/drivers/infiniband/core/cm.c
40333 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40334
40335 struct cm_counter_group {
40336 struct kobject obj;
40337 - atomic_long_t counter[CM_ATTR_COUNT];
40338 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40339 };
40340
40341 struct cm_counter_attribute {
40342 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40343 struct ib_mad_send_buf *msg = NULL;
40344 int ret;
40345
40346 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40347 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40348 counter[CM_REQ_COUNTER]);
40349
40350 /* Quick state check to discard duplicate REQs. */
40351 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40352 if (!cm_id_priv)
40353 return;
40354
40355 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40356 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40357 counter[CM_REP_COUNTER]);
40358 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40359 if (ret)
40360 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40361 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40362 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40363 spin_unlock_irq(&cm_id_priv->lock);
40364 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40365 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40366 counter[CM_RTU_COUNTER]);
40367 goto out;
40368 }
40369 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40370 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40371 dreq_msg->local_comm_id);
40372 if (!cm_id_priv) {
40373 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40374 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40375 counter[CM_DREQ_COUNTER]);
40376 cm_issue_drep(work->port, work->mad_recv_wc);
40377 return -EINVAL;
40378 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40379 case IB_CM_MRA_REP_RCVD:
40380 break;
40381 case IB_CM_TIMEWAIT:
40382 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40383 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40384 counter[CM_DREQ_COUNTER]);
40385 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40386 goto unlock;
40387 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40388 cm_free_msg(msg);
40389 goto deref;
40390 case IB_CM_DREQ_RCVD:
40391 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40392 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40393 counter[CM_DREQ_COUNTER]);
40394 goto unlock;
40395 default:
40396 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40397 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40398 cm_id_priv->msg, timeout)) {
40399 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40400 - atomic_long_inc(&work->port->
40401 + atomic_long_inc_unchecked(&work->port->
40402 counter_group[CM_RECV_DUPLICATES].
40403 counter[CM_MRA_COUNTER]);
40404 goto out;
40405 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40406 break;
40407 case IB_CM_MRA_REQ_RCVD:
40408 case IB_CM_MRA_REP_RCVD:
40409 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40410 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40411 counter[CM_MRA_COUNTER]);
40412 /* fall through */
40413 default:
40414 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40415 case IB_CM_LAP_IDLE:
40416 break;
40417 case IB_CM_MRA_LAP_SENT:
40418 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40419 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40420 counter[CM_LAP_COUNTER]);
40421 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40422 goto unlock;
40423 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40424 cm_free_msg(msg);
40425 goto deref;
40426 case IB_CM_LAP_RCVD:
40427 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40428 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40429 counter[CM_LAP_COUNTER]);
40430 goto unlock;
40431 default:
40432 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40433 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40434 if (cur_cm_id_priv) {
40435 spin_unlock_irq(&cm.lock);
40436 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40437 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40438 counter[CM_SIDR_REQ_COUNTER]);
40439 goto out; /* Duplicate message. */
40440 }
40441 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40442 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40443 msg->retries = 1;
40444
40445 - atomic_long_add(1 + msg->retries,
40446 + atomic_long_add_unchecked(1 + msg->retries,
40447 &port->counter_group[CM_XMIT].counter[attr_index]);
40448 if (msg->retries)
40449 - atomic_long_add(msg->retries,
40450 + atomic_long_add_unchecked(msg->retries,
40451 &port->counter_group[CM_XMIT_RETRIES].
40452 counter[attr_index]);
40453
40454 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40455 }
40456
40457 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40458 - atomic_long_inc(&port->counter_group[CM_RECV].
40459 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40460 counter[attr_id - CM_ATTR_ID_OFFSET]);
40461
40462 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40463 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40464 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40465
40466 return sprintf(buf, "%ld\n",
40467 - atomic_long_read(&group->counter[cm_attr->index]));
40468 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40469 }
40470
40471 static const struct sysfs_ops cm_counter_ops = {
40472 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40473 index 9f5ad7c..588cd84 100644
40474 --- a/drivers/infiniband/core/fmr_pool.c
40475 +++ b/drivers/infiniband/core/fmr_pool.c
40476 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40477
40478 struct task_struct *thread;
40479
40480 - atomic_t req_ser;
40481 - atomic_t flush_ser;
40482 + atomic_unchecked_t req_ser;
40483 + atomic_unchecked_t flush_ser;
40484
40485 wait_queue_head_t force_wait;
40486 };
40487 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40488 struct ib_fmr_pool *pool = pool_ptr;
40489
40490 do {
40491 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40492 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40493 ib_fmr_batch_release(pool);
40494
40495 - atomic_inc(&pool->flush_ser);
40496 + atomic_inc_unchecked(&pool->flush_ser);
40497 wake_up_interruptible(&pool->force_wait);
40498
40499 if (pool->flush_function)
40500 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40501 }
40502
40503 set_current_state(TASK_INTERRUPTIBLE);
40504 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40505 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40506 !kthread_should_stop())
40507 schedule();
40508 __set_current_state(TASK_RUNNING);
40509 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40510 pool->dirty_watermark = params->dirty_watermark;
40511 pool->dirty_len = 0;
40512 spin_lock_init(&pool->pool_lock);
40513 - atomic_set(&pool->req_ser, 0);
40514 - atomic_set(&pool->flush_ser, 0);
40515 + atomic_set_unchecked(&pool->req_ser, 0);
40516 + atomic_set_unchecked(&pool->flush_ser, 0);
40517 init_waitqueue_head(&pool->force_wait);
40518
40519 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40520 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40521 }
40522 spin_unlock_irq(&pool->pool_lock);
40523
40524 - serial = atomic_inc_return(&pool->req_ser);
40525 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40526 wake_up_process(pool->thread);
40527
40528 if (wait_event_interruptible(pool->force_wait,
40529 - atomic_read(&pool->flush_ser) - serial >= 0))
40530 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40531 return -EINTR;
40532
40533 return 0;
40534 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40535 } else {
40536 list_add_tail(&fmr->list, &pool->dirty_list);
40537 if (++pool->dirty_len >= pool->dirty_watermark) {
40538 - atomic_inc(&pool->req_ser);
40539 + atomic_inc_unchecked(&pool->req_ser);
40540 wake_up_process(pool->thread);
40541 }
40542 }
40543 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40544 index 4cb8eb2..146bf60 100644
40545 --- a/drivers/infiniband/hw/cxgb4/mem.c
40546 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40547 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40548 int err;
40549 struct fw_ri_tpte tpt;
40550 u32 stag_idx;
40551 - static atomic_t key;
40552 + static atomic_unchecked_t key;
40553
40554 if (c4iw_fatal_error(rdev))
40555 return -EIO;
40556 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40557 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40558 rdev->stats.stag.max = rdev->stats.stag.cur;
40559 mutex_unlock(&rdev->stats.lock);
40560 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40561 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40562 }
40563 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40564 __func__, stag_state, type, pdid, stag_idx);
40565 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40566 index 79b3dbc..96e5fcc 100644
40567 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40568 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40569 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40570 struct ib_atomic_eth *ateth;
40571 struct ipath_ack_entry *e;
40572 u64 vaddr;
40573 - atomic64_t *maddr;
40574 + atomic64_unchecked_t *maddr;
40575 u64 sdata;
40576 u32 rkey;
40577 u8 next;
40578 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40579 IB_ACCESS_REMOTE_ATOMIC)))
40580 goto nack_acc_unlck;
40581 /* Perform atomic OP and save result. */
40582 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40583 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40584 sdata = be64_to_cpu(ateth->swap_data);
40585 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40586 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40587 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40588 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40589 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40590 be64_to_cpu(ateth->compare_data),
40591 sdata);
40592 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40593 index 1f95bba..9530f87 100644
40594 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40595 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40596 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40597 unsigned long flags;
40598 struct ib_wc wc;
40599 u64 sdata;
40600 - atomic64_t *maddr;
40601 + atomic64_unchecked_t *maddr;
40602 enum ib_wc_status send_status;
40603
40604 /*
40605 @@ -382,11 +382,11 @@ again:
40606 IB_ACCESS_REMOTE_ATOMIC)))
40607 goto acc_err;
40608 /* Perform atomic OP and save result. */
40609 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40610 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40611 sdata = wqe->wr.wr.atomic.compare_add;
40612 *(u64 *) sqp->s_sge.sge.vaddr =
40613 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40614 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40615 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40616 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40617 sdata, wqe->wr.wr.atomic.swap);
40618 goto send_comp;
40619 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40620 index f2a3f48..673ec79 100644
40621 --- a/drivers/infiniband/hw/mlx4/mad.c
40622 +++ b/drivers/infiniband/hw/mlx4/mad.c
40623 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40624
40625 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40626 {
40627 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40628 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40629 cpu_to_be64(0xff00000000000000LL);
40630 }
40631
40632 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40633 index 25b2cdf..099ff97 100644
40634 --- a/drivers/infiniband/hw/mlx4/mcg.c
40635 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40636 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40637 {
40638 char name[20];
40639
40640 - atomic_set(&ctx->tid, 0);
40641 + atomic_set_unchecked(&ctx->tid, 0);
40642 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40643 ctx->mcg_wq = create_singlethread_workqueue(name);
40644 if (!ctx->mcg_wq)
40645 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40646 index f61ec26..ebf72cf 100644
40647 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40648 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40649 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40650 struct list_head mcg_mgid0_list;
40651 struct workqueue_struct *mcg_wq;
40652 struct mlx4_ib_demux_pv_ctx **tun;
40653 - atomic_t tid;
40654 + atomic_unchecked_t tid;
40655 int flushing; /* flushing the work queue */
40656 };
40657
40658 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40659 index 9d3e5c1..d9afe4a 100644
40660 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40661 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40662 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40663 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40664 }
40665
40666 -int mthca_QUERY_FW(struct mthca_dev *dev)
40667 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40668 {
40669 struct mthca_mailbox *mailbox;
40670 u32 *outbox;
40671 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40672 index ed9a989..e0c5871 100644
40673 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40674 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40675 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40676 return key;
40677 }
40678
40679 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40680 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40681 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40682 {
40683 struct mthca_mailbox *mailbox;
40684 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40685 index 4291410..d2ab1fb 100644
40686 --- a/drivers/infiniband/hw/nes/nes.c
40687 +++ b/drivers/infiniband/hw/nes/nes.c
40688 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40689 LIST_HEAD(nes_adapter_list);
40690 static LIST_HEAD(nes_dev_list);
40691
40692 -atomic_t qps_destroyed;
40693 +atomic_unchecked_t qps_destroyed;
40694
40695 static unsigned int ee_flsh_adapter;
40696 static unsigned int sysfs_nonidx_addr;
40697 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40698 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40699 struct nes_adapter *nesadapter = nesdev->nesadapter;
40700
40701 - atomic_inc(&qps_destroyed);
40702 + atomic_inc_unchecked(&qps_destroyed);
40703
40704 /* Free the control structures */
40705
40706 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40707 index 33cc589..3bd6538 100644
40708 --- a/drivers/infiniband/hw/nes/nes.h
40709 +++ b/drivers/infiniband/hw/nes/nes.h
40710 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40711 extern unsigned int wqm_quanta;
40712 extern struct list_head nes_adapter_list;
40713
40714 -extern atomic_t cm_connects;
40715 -extern atomic_t cm_accepts;
40716 -extern atomic_t cm_disconnects;
40717 -extern atomic_t cm_closes;
40718 -extern atomic_t cm_connecteds;
40719 -extern atomic_t cm_connect_reqs;
40720 -extern atomic_t cm_rejects;
40721 -extern atomic_t mod_qp_timouts;
40722 -extern atomic_t qps_created;
40723 -extern atomic_t qps_destroyed;
40724 -extern atomic_t sw_qps_destroyed;
40725 +extern atomic_unchecked_t cm_connects;
40726 +extern atomic_unchecked_t cm_accepts;
40727 +extern atomic_unchecked_t cm_disconnects;
40728 +extern atomic_unchecked_t cm_closes;
40729 +extern atomic_unchecked_t cm_connecteds;
40730 +extern atomic_unchecked_t cm_connect_reqs;
40731 +extern atomic_unchecked_t cm_rejects;
40732 +extern atomic_unchecked_t mod_qp_timouts;
40733 +extern atomic_unchecked_t qps_created;
40734 +extern atomic_unchecked_t qps_destroyed;
40735 +extern atomic_unchecked_t sw_qps_destroyed;
40736 extern u32 mh_detected;
40737 extern u32 mh_pauses_sent;
40738 extern u32 cm_packets_sent;
40739 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40740 extern u32 cm_packets_received;
40741 extern u32 cm_packets_dropped;
40742 extern u32 cm_packets_retrans;
40743 -extern atomic_t cm_listens_created;
40744 -extern atomic_t cm_listens_destroyed;
40745 +extern atomic_unchecked_t cm_listens_created;
40746 +extern atomic_unchecked_t cm_listens_destroyed;
40747 extern u32 cm_backlog_drops;
40748 -extern atomic_t cm_loopbacks;
40749 -extern atomic_t cm_nodes_created;
40750 -extern atomic_t cm_nodes_destroyed;
40751 -extern atomic_t cm_accel_dropped_pkts;
40752 -extern atomic_t cm_resets_recvd;
40753 -extern atomic_t pau_qps_created;
40754 -extern atomic_t pau_qps_destroyed;
40755 +extern atomic_unchecked_t cm_loopbacks;
40756 +extern atomic_unchecked_t cm_nodes_created;
40757 +extern atomic_unchecked_t cm_nodes_destroyed;
40758 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40759 +extern atomic_unchecked_t cm_resets_recvd;
40760 +extern atomic_unchecked_t pau_qps_created;
40761 +extern atomic_unchecked_t pau_qps_destroyed;
40762
40763 extern u32 int_mod_timer_init;
40764 extern u32 int_mod_cq_depth_256;
40765 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40766 index 24b9f1a..00fd004 100644
40767 --- a/drivers/infiniband/hw/nes/nes_cm.c
40768 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40769 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40770 u32 cm_packets_retrans;
40771 u32 cm_packets_created;
40772 u32 cm_packets_received;
40773 -atomic_t cm_listens_created;
40774 -atomic_t cm_listens_destroyed;
40775 +atomic_unchecked_t cm_listens_created;
40776 +atomic_unchecked_t cm_listens_destroyed;
40777 u32 cm_backlog_drops;
40778 -atomic_t cm_loopbacks;
40779 -atomic_t cm_nodes_created;
40780 -atomic_t cm_nodes_destroyed;
40781 -atomic_t cm_accel_dropped_pkts;
40782 -atomic_t cm_resets_recvd;
40783 +atomic_unchecked_t cm_loopbacks;
40784 +atomic_unchecked_t cm_nodes_created;
40785 +atomic_unchecked_t cm_nodes_destroyed;
40786 +atomic_unchecked_t cm_accel_dropped_pkts;
40787 +atomic_unchecked_t cm_resets_recvd;
40788
40789 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40790 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40791 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40792
40793 static struct nes_cm_core *g_cm_core;
40794
40795 -atomic_t cm_connects;
40796 -atomic_t cm_accepts;
40797 -atomic_t cm_disconnects;
40798 -atomic_t cm_closes;
40799 -atomic_t cm_connecteds;
40800 -atomic_t cm_connect_reqs;
40801 -atomic_t cm_rejects;
40802 +atomic_unchecked_t cm_connects;
40803 +atomic_unchecked_t cm_accepts;
40804 +atomic_unchecked_t cm_disconnects;
40805 +atomic_unchecked_t cm_closes;
40806 +atomic_unchecked_t cm_connecteds;
40807 +atomic_unchecked_t cm_connect_reqs;
40808 +atomic_unchecked_t cm_rejects;
40809
40810 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40811 {
40812 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40813 kfree(listener);
40814 listener = NULL;
40815 ret = 0;
40816 - atomic_inc(&cm_listens_destroyed);
40817 + atomic_inc_unchecked(&cm_listens_destroyed);
40818 } else {
40819 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40820 }
40821 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40822 cm_node->rem_mac);
40823
40824 add_hte_node(cm_core, cm_node);
40825 - atomic_inc(&cm_nodes_created);
40826 + atomic_inc_unchecked(&cm_nodes_created);
40827
40828 return cm_node;
40829 }
40830 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40831 }
40832
40833 atomic_dec(&cm_core->node_cnt);
40834 - atomic_inc(&cm_nodes_destroyed);
40835 + atomic_inc_unchecked(&cm_nodes_destroyed);
40836 nesqp = cm_node->nesqp;
40837 if (nesqp) {
40838 nesqp->cm_node = NULL;
40839 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40840
40841 static void drop_packet(struct sk_buff *skb)
40842 {
40843 - atomic_inc(&cm_accel_dropped_pkts);
40844 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40845 dev_kfree_skb_any(skb);
40846 }
40847
40848 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40849 {
40850
40851 int reset = 0; /* whether to send reset in case of err.. */
40852 - atomic_inc(&cm_resets_recvd);
40853 + atomic_inc_unchecked(&cm_resets_recvd);
40854 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40855 " refcnt=%d\n", cm_node, cm_node->state,
40856 atomic_read(&cm_node->ref_count));
40857 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40858 rem_ref_cm_node(cm_node->cm_core, cm_node);
40859 return NULL;
40860 }
40861 - atomic_inc(&cm_loopbacks);
40862 + atomic_inc_unchecked(&cm_loopbacks);
40863 loopbackremotenode->loopbackpartner = cm_node;
40864 loopbackremotenode->tcp_cntxt.rcv_wscale =
40865 NES_CM_DEFAULT_RCV_WND_SCALE;
40866 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40867 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40868 else {
40869 rem_ref_cm_node(cm_core, cm_node);
40870 - atomic_inc(&cm_accel_dropped_pkts);
40871 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40872 dev_kfree_skb_any(skb);
40873 }
40874 break;
40875 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40876
40877 if ((cm_id) && (cm_id->event_handler)) {
40878 if (issue_disconn) {
40879 - atomic_inc(&cm_disconnects);
40880 + atomic_inc_unchecked(&cm_disconnects);
40881 cm_event.event = IW_CM_EVENT_DISCONNECT;
40882 cm_event.status = disconn_status;
40883 cm_event.local_addr = cm_id->local_addr;
40884 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40885 }
40886
40887 if (issue_close) {
40888 - atomic_inc(&cm_closes);
40889 + atomic_inc_unchecked(&cm_closes);
40890 nes_disconnect(nesqp, 1);
40891
40892 cm_id->provider_data = nesqp;
40893 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40894
40895 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40896 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40897 - atomic_inc(&cm_accepts);
40898 + atomic_inc_unchecked(&cm_accepts);
40899
40900 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40901 netdev_refcnt_read(nesvnic->netdev));
40902 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40903 struct nes_cm_core *cm_core;
40904 u8 *start_buff;
40905
40906 - atomic_inc(&cm_rejects);
40907 + atomic_inc_unchecked(&cm_rejects);
40908 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40909 loopback = cm_node->loopbackpartner;
40910 cm_core = cm_node->cm_core;
40911 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40912 ntohl(cm_id->local_addr.sin_addr.s_addr),
40913 ntohs(cm_id->local_addr.sin_port));
40914
40915 - atomic_inc(&cm_connects);
40916 + atomic_inc_unchecked(&cm_connects);
40917 nesqp->active_conn = 1;
40918
40919 /* cache the cm_id in the qp */
40920 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40921 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40922 return err;
40923 }
40924 - atomic_inc(&cm_listens_created);
40925 + atomic_inc_unchecked(&cm_listens_created);
40926 }
40927
40928 cm_id->add_ref(cm_id);
40929 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40930
40931 if (nesqp->destroyed)
40932 return;
40933 - atomic_inc(&cm_connecteds);
40934 + atomic_inc_unchecked(&cm_connecteds);
40935 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40936 " local port 0x%04X. jiffies = %lu.\n",
40937 nesqp->hwqp.qp_id,
40938 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40939
40940 cm_id->add_ref(cm_id);
40941 ret = cm_id->event_handler(cm_id, &cm_event);
40942 - atomic_inc(&cm_closes);
40943 + atomic_inc_unchecked(&cm_closes);
40944 cm_event.event = IW_CM_EVENT_CLOSE;
40945 cm_event.status = 0;
40946 cm_event.provider_data = cm_id->provider_data;
40947 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40948 return;
40949 cm_id = cm_node->cm_id;
40950
40951 - atomic_inc(&cm_connect_reqs);
40952 + atomic_inc_unchecked(&cm_connect_reqs);
40953 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40954 cm_node, cm_id, jiffies);
40955
40956 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40957 return;
40958 cm_id = cm_node->cm_id;
40959
40960 - atomic_inc(&cm_connect_reqs);
40961 + atomic_inc_unchecked(&cm_connect_reqs);
40962 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40963 cm_node, cm_id, jiffies);
40964
40965 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40966 index 4166452..fc952c3 100644
40967 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40968 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40969 @@ -40,8 +40,8 @@
40970 #include "nes.h"
40971 #include "nes_mgt.h"
40972
40973 -atomic_t pau_qps_created;
40974 -atomic_t pau_qps_destroyed;
40975 +atomic_unchecked_t pau_qps_created;
40976 +atomic_unchecked_t pau_qps_destroyed;
40977
40978 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40979 {
40980 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40981 {
40982 struct sk_buff *skb;
40983 unsigned long flags;
40984 - atomic_inc(&pau_qps_destroyed);
40985 + atomic_inc_unchecked(&pau_qps_destroyed);
40986
40987 /* Free packets that have not yet been forwarded */
40988 /* Lock is acquired by skb_dequeue when removing the skb */
40989 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40990 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40991 skb_queue_head_init(&nesqp->pau_list);
40992 spin_lock_init(&nesqp->pau_lock);
40993 - atomic_inc(&pau_qps_created);
40994 + atomic_inc_unchecked(&pau_qps_created);
40995 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40996 }
40997
40998 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40999 index 49eb511..a774366 100644
41000 --- a/drivers/infiniband/hw/nes/nes_nic.c
41001 +++ b/drivers/infiniband/hw/nes/nes_nic.c
41002 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
41003 target_stat_values[++index] = mh_detected;
41004 target_stat_values[++index] = mh_pauses_sent;
41005 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
41006 - target_stat_values[++index] = atomic_read(&cm_connects);
41007 - target_stat_values[++index] = atomic_read(&cm_accepts);
41008 - target_stat_values[++index] = atomic_read(&cm_disconnects);
41009 - target_stat_values[++index] = atomic_read(&cm_connecteds);
41010 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
41011 - target_stat_values[++index] = atomic_read(&cm_rejects);
41012 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
41013 - target_stat_values[++index] = atomic_read(&qps_created);
41014 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
41015 - target_stat_values[++index] = atomic_read(&qps_destroyed);
41016 - target_stat_values[++index] = atomic_read(&cm_closes);
41017 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
41018 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
41019 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
41020 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
41021 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
41022 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
41023 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
41024 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
41025 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
41026 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
41027 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
41028 target_stat_values[++index] = cm_packets_sent;
41029 target_stat_values[++index] = cm_packets_bounced;
41030 target_stat_values[++index] = cm_packets_created;
41031 target_stat_values[++index] = cm_packets_received;
41032 target_stat_values[++index] = cm_packets_dropped;
41033 target_stat_values[++index] = cm_packets_retrans;
41034 - target_stat_values[++index] = atomic_read(&cm_listens_created);
41035 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
41036 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
41037 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
41038 target_stat_values[++index] = cm_backlog_drops;
41039 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
41040 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
41041 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
41042 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
41043 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
41044 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
41045 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
41046 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
41047 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
41048 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
41049 target_stat_values[++index] = nesadapter->free_4kpbl;
41050 target_stat_values[++index] = nesadapter->free_256pbl;
41051 target_stat_values[++index] = int_mod_timer_init;
41052 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
41053 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
41054 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
41055 - target_stat_values[++index] = atomic_read(&pau_qps_created);
41056 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
41057 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
41058 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
41059 }
41060
41061 /**
41062 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
41063 index 5b53ca5..443da3c 100644
41064 --- a/drivers/infiniband/hw/nes/nes_verbs.c
41065 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
41066 @@ -46,9 +46,9 @@
41067
41068 #include <rdma/ib_umem.h>
41069
41070 -atomic_t mod_qp_timouts;
41071 -atomic_t qps_created;
41072 -atomic_t sw_qps_destroyed;
41073 +atomic_unchecked_t mod_qp_timouts;
41074 +atomic_unchecked_t qps_created;
41075 +atomic_unchecked_t sw_qps_destroyed;
41076
41077 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
41078
41079 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
41080 if (init_attr->create_flags)
41081 return ERR_PTR(-EINVAL);
41082
41083 - atomic_inc(&qps_created);
41084 + atomic_inc_unchecked(&qps_created);
41085 switch (init_attr->qp_type) {
41086 case IB_QPT_RC:
41087 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
41088 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
41089 struct iw_cm_event cm_event;
41090 int ret = 0;
41091
41092 - atomic_inc(&sw_qps_destroyed);
41093 + atomic_inc_unchecked(&sw_qps_destroyed);
41094 nesqp->destroyed = 1;
41095
41096 /* Blow away the connection if it exists. */
41097 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
41098 index 4a9af79..b993f75 100644
41099 --- a/drivers/infiniband/hw/qib/qib.h
41100 +++ b/drivers/infiniband/hw/qib/qib.h
41101 @@ -52,6 +52,7 @@
41102 #include <linux/kref.h>
41103 #include <linux/sched.h>
41104 #include <linux/kthread.h>
41105 +#include <linux/slab.h>
41106
41107 #include "qib_common.h"
41108 #include "qib_verbs.h"
41109 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
41110 index da739d9..da1c7f4 100644
41111 --- a/drivers/input/gameport/gameport.c
41112 +++ b/drivers/input/gameport/gameport.c
41113 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
41114 */
41115 static void gameport_init_port(struct gameport *gameport)
41116 {
41117 - static atomic_t gameport_no = ATOMIC_INIT(0);
41118 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
41119
41120 __module_get(THIS_MODULE);
41121
41122 mutex_init(&gameport->drv_mutex);
41123 device_initialize(&gameport->dev);
41124 dev_set_name(&gameport->dev, "gameport%lu",
41125 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
41126 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
41127 gameport->dev.bus = &gameport_bus;
41128 gameport->dev.release = gameport_release_port;
41129 if (gameport->parent)
41130 diff --git a/drivers/input/input.c b/drivers/input/input.c
41131 index c044699..174d71a 100644
41132 --- a/drivers/input/input.c
41133 +++ b/drivers/input/input.c
41134 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
41135 */
41136 int input_register_device(struct input_dev *dev)
41137 {
41138 - static atomic_t input_no = ATOMIC_INIT(0);
41139 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41140 struct input_devres *devres = NULL;
41141 struct input_handler *handler;
41142 unsigned int packet_size;
41143 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
41144 dev->setkeycode = input_default_setkeycode;
41145
41146 dev_set_name(&dev->dev, "input%ld",
41147 - (unsigned long) atomic_inc_return(&input_no) - 1);
41148 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41149
41150 error = device_add(&dev->dev);
41151 if (error)
41152 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41153 index 04c69af..5f92d00 100644
41154 --- a/drivers/input/joystick/sidewinder.c
41155 +++ b/drivers/input/joystick/sidewinder.c
41156 @@ -30,6 +30,7 @@
41157 #include <linux/kernel.h>
41158 #include <linux/module.h>
41159 #include <linux/slab.h>
41160 +#include <linux/sched.h>
41161 #include <linux/init.h>
41162 #include <linux/input.h>
41163 #include <linux/gameport.h>
41164 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41165 index 75e3b10..fb390fd 100644
41166 --- a/drivers/input/joystick/xpad.c
41167 +++ b/drivers/input/joystick/xpad.c
41168 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41169
41170 static int xpad_led_probe(struct usb_xpad *xpad)
41171 {
41172 - static atomic_t led_seq = ATOMIC_INIT(0);
41173 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41174 long led_no;
41175 struct xpad_led *led;
41176 struct led_classdev *led_cdev;
41177 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41178 if (!led)
41179 return -ENOMEM;
41180
41181 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41182 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41183
41184 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41185 led->xpad = xpad;
41186 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41187 index e204f26..8459f15 100644
41188 --- a/drivers/input/misc/ims-pcu.c
41189 +++ b/drivers/input/misc/ims-pcu.c
41190 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41191
41192 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41193 {
41194 - static atomic_t device_no = ATOMIC_INIT(0);
41195 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41196
41197 const struct ims_pcu_device_info *info;
41198 u8 device_id;
41199 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41200 }
41201
41202 /* Device appears to be operable, complete initialization */
41203 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41204 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41205
41206 error = ims_pcu_setup_backlight(pcu);
41207 if (error)
41208 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41209 index 2f0b39d..7370f13 100644
41210 --- a/drivers/input/mouse/psmouse.h
41211 +++ b/drivers/input/mouse/psmouse.h
41212 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41213 ssize_t (*set)(struct psmouse *psmouse, void *data,
41214 const char *buf, size_t count);
41215 bool protect;
41216 -};
41217 +} __do_const;
41218 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41219
41220 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41221 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41222 index 4c842c3..590b0bf 100644
41223 --- a/drivers/input/mousedev.c
41224 +++ b/drivers/input/mousedev.c
41225 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41226
41227 spin_unlock_irq(&client->packet_lock);
41228
41229 - if (copy_to_user(buffer, data, count))
41230 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41231 return -EFAULT;
41232
41233 return count;
41234 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41235 index 25fc597..558bf3b3 100644
41236 --- a/drivers/input/serio/serio.c
41237 +++ b/drivers/input/serio/serio.c
41238 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41239 */
41240 static void serio_init_port(struct serio *serio)
41241 {
41242 - static atomic_t serio_no = ATOMIC_INIT(0);
41243 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41244
41245 __module_get(THIS_MODULE);
41246
41247 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41248 mutex_init(&serio->drv_mutex);
41249 device_initialize(&serio->dev);
41250 dev_set_name(&serio->dev, "serio%ld",
41251 - (long)atomic_inc_return(&serio_no) - 1);
41252 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41253 serio->dev.bus = &serio_bus;
41254 serio->dev.release = serio_release_port;
41255 serio->dev.groups = serio_device_attr_groups;
41256 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41257 index 59df2e7..8f1cafb 100644
41258 --- a/drivers/input/serio/serio_raw.c
41259 +++ b/drivers/input/serio/serio_raw.c
41260 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41261
41262 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41263 {
41264 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41265 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41266 struct serio_raw *serio_raw;
41267 int err;
41268
41269 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41270 }
41271
41272 snprintf(serio_raw->name, sizeof(serio_raw->name),
41273 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41274 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41275 kref_init(&serio_raw->kref);
41276 INIT_LIST_HEAD(&serio_raw->client_list);
41277 init_waitqueue_head(&serio_raw->wait);
41278 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41279 index fbe9ca7..dbee61d 100644
41280 --- a/drivers/iommu/iommu.c
41281 +++ b/drivers/iommu/iommu.c
41282 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41283 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41284 {
41285 bus_register_notifier(bus, &iommu_bus_nb);
41286 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41287 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41288 }
41289
41290 /**
41291 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41292 index 39f81ae..2660096 100644
41293 --- a/drivers/iommu/irq_remapping.c
41294 +++ b/drivers/iommu/irq_remapping.c
41295 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41296 void panic_if_irq_remap(const char *msg)
41297 {
41298 if (irq_remapping_enabled)
41299 - panic(msg);
41300 + panic("%s", msg);
41301 }
41302
41303 static void ir_ack_apic_edge(struct irq_data *data)
41304 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41305
41306 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41307 {
41308 - chip->irq_print_chip = ir_print_prefix;
41309 - chip->irq_ack = ir_ack_apic_edge;
41310 - chip->irq_eoi = ir_ack_apic_level;
41311 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41312 + pax_open_kernel();
41313 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41314 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41315 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41316 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41317 + pax_close_kernel();
41318 }
41319
41320 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41321 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41322 index ee7c503..5d4ce08 100644
41323 --- a/drivers/irqchip/irq-gic.c
41324 +++ b/drivers/irqchip/irq-gic.c
41325 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41326 * Supported arch specific GIC irq extension.
41327 * Default make them NULL.
41328 */
41329 -struct irq_chip gic_arch_extn = {
41330 +irq_chip_no_const gic_arch_extn = {
41331 .irq_eoi = NULL,
41332 .irq_mask = NULL,
41333 .irq_unmask = NULL,
41334 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41335 chained_irq_exit(chip, desc);
41336 }
41337
41338 -static struct irq_chip gic_chip = {
41339 +static irq_chip_no_const gic_chip __read_only = {
41340 .name = "GIC",
41341 .irq_mask = gic_mask_irq,
41342 .irq_unmask = gic_unmask_irq,
41343 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41344 index ac6f72b..81150f2 100644
41345 --- a/drivers/isdn/capi/capi.c
41346 +++ b/drivers/isdn/capi/capi.c
41347 @@ -81,8 +81,8 @@ struct capiminor {
41348
41349 struct capi20_appl *ap;
41350 u32 ncci;
41351 - atomic_t datahandle;
41352 - atomic_t msgid;
41353 + atomic_unchecked_t datahandle;
41354 + atomic_unchecked_t msgid;
41355
41356 struct tty_port port;
41357 int ttyinstop;
41358 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41359 capimsg_setu16(s, 2, mp->ap->applid);
41360 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41361 capimsg_setu8 (s, 5, CAPI_RESP);
41362 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41363 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41364 capimsg_setu32(s, 8, mp->ncci);
41365 capimsg_setu16(s, 12, datahandle);
41366 }
41367 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41368 mp->outbytes -= len;
41369 spin_unlock_bh(&mp->outlock);
41370
41371 - datahandle = atomic_inc_return(&mp->datahandle);
41372 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41373 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41374 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41375 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41376 capimsg_setu16(skb->data, 2, mp->ap->applid);
41377 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41378 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41379 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41380 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41381 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41382 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41383 capimsg_setu16(skb->data, 16, len); /* Data length */
41384 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41385 index 600c79b..3752bab 100644
41386 --- a/drivers/isdn/gigaset/interface.c
41387 +++ b/drivers/isdn/gigaset/interface.c
41388 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41389 }
41390 tty->driver_data = cs;
41391
41392 - ++cs->port.count;
41393 + atomic_inc(&cs->port.count);
41394
41395 - if (cs->port.count == 1) {
41396 + if (atomic_read(&cs->port.count) == 1) {
41397 tty_port_tty_set(&cs->port, tty);
41398 cs->port.low_latency = 1;
41399 }
41400 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41401
41402 if (!cs->connected)
41403 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41404 - else if (!cs->port.count)
41405 + else if (!atomic_read(&cs->port.count))
41406 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41407 - else if (!--cs->port.count)
41408 + else if (!atomic_dec_return(&cs->port.count))
41409 tty_port_tty_set(&cs->port, NULL);
41410
41411 mutex_unlock(&cs->mutex);
41412 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41413 index d0a41cb..f0cdb8c 100644
41414 --- a/drivers/isdn/gigaset/usb-gigaset.c
41415 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41416 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41417 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41418 memcpy(cs->hw.usb->bchars, buf, 6);
41419 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41420 - 0, 0, &buf, 6, 2000);
41421 + 0, 0, buf, 6, 2000);
41422 }
41423
41424 static void gigaset_freebcshw(struct bc_state *bcs)
41425 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41426 index 4d9b195..455075c 100644
41427 --- a/drivers/isdn/hardware/avm/b1.c
41428 +++ b/drivers/isdn/hardware/avm/b1.c
41429 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41430 }
41431 if (left) {
41432 if (t4file->user) {
41433 - if (copy_from_user(buf, dp, left))
41434 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41435 return -EFAULT;
41436 } else {
41437 memcpy(buf, dp, left);
41438 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41439 }
41440 if (left) {
41441 if (config->user) {
41442 - if (copy_from_user(buf, dp, left))
41443 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41444 return -EFAULT;
41445 } else {
41446 memcpy(buf, dp, left);
41447 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
41448 index 1063bab..36817e0 100644
41449 --- a/drivers/isdn/hisax/amd7930_fn.c
41450 +++ b/drivers/isdn/hisax/amd7930_fn.c
41451 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41452
41453 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41454 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41455 - debugl1(cs, cs->dlog);
41456 + debugl1(cs, "%s", cs->dlog);
41457 }
41458 /* moves received data in sk-buffer */
41459 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41460 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41461
41462 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41463 QuickHex(t, deb_ptr, count);
41464 - debugl1(cs, cs->dlog);
41465 + debugl1(cs, "%s", cs->dlog);
41466 }
41467 /* AMD interrupts on */
41468 AmdIrqOn(cs);
41469 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41470 index ee9b9a0..d1427bd 100644
41471 --- a/drivers/isdn/hisax/avm_pci.c
41472 +++ b/drivers/isdn/hisax/avm_pci.c
41473 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41474 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41475 bcs->channel ? 'B' : 'A', count);
41476 QuickHex(t, p, count);
41477 - debugl1(cs, bcs->blog);
41478 + debugl1(cs, "%s", bcs->blog);
41479 }
41480 }
41481
41482 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41483 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41484 bcs->channel ? 'B' : 'A', count);
41485 QuickHex(t, p, count);
41486 - debugl1(cs, bcs->blog);
41487 + debugl1(cs, "%s", bcs->blog);
41488 }
41489 }
41490
41491 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41492 index bf04d2a..b33f53b 100644
41493 --- a/drivers/isdn/hisax/config.c
41494 +++ b/drivers/isdn/hisax/config.c
41495 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41496 ptr--;
41497 *ptr++ = '\n';
41498 *ptr = 0;
41499 - HiSax_putstatus(cs, NULL, cs->dlog);
41500 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41501 } else
41502 HiSax_putstatus(cs, "LogEcho: ",
41503 "warning Frame too big (%d)",
41504 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41505 index 8d0cf6e..4fc90de 100644
41506 --- a/drivers/isdn/hisax/diva.c
41507 +++ b/drivers/isdn/hisax/diva.c
41508 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41509 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41510 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41511 QuickHex(t, ptr, count);
41512 - debugl1(cs, bcs->blog);
41513 + debugl1(cs, "%s", bcs->blog);
41514 }
41515 }
41516
41517 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41518 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41519 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41520 QuickHex(t, ptr, count);
41521 - debugl1(cs, bcs->blog);
41522 + debugl1(cs, "%s", bcs->blog);
41523 }
41524 }
41525
41526 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41527 index 1df6f9a..2be1c8a 100644
41528 --- a/drivers/isdn/hisax/elsa.c
41529 +++ b/drivers/isdn/hisax/elsa.c
41530 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41531 t = tmp;
41532 t += sprintf(tmp, "Arcofi data");
41533 QuickHex(t, p, cs->dc.isac.mon_rxp);
41534 - debugl1(cs, tmp);
41535 + debugl1(cs, "%s", tmp);
41536 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41537 switch (cs->dc.isac.mon_rx[1]) {
41538 case 0x80:
41539 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41540 index d4c98d3..3f84dd8 100644
41541 --- a/drivers/isdn/hisax/elsa_ser.c
41542 +++ b/drivers/isdn/hisax/elsa_ser.c
41543 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41544
41545 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41546 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41547 - debugl1(cs, tmp);
41548 + debugl1(cs, "%s", tmp);
41549 }
41550 cs->hw.elsa.rcvcnt = 0;
41551 }
41552 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41553 index 3ccd724..497bd02 100644
41554 --- a/drivers/isdn/hisax/hfc_pci.c
41555 +++ b/drivers/isdn/hisax/hfc_pci.c
41556 @@ -901,7 +901,7 @@ Begin:
41557 ptr--;
41558 *ptr++ = '\n';
41559 *ptr = 0;
41560 - HiSax_putstatus(cs, NULL, cs->dlog);
41561 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41562 } else
41563 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41564 }
41565 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41566 index dc4574f..fa1fefd 100644
41567 --- a/drivers/isdn/hisax/hfc_sx.c
41568 +++ b/drivers/isdn/hisax/hfc_sx.c
41569 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41570 ptr--;
41571 *ptr++ = '\n';
41572 *ptr = 0;
41573 - HiSax_putstatus(cs, NULL, cs->dlog);
41574 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41575 } else
41576 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41577 }
41578 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41579 index f398d48..a8d6188 100644
41580 --- a/drivers/isdn/hisax/hscx_irq.c
41581 +++ b/drivers/isdn/hisax/hscx_irq.c
41582 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41583 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41584 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41585 QuickHex(t, ptr, count);
41586 - debugl1(cs, bcs->blog);
41587 + debugl1(cs, "%s", bcs->blog);
41588 }
41589 }
41590
41591 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41592 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41593 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41594 QuickHex(t, ptr, count);
41595 - debugl1(cs, bcs->blog);
41596 + debugl1(cs, "%s", bcs->blog);
41597 }
41598 }
41599
41600 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41601 index db5321f..51dae91 100644
41602 --- a/drivers/isdn/hisax/icc.c
41603 +++ b/drivers/isdn/hisax/icc.c
41604 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41605
41606 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41607 QuickHex(t, ptr, count);
41608 - debugl1(cs, cs->dlog);
41609 + debugl1(cs, "%s", cs->dlog);
41610 }
41611 }
41612
41613 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41614
41615 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41616 QuickHex(t, ptr, count);
41617 - debugl1(cs, cs->dlog);
41618 + debugl1(cs, "%s", cs->dlog);
41619 }
41620 }
41621
41622 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41623 index 74feb5c..5faa5de 100644
41624 --- a/drivers/isdn/hisax/ipacx.c
41625 +++ b/drivers/isdn/hisax/ipacx.c
41626 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41627
41628 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41629 QuickHex(t, ptr, count);
41630 - debugl1(cs, cs->dlog);
41631 + debugl1(cs, "%s", cs->dlog);
41632 }
41633 }
41634
41635 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41636
41637 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41638 QuickHex(t, ptr, count);
41639 - debugl1(cs, cs->dlog);
41640 + debugl1(cs, "%s", cs->dlog);
41641 }
41642 }
41643
41644 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41645
41646 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41647 QuickHex(t, ptr, count);
41648 - debugl1(cs, bcs->blog);
41649 + debugl1(cs, "%s", bcs->blog);
41650 }
41651 }
41652
41653 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41654
41655 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41656 QuickHex(t, ptr, count);
41657 - debugl1(cs, bcs->blog);
41658 + debugl1(cs, "%s", bcs->blog);
41659 }
41660 }
41661
41662 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41663 index a365ccc..7fdf78f 100644
41664 --- a/drivers/isdn/hisax/isac.c
41665 +++ b/drivers/isdn/hisax/isac.c
41666 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41667
41668 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41669 QuickHex(t, ptr, count);
41670 - debugl1(cs, cs->dlog);
41671 + debugl1(cs, "%s", cs->dlog);
41672 }
41673 }
41674
41675 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41676
41677 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41678 QuickHex(t, ptr, count);
41679 - debugl1(cs, cs->dlog);
41680 + debugl1(cs, "%s", cs->dlog);
41681 }
41682 }
41683
41684 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41685 index 7fdf347..f4956c7 100644
41686 --- a/drivers/isdn/hisax/isar.c
41687 +++ b/drivers/isdn/hisax/isar.c
41688 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41689 t = tmp;
41690 t += sprintf(t, "sendmbox cnt %d", len);
41691 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41692 - debugl1(cs, tmp);
41693 + debugl1(cs, "%s", tmp);
41694 i -= 64;
41695 }
41696 }
41697 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41698 t = tmp;
41699 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41700 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41701 - debugl1(cs, tmp);
41702 + debugl1(cs, "%s", tmp);
41703 i -= 64;
41704 }
41705 }
41706 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41707 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41708 ireg->iis, ireg->cmsb);
41709 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41710 - debugl1(cs, debbuf);
41711 + debugl1(cs, "%s", debbuf);
41712 }
41713 break;
41714 case ISAR_IIS_INVMSG:
41715 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41716 index f946c58..e2ae787 100644
41717 --- a/drivers/isdn/hisax/jade.c
41718 +++ b/drivers/isdn/hisax/jade.c
41719 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41720 int jade = bcs->hw.hscx.hscx;
41721
41722 if (cs->debug & L1_DEB_HSCX) {
41723 - char tmp[40];
41724 - sprintf(tmp, "jade %c mode %d ichan %d",
41725 - 'A' + jade, mode, bc);
41726 - debugl1(cs, tmp);
41727 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41728 }
41729 bcs->mode = mode;
41730 bcs->channel = bc;
41731 @@ -257,23 +254,18 @@ void
41732 clear_pending_jade_ints(struct IsdnCardState *cs)
41733 {
41734 int val;
41735 - char tmp[64];
41736
41737 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41738 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41739
41740 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41741 - sprintf(tmp, "jade B ISTA %x", val);
41742 - debugl1(cs, tmp);
41743 + debugl1(cs, "jade B ISTA %x", val);
41744 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41745 - sprintf(tmp, "jade A ISTA %x", val);
41746 - debugl1(cs, tmp);
41747 + debugl1(cs, "jade A ISTA %x", val);
41748 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41749 - sprintf(tmp, "jade B STAR %x", val);
41750 - debugl1(cs, tmp);
41751 + debugl1(cs, "jade B STAR %x", val);
41752 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41753 - sprintf(tmp, "jade A STAR %x", val);
41754 - debugl1(cs, tmp);
41755 + debugl1(cs, "jade A STAR %x", val);
41756 /* Unmask ints */
41757 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41758 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41759 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41760 index f521fc8..b930da9 100644
41761 --- a/drivers/isdn/hisax/jade_irq.c
41762 +++ b/drivers/isdn/hisax/jade_irq.c
41763 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41764 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41765 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41766 QuickHex(t, ptr, count);
41767 - debugl1(cs, bcs->blog);
41768 + debugl1(cs, "%s", bcs->blog);
41769 }
41770 }
41771
41772 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41773 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41774 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41775 QuickHex(t, ptr, count);
41776 - debugl1(cs, bcs->blog);
41777 + debugl1(cs, "%s", bcs->blog);
41778 }
41779 }
41780
41781 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41782 index 4c1bca5..875402e 100644
41783 --- a/drivers/isdn/hisax/l3_1tr6.c
41784 +++ b/drivers/isdn/hisax/l3_1tr6.c
41785 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41786 {
41787 dev_kfree_skb(skb);
41788 if (pc->st->l3.debug & L3_DEB_WARN)
41789 - l3_debug(pc->st, msg);
41790 + l3_debug(pc->st, "%s", msg);
41791 l3_1tr6_release_req(pc, 0, NULL);
41792 }
41793
41794 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41795 {
41796 u_char *p;
41797 int bcfound = 0;
41798 - char tmp[80];
41799 struct sk_buff *skb = arg;
41800
41801 /* Channel Identification */
41802 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41803 /* Signal all services, linklevel takes care of Service-Indicator */
41804 if (bcfound) {
41805 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41806 - sprintf(tmp, "non-digital call: %s -> %s",
41807 + l3_debug(pc->st, "non-digital call: %s -> %s",
41808 pc->para.setup.phone,
41809 pc->para.setup.eazmsn);
41810 - l3_debug(pc->st, tmp);
41811 }
41812 newl3state(pc, 6);
41813 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41814 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41815 {
41816 u_char *p;
41817 int i, tmpcharge = 0;
41818 - char a_charge[8], tmp[32];
41819 + char a_charge[8];
41820 struct sk_buff *skb = arg;
41821
41822 p = skb->data;
41823 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41824 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41825 }
41826 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41827 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41828 - l3_debug(pc->st, tmp);
41829 + l3_debug(pc->st, "charging info %d",
41830 + pc->para.chargeinfo);
41831 }
41832 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41833 l3_debug(pc->st, "charging info not found");
41834 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41835 struct sk_buff *skb = arg;
41836 u_char *p;
41837 int i, tmpcharge = 0;
41838 - char a_charge[8], tmp[32];
41839 + char a_charge[8];
41840
41841 StopAllL3Timer(pc);
41842 p = skb->data;
41843 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41844 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41845 }
41846 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41847 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41848 - l3_debug(pc->st, tmp);
41849 + l3_debug(pc->st, "charging info %d",
41850 + pc->para.chargeinfo);
41851 }
41852 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41853 l3_debug(pc->st, "charging info not found");
41854 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41855 int i, mt, cr;
41856 struct l3_process *proc;
41857 struct sk_buff *skb = arg;
41858 - char tmp[80];
41859
41860 switch (pr) {
41861 case (DL_DATA | INDICATION):
41862 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41863 }
41864 if (skb->len < 4) {
41865 if (st->l3.debug & L3_DEB_PROTERR) {
41866 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41867 - l3_debug(st, tmp);
41868 + l3_debug(st, "up1tr6 len only %d", skb->len);
41869 }
41870 dev_kfree_skb(skb);
41871 return;
41872 }
41873 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41874 if (st->l3.debug & L3_DEB_PROTERR) {
41875 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41876 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41877 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41878 skb->data[0], skb->len);
41879 - l3_debug(st, tmp);
41880 }
41881 dev_kfree_skb(skb);
41882 return;
41883 }
41884 if (skb->data[1] != 1) {
41885 if (st->l3.debug & L3_DEB_PROTERR) {
41886 - sprintf(tmp, "up1tr6 CR len not 1");
41887 - l3_debug(st, tmp);
41888 + l3_debug(st, "up1tr6 CR len not 1");
41889 }
41890 dev_kfree_skb(skb);
41891 return;
41892 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41893 if (skb->data[0] == PROTO_DIS_N0) {
41894 dev_kfree_skb(skb);
41895 if (st->l3.debug & L3_DEB_STATE) {
41896 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41897 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41898 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41899 - l3_debug(st, tmp);
41900 }
41901 } else if (skb->data[0] == PROTO_DIS_N1) {
41902 if (!(proc = getl3proc(st, cr))) {
41903 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41904 if (cr < 128) {
41905 if (!(proc = new_l3_process(st, cr))) {
41906 if (st->l3.debug & L3_DEB_PROTERR) {
41907 - sprintf(tmp, "up1tr6 no roc mem");
41908 - l3_debug(st, tmp);
41909 + l3_debug(st, "up1tr6 no roc mem");
41910 }
41911 dev_kfree_skb(skb);
41912 return;
41913 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41914 } else {
41915 if (!(proc = new_l3_process(st, cr))) {
41916 if (st->l3.debug & L3_DEB_PROTERR) {
41917 - sprintf(tmp, "up1tr6 no roc mem");
41918 - l3_debug(st, tmp);
41919 + l3_debug(st, "up1tr6 no roc mem");
41920 }
41921 dev_kfree_skb(skb);
41922 return;
41923 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41924 if (i == ARRAY_SIZE(datastln1)) {
41925 dev_kfree_skb(skb);
41926 if (st->l3.debug & L3_DEB_STATE) {
41927 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41928 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41929 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41930 proc->state, mt);
41931 - l3_debug(st, tmp);
41932 }
41933 return;
41934 } else {
41935 if (st->l3.debug & L3_DEB_STATE) {
41936 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41937 + l3_debug(st, "up1tr6%sstate %d mt %x",
41938 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41939 proc->state, mt);
41940 - l3_debug(st, tmp);
41941 }
41942 datastln1[i].rout(proc, pr, skb);
41943 }
41944 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41945 int i, cr;
41946 struct l3_process *proc;
41947 struct Channel *chan;
41948 - char tmp[80];
41949
41950 if ((DL_ESTABLISH | REQUEST) == pr) {
41951 l3_msg(st, pr, NULL);
41952 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41953 break;
41954 if (i == ARRAY_SIZE(downstl)) {
41955 if (st->l3.debug & L3_DEB_STATE) {
41956 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41957 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41958 proc->state, pr);
41959 - l3_debug(st, tmp);
41960 }
41961 } else {
41962 if (st->l3.debug & L3_DEB_STATE) {
41963 - sprintf(tmp, "down1tr6 state %d prim %d",
41964 + l3_debug(st, "down1tr6 state %d prim %d",
41965 proc->state, pr);
41966 - l3_debug(st, tmp);
41967 }
41968 downstl[i].rout(proc, pr, arg);
41969 }
41970 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41971 index b646eed..233e432 100644
41972 --- a/drivers/isdn/hisax/netjet.c
41973 +++ b/drivers/isdn/hisax/netjet.c
41974 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41975 else
41976 j = i;
41977 QuickHex(t, p, j);
41978 - debugl1(cs, tmp);
41979 + debugl1(cs, "%s", tmp);
41980 p += j;
41981 i -= j;
41982 t = tmp;
41983 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41984 index 041bf52..af1b020 100644
41985 --- a/drivers/isdn/hisax/q931.c
41986 +++ b/drivers/isdn/hisax/q931.c
41987 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41988 dp--;
41989 *dp++ = '\n';
41990 *dp = 0;
41991 - HiSax_putstatus(cs, NULL, cs->dlog);
41992 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41993 } else
41994 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41995 }
41996 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41997 }
41998 if (finish) {
41999 *dp = 0;
42000 - HiSax_putstatus(cs, NULL, cs->dlog);
42001 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
42002 return;
42003 }
42004 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
42005 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
42006 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
42007 }
42008 *dp = 0;
42009 - HiSax_putstatus(cs, NULL, cs->dlog);
42010 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
42011 }
42012 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
42013 index d8cac69..a858955 100644
42014 --- a/drivers/isdn/hisax/w6692.c
42015 +++ b/drivers/isdn/hisax/w6692.c
42016 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
42017
42018 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
42019 QuickHex(t, ptr, count);
42020 - debugl1(cs, cs->dlog);
42021 + debugl1(cs, "%s", cs->dlog);
42022 }
42023 }
42024
42025 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
42026
42027 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
42028 QuickHex(t, ptr, count);
42029 - debugl1(cs, cs->dlog);
42030 + debugl1(cs, "%s", cs->dlog);
42031 }
42032 }
42033
42034 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
42035 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
42036 bcs->channel + '1', count);
42037 QuickHex(t, ptr, count);
42038 - debugl1(cs, bcs->blog);
42039 + debugl1(cs, "%s", bcs->blog);
42040 }
42041 }
42042
42043 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
42044 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
42045 bcs->channel + '1', count);
42046 QuickHex(t, ptr, count);
42047 - debugl1(cs, bcs->blog);
42048 + debugl1(cs, "%s", bcs->blog);
42049 }
42050 }
42051
42052 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
42053 index 9bb12ba..d4262f7 100644
42054 --- a/drivers/isdn/i4l/isdn_common.c
42055 +++ b/drivers/isdn/i4l/isdn_common.c
42056 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
42057 } else
42058 return -EINVAL;
42059 case IIOCDBGVAR:
42060 + if (!capable(CAP_SYS_RAWIO))
42061 + return -EPERM;
42062 if (arg) {
42063 if (copy_to_user(argp, &dev, sizeof(ulong)))
42064 return -EFAULT;
42065 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
42066 index 3c5f249..5fac4d0 100644
42067 --- a/drivers/isdn/i4l/isdn_tty.c
42068 +++ b/drivers/isdn/i4l/isdn_tty.c
42069 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
42070
42071 #ifdef ISDN_DEBUG_MODEM_OPEN
42072 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
42073 - port->count);
42074 + atomic_read(&port->count));
42075 #endif
42076 - port->count++;
42077 + atomic_inc(&port->count);
42078 port->tty = tty;
42079 /*
42080 * Start up serial port
42081 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42082 #endif
42083 return;
42084 }
42085 - if ((tty->count == 1) && (port->count != 1)) {
42086 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
42087 /*
42088 * Uh, oh. tty->count is 1, which means that the tty
42089 * structure will be freed. Info->count should always
42090 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42091 * serial port won't be shutdown.
42092 */
42093 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
42094 - "info->count is %d\n", port->count);
42095 - port->count = 1;
42096 + "info->count is %d\n", atomic_read(&port->count));
42097 + atomic_set(&port->count, 1);
42098 }
42099 - if (--port->count < 0) {
42100 + if (atomic_dec_return(&port->count) < 0) {
42101 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
42102 - info->line, port->count);
42103 - port->count = 0;
42104 + info->line, atomic_read(&port->count));
42105 + atomic_set(&port->count, 0);
42106 }
42107 - if (port->count) {
42108 + if (atomic_read(&port->count)) {
42109 #ifdef ISDN_DEBUG_MODEM_OPEN
42110 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
42111 #endif
42112 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
42113 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
42114 return;
42115 isdn_tty_shutdown(info);
42116 - port->count = 0;
42117 + atomic_set(&port->count, 0);
42118 port->flags &= ~ASYNC_NORMAL_ACTIVE;
42119 port->tty = NULL;
42120 wake_up_interruptible(&port->open_wait);
42121 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
42122 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
42123 modem_info *info = &dev->mdm.info[i];
42124
42125 - if (info->port.count == 0)
42126 + if (atomic_read(&info->port.count) == 0)
42127 continue;
42128 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
42129 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
42130 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
42131 index e74df7c..03a03ba 100644
42132 --- a/drivers/isdn/icn/icn.c
42133 +++ b/drivers/isdn/icn/icn.c
42134 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
42135 if (count > len)
42136 count = len;
42137 if (user) {
42138 - if (copy_from_user(msg, buf, count))
42139 + if (count > sizeof msg || copy_from_user(msg, buf, count))
42140 return -EFAULT;
42141 } else
42142 memcpy(msg, buf, count);
42143 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
42144 index 6a8405d..0bd1c7e 100644
42145 --- a/drivers/leds/leds-clevo-mail.c
42146 +++ b/drivers/leds/leds-clevo-mail.c
42147 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
42148 * detected as working, but in reality it is not) as low as
42149 * possible.
42150 */
42151 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
42152 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
42153 {
42154 .callback = clevo_mail_led_dmi_callback,
42155 .ident = "Clevo D410J",
42156 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
42157 index 64e204e..c6bf189 100644
42158 --- a/drivers/leds/leds-ss4200.c
42159 +++ b/drivers/leds/leds-ss4200.c
42160 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
42161 * detected as working, but in reality it is not) as low as
42162 * possible.
42163 */
42164 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
42165 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
42166 {
42167 .callback = ss4200_led_dmi_callback,
42168 .ident = "Intel SS4200-E",
42169 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
42170 index 0bf1e4e..b4bf44e 100644
42171 --- a/drivers/lguest/core.c
42172 +++ b/drivers/lguest/core.c
42173 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
42174 * The end address needs +1 because __get_vm_area allocates an
42175 * extra guard page, so we need space for that.
42176 */
42177 +
42178 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
42179 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42180 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
42181 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42182 +#else
42183 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42184 VM_ALLOC, switcher_addr, switcher_addr
42185 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42186 +#endif
42187 +
42188 if (!switcher_vma) {
42189 err = -ENOMEM;
42190 printk("lguest: could not map switcher pages high\n");
42191 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
42192 * Now the Switcher is mapped at the right address, we can't fail!
42193 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
42194 */
42195 - memcpy(switcher_vma->addr, start_switcher_text,
42196 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
42197 end_switcher_text - start_switcher_text);
42198
42199 printk(KERN_INFO "lguest: mapped switcher at %p\n",
42200 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
42201 index a35d8d1..59fb772 100644
42202 --- a/drivers/lguest/page_tables.c
42203 +++ b/drivers/lguest/page_tables.c
42204 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
42205 /*:*/
42206
42207 #ifdef CONFIG_X86_PAE
42208 -static void release_pmd(pmd_t *spmd)
42209 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
42210 {
42211 /* If the entry's not present, there's nothing to release. */
42212 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
42213 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
42214 index 5169239..47cb4db 100644
42215 --- a/drivers/lguest/x86/core.c
42216 +++ b/drivers/lguest/x86/core.c
42217 @@ -59,7 +59,7 @@ static struct {
42218 /* Offset from where switcher.S was compiled to where we've copied it */
42219 static unsigned long switcher_offset(void)
42220 {
42221 - return switcher_addr - (unsigned long)start_switcher_text;
42222 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
42223 }
42224
42225 /* This cpu's struct lguest_pages (after the Switcher text page) */
42226 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42227 * These copies are pretty cheap, so we do them unconditionally: */
42228 /* Save the current Host top-level page directory.
42229 */
42230 +
42231 +#ifdef CONFIG_PAX_PER_CPU_PGD
42232 + pages->state.host_cr3 = read_cr3();
42233 +#else
42234 pages->state.host_cr3 = __pa(current->mm->pgd);
42235 +#endif
42236 +
42237 /*
42238 * Set up the Guest's page tables to see this CPU's pages (and no
42239 * other CPU's pages).
42240 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42241 * compiled-in switcher code and the high-mapped copy we just made.
42242 */
42243 for (i = 0; i < IDT_ENTRIES; i++)
42244 - default_idt_entries[i] += switcher_offset();
42245 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42246
42247 /*
42248 * Set up the Switcher's per-cpu areas.
42249 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42250 * it will be undisturbed when we switch. To change %cs and jump we
42251 * need this structure to feed to Intel's "lcall" instruction.
42252 */
42253 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42254 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42255 lguest_entry.segment = LGUEST_CS;
42256
42257 /*
42258 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42259 index 40634b0..4f5855e 100644
42260 --- a/drivers/lguest/x86/switcher_32.S
42261 +++ b/drivers/lguest/x86/switcher_32.S
42262 @@ -87,6 +87,7 @@
42263 #include <asm/page.h>
42264 #include <asm/segment.h>
42265 #include <asm/lguest.h>
42266 +#include <asm/processor-flags.h>
42267
42268 // We mark the start of the code to copy
42269 // It's placed in .text tho it's never run here
42270 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42271 // Changes type when we load it: damn Intel!
42272 // For after we switch over our page tables
42273 // That entry will be read-only: we'd crash.
42274 +
42275 +#ifdef CONFIG_PAX_KERNEXEC
42276 + mov %cr0, %edx
42277 + xor $X86_CR0_WP, %edx
42278 + mov %edx, %cr0
42279 +#endif
42280 +
42281 movl $(GDT_ENTRY_TSS*8), %edx
42282 ltr %dx
42283
42284 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42285 // Let's clear it again for our return.
42286 // The GDT descriptor of the Host
42287 // Points to the table after two "size" bytes
42288 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42289 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42290 // Clear "used" from type field (byte 5, bit 2)
42291 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42292 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42293 +
42294 +#ifdef CONFIG_PAX_KERNEXEC
42295 + mov %cr0, %eax
42296 + xor $X86_CR0_WP, %eax
42297 + mov %eax, %cr0
42298 +#endif
42299
42300 // Once our page table's switched, the Guest is live!
42301 // The Host fades as we run this final step.
42302 @@ -295,13 +309,12 @@ deliver_to_host:
42303 // I consulted gcc, and it gave
42304 // These instructions, which I gladly credit:
42305 leal (%edx,%ebx,8), %eax
42306 - movzwl (%eax),%edx
42307 - movl 4(%eax), %eax
42308 - xorw %ax, %ax
42309 - orl %eax, %edx
42310 + movl 4(%eax), %edx
42311 + movw (%eax), %dx
42312 // Now the address of the handler's in %edx
42313 // We call it now: its "iret" drops us home.
42314 - jmp *%edx
42315 + ljmp $__KERNEL_CS, $1f
42316 +1: jmp *%edx
42317
42318 // Every interrupt can come to us here
42319 // But we must truly tell each apart.
42320 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42321 index 0003992..854bbce 100644
42322 --- a/drivers/md/bcache/closure.h
42323 +++ b/drivers/md/bcache/closure.h
42324 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42325 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42326 struct workqueue_struct *wq)
42327 {
42328 - BUG_ON(object_is_on_stack(cl));
42329 + BUG_ON(object_starts_on_stack(cl));
42330 closure_set_ip(cl);
42331 cl->fn = fn;
42332 cl->wq = wq;
42333 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42334 index 547c4c5..5be1de4 100644
42335 --- a/drivers/md/bcache/super.c
42336 +++ b/drivers/md/bcache/super.c
42337 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42338 err:
42339 closure_sync(&op.cl);
42340 /* XXX: test this, it's broken */
42341 - bch_cache_set_error(c, err);
42342 + bch_cache_set_error(c, "%s", err);
42343 }
42344
42345 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42346 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42347 index a7fd821..9dcf6c3 100644
42348 --- a/drivers/md/bitmap.c
42349 +++ b/drivers/md/bitmap.c
42350 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42351 chunk_kb ? "KB" : "B");
42352 if (bitmap->storage.file) {
42353 seq_printf(seq, ", file: ");
42354 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42355 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42356 }
42357
42358 seq_printf(seq, "\n");
42359 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42360 index f1b7586..a49c4bd 100644
42361 --- a/drivers/md/dm-ioctl.c
42362 +++ b/drivers/md/dm-ioctl.c
42363 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42364 cmd == DM_LIST_VERSIONS_CMD)
42365 return 0;
42366
42367 - if ((cmd == DM_DEV_CREATE_CMD)) {
42368 + if (cmd == DM_DEV_CREATE_CMD) {
42369 if (!*param->name) {
42370 DMWARN("name not supplied when creating device");
42371 return -EINVAL;
42372 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42373 index 699b5be..eac0a15 100644
42374 --- a/drivers/md/dm-raid1.c
42375 +++ b/drivers/md/dm-raid1.c
42376 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42377
42378 struct mirror {
42379 struct mirror_set *ms;
42380 - atomic_t error_count;
42381 + atomic_unchecked_t error_count;
42382 unsigned long error_type;
42383 struct dm_dev *dev;
42384 sector_t offset;
42385 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42386 struct mirror *m;
42387
42388 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42389 - if (!atomic_read(&m->error_count))
42390 + if (!atomic_read_unchecked(&m->error_count))
42391 return m;
42392
42393 return NULL;
42394 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42395 * simple way to tell if a device has encountered
42396 * errors.
42397 */
42398 - atomic_inc(&m->error_count);
42399 + atomic_inc_unchecked(&m->error_count);
42400
42401 if (test_and_set_bit(error_type, &m->error_type))
42402 return;
42403 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42404 struct mirror *m = get_default_mirror(ms);
42405
42406 do {
42407 - if (likely(!atomic_read(&m->error_count)))
42408 + if (likely(!atomic_read_unchecked(&m->error_count)))
42409 return m;
42410
42411 if (m-- == ms->mirror)
42412 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42413 {
42414 struct mirror *default_mirror = get_default_mirror(m->ms);
42415
42416 - return !atomic_read(&default_mirror->error_count);
42417 + return !atomic_read_unchecked(&default_mirror->error_count);
42418 }
42419
42420 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42421 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42422 */
42423 if (likely(region_in_sync(ms, region, 1)))
42424 m = choose_mirror(ms, bio->bi_sector);
42425 - else if (m && atomic_read(&m->error_count))
42426 + else if (m && atomic_read_unchecked(&m->error_count))
42427 m = NULL;
42428
42429 if (likely(m))
42430 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42431 }
42432
42433 ms->mirror[mirror].ms = ms;
42434 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42435 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42436 ms->mirror[mirror].error_type = 0;
42437 ms->mirror[mirror].offset = offset;
42438
42439 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42440 */
42441 static char device_status_char(struct mirror *m)
42442 {
42443 - if (!atomic_read(&(m->error_count)))
42444 + if (!atomic_read_unchecked(&(m->error_count)))
42445 return 'A';
42446
42447 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42448 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42449 index d907ca6..cfb8384 100644
42450 --- a/drivers/md/dm-stripe.c
42451 +++ b/drivers/md/dm-stripe.c
42452 @@ -20,7 +20,7 @@ struct stripe {
42453 struct dm_dev *dev;
42454 sector_t physical_start;
42455
42456 - atomic_t error_count;
42457 + atomic_unchecked_t error_count;
42458 };
42459
42460 struct stripe_c {
42461 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42462 kfree(sc);
42463 return r;
42464 }
42465 - atomic_set(&(sc->stripe[i].error_count), 0);
42466 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42467 }
42468
42469 ti->private = sc;
42470 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42471 DMEMIT("%d ", sc->stripes);
42472 for (i = 0; i < sc->stripes; i++) {
42473 DMEMIT("%s ", sc->stripe[i].dev->name);
42474 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42475 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42476 'D' : 'A';
42477 }
42478 buffer[i] = '\0';
42479 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42480 */
42481 for (i = 0; i < sc->stripes; i++)
42482 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42483 - atomic_inc(&(sc->stripe[i].error_count));
42484 - if (atomic_read(&(sc->stripe[i].error_count)) <
42485 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42486 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42487 DM_IO_ERROR_THRESHOLD)
42488 schedule_work(&sc->trigger_event);
42489 }
42490 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42491 index f221812..aca962b 100644
42492 --- a/drivers/md/dm-table.c
42493 +++ b/drivers/md/dm-table.c
42494 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42495 if (!dev_size)
42496 return 0;
42497
42498 - if ((start >= dev_size) || (start + len > dev_size)) {
42499 + if ((start >= dev_size) || (len > dev_size - start)) {
42500 DMWARN("%s: %s too small for target: "
42501 "start=%llu, len=%llu, dev_size=%llu",
42502 dm_device_name(ti->table->md), bdevname(bdev, b),
42503 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42504 index 60bce43..9b997d0 100644
42505 --- a/drivers/md/dm-thin-metadata.c
42506 +++ b/drivers/md/dm-thin-metadata.c
42507 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42508 {
42509 pmd->info.tm = pmd->tm;
42510 pmd->info.levels = 2;
42511 - pmd->info.value_type.context = pmd->data_sm;
42512 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42513 pmd->info.value_type.size = sizeof(__le64);
42514 pmd->info.value_type.inc = data_block_inc;
42515 pmd->info.value_type.dec = data_block_dec;
42516 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42517
42518 pmd->bl_info.tm = pmd->tm;
42519 pmd->bl_info.levels = 1;
42520 - pmd->bl_info.value_type.context = pmd->data_sm;
42521 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42522 pmd->bl_info.value_type.size = sizeof(__le64);
42523 pmd->bl_info.value_type.inc = data_block_inc;
42524 pmd->bl_info.value_type.dec = data_block_dec;
42525 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42526 index 9e39d2b..fb879a7 100644
42527 --- a/drivers/md/dm.c
42528 +++ b/drivers/md/dm.c
42529 @@ -178,9 +178,9 @@ struct mapped_device {
42530 /*
42531 * Event handling.
42532 */
42533 - atomic_t event_nr;
42534 + atomic_unchecked_t event_nr;
42535 wait_queue_head_t eventq;
42536 - atomic_t uevent_seq;
42537 + atomic_unchecked_t uevent_seq;
42538 struct list_head uevent_list;
42539 spinlock_t uevent_lock; /* Protect access to uevent_list */
42540
42541 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42542 spin_lock_init(&md->deferred_lock);
42543 atomic_set(&md->holders, 1);
42544 atomic_set(&md->open_count, 0);
42545 - atomic_set(&md->event_nr, 0);
42546 - atomic_set(&md->uevent_seq, 0);
42547 + atomic_set_unchecked(&md->event_nr, 0);
42548 + atomic_set_unchecked(&md->uevent_seq, 0);
42549 INIT_LIST_HEAD(&md->uevent_list);
42550 spin_lock_init(&md->uevent_lock);
42551
42552 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42553
42554 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42555
42556 - atomic_inc(&md->event_nr);
42557 + atomic_inc_unchecked(&md->event_nr);
42558 wake_up(&md->eventq);
42559 }
42560
42561 @@ -2716,18 +2716,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42562
42563 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42564 {
42565 - return atomic_add_return(1, &md->uevent_seq);
42566 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42567 }
42568
42569 uint32_t dm_get_event_nr(struct mapped_device *md)
42570 {
42571 - return atomic_read(&md->event_nr);
42572 + return atomic_read_unchecked(&md->event_nr);
42573 }
42574
42575 int dm_wait_event(struct mapped_device *md, int event_nr)
42576 {
42577 return wait_event_interruptible(md->eventq,
42578 - (event_nr != atomic_read(&md->event_nr)));
42579 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42580 }
42581
42582 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42583 diff --git a/drivers/md/md.c b/drivers/md/md.c
42584 index 9f13e13..411a5b8 100644
42585 --- a/drivers/md/md.c
42586 +++ b/drivers/md/md.c
42587 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42588 * start build, activate spare
42589 */
42590 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42591 -static atomic_t md_event_count;
42592 +static atomic_unchecked_t md_event_count;
42593 void md_new_event(struct mddev *mddev)
42594 {
42595 - atomic_inc(&md_event_count);
42596 + atomic_inc_unchecked(&md_event_count);
42597 wake_up(&md_event_waiters);
42598 }
42599 EXPORT_SYMBOL_GPL(md_new_event);
42600 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42601 */
42602 static void md_new_event_inintr(struct mddev *mddev)
42603 {
42604 - atomic_inc(&md_event_count);
42605 + atomic_inc_unchecked(&md_event_count);
42606 wake_up(&md_event_waiters);
42607 }
42608
42609 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42610 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42611 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42612 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42613 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42614 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42615
42616 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42617 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42618 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42619 else
42620 sb->resync_offset = cpu_to_le64(0);
42621
42622 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42623 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42624
42625 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42626 sb->size = cpu_to_le64(mddev->dev_sectors);
42627 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42628 static ssize_t
42629 errors_show(struct md_rdev *rdev, char *page)
42630 {
42631 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42632 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42633 }
42634
42635 static ssize_t
42636 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42637 char *e;
42638 unsigned long n = simple_strtoul(buf, &e, 10);
42639 if (*buf && (*e == 0 || *e == '\n')) {
42640 - atomic_set(&rdev->corrected_errors, n);
42641 + atomic_set_unchecked(&rdev->corrected_errors, n);
42642 return len;
42643 }
42644 return -EINVAL;
42645 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42646 rdev->sb_loaded = 0;
42647 rdev->bb_page = NULL;
42648 atomic_set(&rdev->nr_pending, 0);
42649 - atomic_set(&rdev->read_errors, 0);
42650 - atomic_set(&rdev->corrected_errors, 0);
42651 + atomic_set_unchecked(&rdev->read_errors, 0);
42652 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42653
42654 INIT_LIST_HEAD(&rdev->same_set);
42655 init_waitqueue_head(&rdev->blocked_wait);
42656 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42657
42658 spin_unlock(&pers_lock);
42659 seq_printf(seq, "\n");
42660 - seq->poll_event = atomic_read(&md_event_count);
42661 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42662 return 0;
42663 }
42664 if (v == (void*)2) {
42665 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42666 return error;
42667
42668 seq = file->private_data;
42669 - seq->poll_event = atomic_read(&md_event_count);
42670 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42671 return error;
42672 }
42673
42674 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42675 /* always allow read */
42676 mask = POLLIN | POLLRDNORM;
42677
42678 - if (seq->poll_event != atomic_read(&md_event_count))
42679 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42680 mask |= POLLERR | POLLPRI;
42681 return mask;
42682 }
42683 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42684 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42685 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42686 (int)part_stat_read(&disk->part0, sectors[1]) -
42687 - atomic_read(&disk->sync_io);
42688 + atomic_read_unchecked(&disk->sync_io);
42689 /* sync IO will cause sync_io to increase before the disk_stats
42690 * as sync_io is counted when a request starts, and
42691 * disk_stats is counted when it completes.
42692 diff --git a/drivers/md/md.h b/drivers/md/md.h
42693 index 20f02c0..fd8c821 100644
42694 --- a/drivers/md/md.h
42695 +++ b/drivers/md/md.h
42696 @@ -94,13 +94,13 @@ struct md_rdev {
42697 * only maintained for arrays that
42698 * support hot removal
42699 */
42700 - atomic_t read_errors; /* number of consecutive read errors that
42701 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42702 * we have tried to ignore.
42703 */
42704 struct timespec last_read_error; /* monotonic time since our
42705 * last read error
42706 */
42707 - atomic_t corrected_errors; /* number of corrected read errors,
42708 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42709 * for reporting to userspace and storing
42710 * in superblock.
42711 */
42712 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42713
42714 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42715 {
42716 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42717 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42718 }
42719
42720 struct md_personality
42721 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42722 index 3e6d115..ffecdeb 100644
42723 --- a/drivers/md/persistent-data/dm-space-map.h
42724 +++ b/drivers/md/persistent-data/dm-space-map.h
42725 @@ -71,6 +71,7 @@ struct dm_space_map {
42726 dm_sm_threshold_fn fn,
42727 void *context);
42728 };
42729 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42730
42731 /*----------------------------------------------------------------*/
42732
42733 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42734 index d60412c..8d4c982 100644
42735 --- a/drivers/md/raid1.c
42736 +++ b/drivers/md/raid1.c
42737 @@ -1823,7 +1823,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42738 if (r1_sync_page_io(rdev, sect, s,
42739 bio->bi_io_vec[idx].bv_page,
42740 READ) != 0)
42741 - atomic_add(s, &rdev->corrected_errors);
42742 + atomic_add_unchecked(s, &rdev->corrected_errors);
42743 }
42744 sectors -= s;
42745 sect += s;
42746 @@ -2050,7 +2050,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42747 test_bit(In_sync, &rdev->flags)) {
42748 if (r1_sync_page_io(rdev, sect, s,
42749 conf->tmppage, READ)) {
42750 - atomic_add(s, &rdev->corrected_errors);
42751 + atomic_add_unchecked(s, &rdev->corrected_errors);
42752 printk(KERN_INFO
42753 "md/raid1:%s: read error corrected "
42754 "(%d sectors at %llu on %s)\n",
42755 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42756 index df7b0a0..a257495 100644
42757 --- a/drivers/md/raid10.c
42758 +++ b/drivers/md/raid10.c
42759 @@ -1962,7 +1962,7 @@ static void end_sync_read(struct bio *bio, int error)
42760 /* The write handler will notice the lack of
42761 * R10BIO_Uptodate and record any errors etc
42762 */
42763 - atomic_add(r10_bio->sectors,
42764 + atomic_add_unchecked(r10_bio->sectors,
42765 &conf->mirrors[d].rdev->corrected_errors);
42766
42767 /* for reconstruct, we always reschedule after a read.
42768 @@ -2320,7 +2320,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42769 {
42770 struct timespec cur_time_mon;
42771 unsigned long hours_since_last;
42772 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42773 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42774
42775 ktime_get_ts(&cur_time_mon);
42776
42777 @@ -2342,9 +2342,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42778 * overflowing the shift of read_errors by hours_since_last.
42779 */
42780 if (hours_since_last >= 8 * sizeof(read_errors))
42781 - atomic_set(&rdev->read_errors, 0);
42782 + atomic_set_unchecked(&rdev->read_errors, 0);
42783 else
42784 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42785 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42786 }
42787
42788 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42789 @@ -2398,8 +2398,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42790 return;
42791
42792 check_decay_read_errors(mddev, rdev);
42793 - atomic_inc(&rdev->read_errors);
42794 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42795 + atomic_inc_unchecked(&rdev->read_errors);
42796 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42797 char b[BDEVNAME_SIZE];
42798 bdevname(rdev->bdev, b);
42799
42800 @@ -2407,7 +2407,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42801 "md/raid10:%s: %s: Raid device exceeded "
42802 "read_error threshold [cur %d:max %d]\n",
42803 mdname(mddev), b,
42804 - atomic_read(&rdev->read_errors), max_read_errors);
42805 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42806 printk(KERN_NOTICE
42807 "md/raid10:%s: %s: Failing raid device\n",
42808 mdname(mddev), b);
42809 @@ -2562,7 +2562,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42810 sect +
42811 choose_data_offset(r10_bio, rdev)),
42812 bdevname(rdev->bdev, b));
42813 - atomic_add(s, &rdev->corrected_errors);
42814 + atomic_add_unchecked(s, &rdev->corrected_errors);
42815 }
42816
42817 rdev_dec_pending(rdev, mddev);
42818 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42819 index 78ea443..7d57513 100644
42820 --- a/drivers/md/raid5.c
42821 +++ b/drivers/md/raid5.c
42822 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42823 mdname(conf->mddev), STRIPE_SECTORS,
42824 (unsigned long long)s,
42825 bdevname(rdev->bdev, b));
42826 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42827 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42828 clear_bit(R5_ReadError, &sh->dev[i].flags);
42829 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42830 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42831 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42832
42833 - if (atomic_read(&rdev->read_errors))
42834 - atomic_set(&rdev->read_errors, 0);
42835 + if (atomic_read_unchecked(&rdev->read_errors))
42836 + atomic_set_unchecked(&rdev->read_errors, 0);
42837 } else {
42838 const char *bdn = bdevname(rdev->bdev, b);
42839 int retry = 0;
42840 int set_bad = 0;
42841
42842 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42843 - atomic_inc(&rdev->read_errors);
42844 + atomic_inc_unchecked(&rdev->read_errors);
42845 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42846 printk_ratelimited(
42847 KERN_WARNING
42848 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42849 mdname(conf->mddev),
42850 (unsigned long long)s,
42851 bdn);
42852 - } else if (atomic_read(&rdev->read_errors)
42853 + } else if (atomic_read_unchecked(&rdev->read_errors)
42854 > conf->max_nr_stripes)
42855 printk(KERN_WARNING
42856 "md/raid:%s: Too many read errors, failing device %s.\n",
42857 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42858 index 401ef64..836e563 100644
42859 --- a/drivers/media/dvb-core/dvbdev.c
42860 +++ b/drivers/media/dvb-core/dvbdev.c
42861 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42862 const struct dvb_device *template, void *priv, int type)
42863 {
42864 struct dvb_device *dvbdev;
42865 - struct file_operations *dvbdevfops;
42866 + file_operations_no_const *dvbdevfops;
42867 struct device *clsdev;
42868 int minor;
42869 int id;
42870 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42871 index 9b6c3bb..baeb5c7 100644
42872 --- a/drivers/media/dvb-frontends/dib3000.h
42873 +++ b/drivers/media/dvb-frontends/dib3000.h
42874 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42875 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42876 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42877 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42878 -};
42879 +} __no_const;
42880
42881 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42882 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42883 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42884 index ecf21d9..b992428d 100644
42885 --- a/drivers/media/pci/cx88/cx88-video.c
42886 +++ b/drivers/media/pci/cx88/cx88-video.c
42887 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42888
42889 /* ------------------------------------------------------------------ */
42890
42891 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42892 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42893 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42894 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42895 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42896 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42897
42898 module_param_array(video_nr, int, NULL, 0444);
42899 module_param_array(vbi_nr, int, NULL, 0444);
42900 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42901 index c08ae3e..eb59af1 100644
42902 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42903 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42904 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42905 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42906
42907 /* ivtv instance counter */
42908 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42909 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42910
42911 /* Parameter declarations */
42912 static int cardtype[IVTV_MAX_CARDS];
42913 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42914 index dfd0a21..6bbb465 100644
42915 --- a/drivers/media/platform/omap/omap_vout.c
42916 +++ b/drivers/media/platform/omap/omap_vout.c
42917 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42918 OMAP_VIDEO2,
42919 };
42920
42921 -static struct videobuf_queue_ops video_vbq_ops;
42922 /* Variables configurable through module params*/
42923 static u32 video1_numbuffers = 3;
42924 static u32 video2_numbuffers = 3;
42925 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42926 {
42927 struct videobuf_queue *q;
42928 struct omap_vout_device *vout = NULL;
42929 + static struct videobuf_queue_ops video_vbq_ops = {
42930 + .buf_setup = omap_vout_buffer_setup,
42931 + .buf_prepare = omap_vout_buffer_prepare,
42932 + .buf_release = omap_vout_buffer_release,
42933 + .buf_queue = omap_vout_buffer_queue,
42934 + };
42935
42936 vout = video_drvdata(file);
42937 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42938 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42939 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42940
42941 q = &vout->vbq;
42942 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42943 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42944 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42945 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42946 spin_lock_init(&vout->vbq_lock);
42947
42948 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42949 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42950 index 04e6490..2df65bf 100644
42951 --- a/drivers/media/platform/s5p-tv/mixer.h
42952 +++ b/drivers/media/platform/s5p-tv/mixer.h
42953 @@ -156,7 +156,7 @@ struct mxr_layer {
42954 /** layer index (unique identifier) */
42955 int idx;
42956 /** callbacks for layer methods */
42957 - struct mxr_layer_ops ops;
42958 + struct mxr_layer_ops *ops;
42959 /** format array */
42960 const struct mxr_format **fmt_array;
42961 /** size of format array */
42962 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42963 index b93a21f..2535195 100644
42964 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42965 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42966 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42967 {
42968 struct mxr_layer *layer;
42969 int ret;
42970 - struct mxr_layer_ops ops = {
42971 + static struct mxr_layer_ops ops = {
42972 .release = mxr_graph_layer_release,
42973 .buffer_set = mxr_graph_buffer_set,
42974 .stream_set = mxr_graph_stream_set,
42975 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42976 index b713403..53cb5ad 100644
42977 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42978 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42979 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42980 layer->update_buf = next;
42981 }
42982
42983 - layer->ops.buffer_set(layer, layer->update_buf);
42984 + layer->ops->buffer_set(layer, layer->update_buf);
42985
42986 if (done && done != layer->shadow_buf)
42987 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42988 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42989 index 641b1f0..49cff30 100644
42990 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42991 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42992 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42993 layer->geo.src.height = layer->geo.src.full_height;
42994
42995 mxr_geometry_dump(mdev, &layer->geo);
42996 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42997 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42998 mxr_geometry_dump(mdev, &layer->geo);
42999 }
43000
43001 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
43002 layer->geo.dst.full_width = mbus_fmt.width;
43003 layer->geo.dst.full_height = mbus_fmt.height;
43004 layer->geo.dst.field = mbus_fmt.field;
43005 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43006 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43007
43008 mxr_geometry_dump(mdev, &layer->geo);
43009 }
43010 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
43011 /* set source size to highest accepted value */
43012 geo->src.full_width = max(geo->dst.full_width, pix->width);
43013 geo->src.full_height = max(geo->dst.full_height, pix->height);
43014 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43015 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43016 mxr_geometry_dump(mdev, &layer->geo);
43017 /* set cropping to total visible screen */
43018 geo->src.width = pix->width;
43019 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
43020 geo->src.x_offset = 0;
43021 geo->src.y_offset = 0;
43022 /* assure consistency of geometry */
43023 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
43024 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
43025 mxr_geometry_dump(mdev, &layer->geo);
43026 /* set full size to lowest possible value */
43027 geo->src.full_width = 0;
43028 geo->src.full_height = 0;
43029 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43030 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43031 mxr_geometry_dump(mdev, &layer->geo);
43032
43033 /* returning results */
43034 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
43035 target->width = s->r.width;
43036 target->height = s->r.height;
43037
43038 - layer->ops.fix_geometry(layer, stage, s->flags);
43039 + layer->ops->fix_geometry(layer, stage, s->flags);
43040
43041 /* retrieve update selection rectangle */
43042 res.left = target->x_offset;
43043 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
43044 mxr_output_get(mdev);
43045
43046 mxr_layer_update_output(layer);
43047 - layer->ops.format_set(layer);
43048 + layer->ops->format_set(layer);
43049 /* enabling layer in hardware */
43050 spin_lock_irqsave(&layer->enq_slock, flags);
43051 layer->state = MXR_LAYER_STREAMING;
43052 spin_unlock_irqrestore(&layer->enq_slock, flags);
43053
43054 - layer->ops.stream_set(layer, MXR_ENABLE);
43055 + layer->ops->stream_set(layer, MXR_ENABLE);
43056 mxr_streamer_get(mdev);
43057
43058 return 0;
43059 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
43060 spin_unlock_irqrestore(&layer->enq_slock, flags);
43061
43062 /* disabling layer in hardware */
43063 - layer->ops.stream_set(layer, MXR_DISABLE);
43064 + layer->ops->stream_set(layer, MXR_DISABLE);
43065 /* remove one streamer */
43066 mxr_streamer_put(mdev);
43067 /* allow changes in output configuration */
43068 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
43069
43070 void mxr_layer_release(struct mxr_layer *layer)
43071 {
43072 - if (layer->ops.release)
43073 - layer->ops.release(layer);
43074 + if (layer->ops->release)
43075 + layer->ops->release(layer);
43076 }
43077
43078 void mxr_base_layer_release(struct mxr_layer *layer)
43079 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
43080
43081 layer->mdev = mdev;
43082 layer->idx = idx;
43083 - layer->ops = *ops;
43084 + layer->ops = ops;
43085
43086 spin_lock_init(&layer->enq_slock);
43087 INIT_LIST_HEAD(&layer->enq_list);
43088 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43089 index 3d13a63..da31bf1 100644
43090 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43091 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43092 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
43093 {
43094 struct mxr_layer *layer;
43095 int ret;
43096 - struct mxr_layer_ops ops = {
43097 + static struct mxr_layer_ops ops = {
43098 .release = mxr_vp_layer_release,
43099 .buffer_set = mxr_vp_buffer_set,
43100 .stream_set = mxr_vp_stream_set,
43101 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
43102 index 545c04c..a14bded 100644
43103 --- a/drivers/media/radio/radio-cadet.c
43104 +++ b/drivers/media/radio/radio-cadet.c
43105 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43106 unsigned char readbuf[RDS_BUFFER];
43107 int i = 0;
43108
43109 + if (count > RDS_BUFFER)
43110 + return -EFAULT;
43111 mutex_lock(&dev->lock);
43112 if (dev->rdsstat == 0)
43113 cadet_start_rds(dev);
43114 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43115 while (i < count && dev->rdsin != dev->rdsout)
43116 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
43117
43118 - if (i && copy_to_user(data, readbuf, i))
43119 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
43120 i = -EFAULT;
43121 unlock:
43122 mutex_unlock(&dev->lock);
43123 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
43124 index bd4d3a7..ffc0b9d 100644
43125 --- a/drivers/media/radio/radio-maxiradio.c
43126 +++ b/drivers/media/radio/radio-maxiradio.c
43127 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
43128 /* TEA5757 pin mappings */
43129 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
43130
43131 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
43132 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
43133
43134 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
43135 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
43136 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
43137 index 8fa18ab..caee70f 100644
43138 --- a/drivers/media/radio/radio-shark.c
43139 +++ b/drivers/media/radio/radio-shark.c
43140 @@ -79,7 +79,7 @@ struct shark_device {
43141 u32 last_val;
43142 };
43143
43144 -static atomic_t shark_instance = ATOMIC_INIT(0);
43145 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43146
43147 static void shark_write_val(struct snd_tea575x *tea, u32 val)
43148 {
43149 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
43150 index 9fb6697..f167415 100644
43151 --- a/drivers/media/radio/radio-shark2.c
43152 +++ b/drivers/media/radio/radio-shark2.c
43153 @@ -74,7 +74,7 @@ struct shark_device {
43154 u8 *transfer_buffer;
43155 };
43156
43157 -static atomic_t shark_instance = ATOMIC_INIT(0);
43158 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43159
43160 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
43161 {
43162 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
43163 index 9c9084c..a9e8dfb 100644
43164 --- a/drivers/media/radio/radio-si476x.c
43165 +++ b/drivers/media/radio/radio-si476x.c
43166 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
43167 struct si476x_radio *radio;
43168 struct v4l2_ctrl *ctrl;
43169
43170 - static atomic_t instance = ATOMIC_INIT(0);
43171 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
43172
43173 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
43174 if (!radio)
43175 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
43176 index 1cf382a..c22998c 100644
43177 --- a/drivers/media/rc/rc-main.c
43178 +++ b/drivers/media/rc/rc-main.c
43179 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
43180 int rc_register_device(struct rc_dev *dev)
43181 {
43182 static bool raw_init = false; /* raw decoders loaded? */
43183 - static atomic_t devno = ATOMIC_INIT(0);
43184 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
43185 struct rc_map *rc_map;
43186 const char *path;
43187 int rc;
43188 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
43189 */
43190 mutex_lock(&dev->lock);
43191
43192 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
43193 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
43194 dev_set_name(&dev->dev, "rc%ld", dev->devno);
43195 dev_set_drvdata(&dev->dev, dev);
43196 rc = device_add(&dev->dev);
43197 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
43198 index 3940bb0..fb3952a 100644
43199 --- a/drivers/media/usb/dvb-usb/cxusb.c
43200 +++ b/drivers/media/usb/dvb-usb/cxusb.c
43201 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
43202
43203 struct dib0700_adapter_state {
43204 int (*set_param_save) (struct dvb_frontend *);
43205 -};
43206 +} __no_const;
43207
43208 static int dib7070_set_param_override(struct dvb_frontend *fe)
43209 {
43210 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
43211 index 6e237b6..dc25556 100644
43212 --- a/drivers/media/usb/dvb-usb/dw2102.c
43213 +++ b/drivers/media/usb/dvb-usb/dw2102.c
43214 @@ -118,7 +118,7 @@ struct su3000_state {
43215
43216 struct s6x0_state {
43217 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
43218 -};
43219 +} __no_const;
43220
43221 /* debug */
43222 static int dvb_usb_dw2102_debug;
43223 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43224 index 8f7a6a4..59502dd 100644
43225 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43226 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43227 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43228 __u32 reserved;
43229 };
43230
43231 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43232 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43233 enum v4l2_memory memory)
43234 {
43235 void __user *up_pln;
43236 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43237 return 0;
43238 }
43239
43240 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43241 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43242 enum v4l2_memory memory)
43243 {
43244 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43245 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43246 put_user(kp->start_block, &up->start_block) ||
43247 put_user(kp->blocks, &up->blocks) ||
43248 put_user(tmp, &up->edid) ||
43249 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43250 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43251 return -EFAULT;
43252 return 0;
43253 }
43254 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43255 index 02d1b63..5fd6b16 100644
43256 --- a/drivers/media/v4l2-core/v4l2-device.c
43257 +++ b/drivers/media/v4l2-core/v4l2-device.c
43258 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43259 EXPORT_SYMBOL_GPL(v4l2_device_put);
43260
43261 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43262 - atomic_t *instance)
43263 + atomic_unchecked_t *instance)
43264 {
43265 - int num = atomic_inc_return(instance) - 1;
43266 + int num = atomic_inc_return_unchecked(instance) - 1;
43267 int len = strlen(basename);
43268
43269 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43270 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43271 index 68e6b5e..d8b923e 100644
43272 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43273 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43274 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43275 struct file *file, void *fh, void *p);
43276 } u;
43277 void (*debug)(const void *arg, bool write_only);
43278 -};
43279 +} __do_const;
43280 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43281
43282 /* This control needs a priority check */
43283 #define INFO_FL_PRIO (1 << 0)
43284 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43285 struct video_device *vfd = video_devdata(file);
43286 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43287 bool write_only = false;
43288 - struct v4l2_ioctl_info default_info;
43289 + v4l2_ioctl_info_no_const default_info;
43290 const struct v4l2_ioctl_info *info;
43291 void *fh = file->private_data;
43292 struct v4l2_fh *vfh = NULL;
43293 @@ -2194,7 +2195,7 @@ done:
43294 }
43295
43296 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43297 - void * __user *user_ptr, void ***kernel_ptr)
43298 + void __user **user_ptr, void ***kernel_ptr)
43299 {
43300 int ret = 0;
43301
43302 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43303 ret = -EINVAL;
43304 break;
43305 }
43306 - *user_ptr = (void __user *)buf->m.planes;
43307 + *user_ptr = (void __force_user *)buf->m.planes;
43308 *kernel_ptr = (void *)&buf->m.planes;
43309 *array_size = sizeof(struct v4l2_plane) * buf->length;
43310 ret = 1;
43311 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43312 ret = -EINVAL;
43313 break;
43314 }
43315 - *user_ptr = (void __user *)ctrls->controls;
43316 + *user_ptr = (void __force_user *)ctrls->controls;
43317 *kernel_ptr = (void *)&ctrls->controls;
43318 *array_size = sizeof(struct v4l2_ext_control)
43319 * ctrls->count;
43320 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43321 index 767ff4d..c69d259 100644
43322 --- a/drivers/message/fusion/mptbase.c
43323 +++ b/drivers/message/fusion/mptbase.c
43324 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43325 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43326 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43327
43328 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43329 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43330 +#else
43331 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43332 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43333 +#endif
43334 +
43335 /*
43336 * Rounding UP to nearest 4-kB boundary here...
43337 */
43338 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43339 ioc->facts.GlobalCredits);
43340
43341 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43342 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43343 + NULL, NULL);
43344 +#else
43345 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43346 +#endif
43347 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43348 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43349 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43350 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43351 index dd239bd..689c4f7 100644
43352 --- a/drivers/message/fusion/mptsas.c
43353 +++ b/drivers/message/fusion/mptsas.c
43354 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43355 return 0;
43356 }
43357
43358 +static inline void
43359 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43360 +{
43361 + if (phy_info->port_details) {
43362 + phy_info->port_details->rphy = rphy;
43363 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43364 + ioc->name, rphy));
43365 + }
43366 +
43367 + if (rphy) {
43368 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43369 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43370 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43371 + ioc->name, rphy, rphy->dev.release));
43372 + }
43373 +}
43374 +
43375 /* no mutex */
43376 static void
43377 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43378 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43379 return NULL;
43380 }
43381
43382 -static inline void
43383 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43384 -{
43385 - if (phy_info->port_details) {
43386 - phy_info->port_details->rphy = rphy;
43387 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43388 - ioc->name, rphy));
43389 - }
43390 -
43391 - if (rphy) {
43392 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43393 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43394 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43395 - ioc->name, rphy, rphy->dev.release));
43396 - }
43397 -}
43398 -
43399 static inline struct sas_port *
43400 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43401 {
43402 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43403 index 727819c..ad74694 100644
43404 --- a/drivers/message/fusion/mptscsih.c
43405 +++ b/drivers/message/fusion/mptscsih.c
43406 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43407
43408 h = shost_priv(SChost);
43409
43410 - if (h) {
43411 - if (h->info_kbuf == NULL)
43412 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43413 - return h->info_kbuf;
43414 - h->info_kbuf[0] = '\0';
43415 + if (!h)
43416 + return NULL;
43417
43418 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43419 - h->info_kbuf[size-1] = '\0';
43420 - }
43421 + if (h->info_kbuf == NULL)
43422 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43423 + return h->info_kbuf;
43424 + h->info_kbuf[0] = '\0';
43425 +
43426 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43427 + h->info_kbuf[size-1] = '\0';
43428
43429 return h->info_kbuf;
43430 }
43431 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43432 index b7d87cd..9890039 100644
43433 --- a/drivers/message/i2o/i2o_proc.c
43434 +++ b/drivers/message/i2o/i2o_proc.c
43435 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43436 "Array Controller Device"
43437 };
43438
43439 -static char *chtostr(char *tmp, u8 *chars, int n)
43440 -{
43441 - tmp[0] = 0;
43442 - return strncat(tmp, (char *)chars, n);
43443 -}
43444 -
43445 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43446 char *group)
43447 {
43448 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43449 } *result;
43450
43451 i2o_exec_execute_ddm_table ddm_table;
43452 - char tmp[28 + 1];
43453
43454 result = kmalloc(sizeof(*result), GFP_KERNEL);
43455 if (!result)
43456 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43457
43458 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43459 seq_printf(seq, "%-#8x", ddm_table.module_id);
43460 - seq_printf(seq, "%-29s",
43461 - chtostr(tmp, ddm_table.module_name_version, 28));
43462 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43463 seq_printf(seq, "%9d ", ddm_table.data_size);
43464 seq_printf(seq, "%8d", ddm_table.code_size);
43465
43466 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43467
43468 i2o_driver_result_table *result;
43469 i2o_driver_store_table *dst;
43470 - char tmp[28 + 1];
43471
43472 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43473 if (result == NULL)
43474 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43475
43476 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43477 seq_printf(seq, "%-#8x", dst->module_id);
43478 - seq_printf(seq, "%-29s",
43479 - chtostr(tmp, dst->module_name_version, 28));
43480 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43481 + seq_printf(seq, "%-.28s", dst->module_name_version);
43482 + seq_printf(seq, "%-.8s", dst->date);
43483 seq_printf(seq, "%8d ", dst->module_size);
43484 seq_printf(seq, "%8d ", dst->mpb_size);
43485 seq_printf(seq, "0x%04x", dst->module_flags);
43486 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43487 // == (allow) 512d bytes (max)
43488 static u16 *work16 = (u16 *) work32;
43489 int token;
43490 - char tmp[16 + 1];
43491
43492 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43493
43494 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43495 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43496 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43497 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43498 - seq_printf(seq, "Vendor info : %s\n",
43499 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43500 - seq_printf(seq, "Product info : %s\n",
43501 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43502 - seq_printf(seq, "Description : %s\n",
43503 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43504 - seq_printf(seq, "Product rev. : %s\n",
43505 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43506 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43507 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43508 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43509 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43510
43511 seq_printf(seq, "Serial number : ");
43512 print_serial_number(seq, (u8 *) (work32 + 16),
43513 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43514 u8 pad[256]; // allow up to 256 byte (max) serial number
43515 } result;
43516
43517 - char tmp[24 + 1];
43518 -
43519 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43520
43521 if (token < 0) {
43522 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43523 }
43524
43525 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43526 - seq_printf(seq, "Module name : %s\n",
43527 - chtostr(tmp, result.module_name, 24));
43528 - seq_printf(seq, "Module revision : %s\n",
43529 - chtostr(tmp, result.module_rev, 8));
43530 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43531 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43532
43533 seq_printf(seq, "Serial number : ");
43534 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43535 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43536 u8 instance_number[4];
43537 } result;
43538
43539 - char tmp[64 + 1];
43540 -
43541 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43542
43543 if (token < 0) {
43544 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43545 return 0;
43546 }
43547
43548 - seq_printf(seq, "Device name : %s\n",
43549 - chtostr(tmp, result.device_name, 64));
43550 - seq_printf(seq, "Service name : %s\n",
43551 - chtostr(tmp, result.service_name, 64));
43552 - seq_printf(seq, "Physical name : %s\n",
43553 - chtostr(tmp, result.physical_location, 64));
43554 - seq_printf(seq, "Instance number : %s\n",
43555 - chtostr(tmp, result.instance_number, 4));
43556 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43557 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43558 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43559 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43560
43561 return 0;
43562 }
43563 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43564 index a8c08f3..155fe3d 100644
43565 --- a/drivers/message/i2o/iop.c
43566 +++ b/drivers/message/i2o/iop.c
43567 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43568
43569 spin_lock_irqsave(&c->context_list_lock, flags);
43570
43571 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43572 - atomic_inc(&c->context_list_counter);
43573 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43574 + atomic_inc_unchecked(&c->context_list_counter);
43575
43576 - entry->context = atomic_read(&c->context_list_counter);
43577 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43578
43579 list_add(&entry->list, &c->context_list);
43580
43581 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43582
43583 #if BITS_PER_LONG == 64
43584 spin_lock_init(&c->context_list_lock);
43585 - atomic_set(&c->context_list_counter, 0);
43586 + atomic_set_unchecked(&c->context_list_counter, 0);
43587 INIT_LIST_HEAD(&c->context_list);
43588 #endif
43589
43590 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43591 index fcbb2e9..2635e11 100644
43592 --- a/drivers/mfd/janz-cmodio.c
43593 +++ b/drivers/mfd/janz-cmodio.c
43594 @@ -13,6 +13,7 @@
43595
43596 #include <linux/kernel.h>
43597 #include <linux/module.h>
43598 +#include <linux/slab.h>
43599 #include <linux/init.h>
43600 #include <linux/pci.h>
43601 #include <linux/interrupt.h>
43602 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43603 index 9aa6d1e..1631bfc 100644
43604 --- a/drivers/mfd/twl4030-irq.c
43605 +++ b/drivers/mfd/twl4030-irq.c
43606 @@ -35,6 +35,7 @@
43607 #include <linux/of.h>
43608 #include <linux/irqdomain.h>
43609 #include <linux/i2c/twl.h>
43610 +#include <asm/pgtable.h>
43611
43612 #include "twl-core.h"
43613
43614 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43615 * Install an irq handler for each of the SIH modules;
43616 * clone dummy irq_chip since PIH can't *do* anything
43617 */
43618 - twl4030_irq_chip = dummy_irq_chip;
43619 - twl4030_irq_chip.name = "twl4030";
43620 + pax_open_kernel();
43621 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43622 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43623
43624 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43625 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43626 + pax_close_kernel();
43627
43628 for (i = irq_base; i < irq_end; i++) {
43629 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43630 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43631 index 277a8db..0e0b754 100644
43632 --- a/drivers/mfd/twl6030-irq.c
43633 +++ b/drivers/mfd/twl6030-irq.c
43634 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43635 * install an irq handler for each of the modules;
43636 * clone dummy irq_chip since PIH can't *do* anything
43637 */
43638 - twl6030_irq_chip = dummy_irq_chip;
43639 - twl6030_irq_chip.name = "twl6030";
43640 - twl6030_irq_chip.irq_set_type = NULL;
43641 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43642 + pax_open_kernel();
43643 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43644 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43645 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43646 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43647 + pax_close_kernel();
43648
43649 for (i = irq_base; i < irq_end; i++) {
43650 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43651 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43652 index f32550a..e3e52a2 100644
43653 --- a/drivers/misc/c2port/core.c
43654 +++ b/drivers/misc/c2port/core.c
43655 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43656 mutex_init(&c2dev->mutex);
43657
43658 /* Create binary file */
43659 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43660 + pax_open_kernel();
43661 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43662 + pax_close_kernel();
43663 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43664 if (unlikely(ret))
43665 goto error_device_create_bin_file;
43666 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43667 index 36f5d52..32311c3 100644
43668 --- a/drivers/misc/kgdbts.c
43669 +++ b/drivers/misc/kgdbts.c
43670 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43671 char before[BREAK_INSTR_SIZE];
43672 char after[BREAK_INSTR_SIZE];
43673
43674 - probe_kernel_read(before, (char *)kgdbts_break_test,
43675 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43676 BREAK_INSTR_SIZE);
43677 init_simple_test();
43678 ts.tst = plant_and_detach_test;
43679 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43680 /* Activate test with initial breakpoint */
43681 if (!is_early)
43682 kgdb_breakpoint();
43683 - probe_kernel_read(after, (char *)kgdbts_break_test,
43684 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43685 BREAK_INSTR_SIZE);
43686 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43687 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43688 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43689 index 036effe..b3a6336 100644
43690 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43691 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43692 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43693 * the lid is closed. This leads to interrupts as soon as a little move
43694 * is done.
43695 */
43696 - atomic_inc(&lis3->count);
43697 + atomic_inc_unchecked(&lis3->count);
43698
43699 wake_up_interruptible(&lis3->misc_wait);
43700 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43701 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43702 if (lis3->pm_dev)
43703 pm_runtime_get_sync(lis3->pm_dev);
43704
43705 - atomic_set(&lis3->count, 0);
43706 + atomic_set_unchecked(&lis3->count, 0);
43707 return 0;
43708 }
43709
43710 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43711 add_wait_queue(&lis3->misc_wait, &wait);
43712 while (true) {
43713 set_current_state(TASK_INTERRUPTIBLE);
43714 - data = atomic_xchg(&lis3->count, 0);
43715 + data = atomic_xchg_unchecked(&lis3->count, 0);
43716 if (data)
43717 break;
43718
43719 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43720 struct lis3lv02d, miscdev);
43721
43722 poll_wait(file, &lis3->misc_wait, wait);
43723 - if (atomic_read(&lis3->count))
43724 + if (atomic_read_unchecked(&lis3->count))
43725 return POLLIN | POLLRDNORM;
43726 return 0;
43727 }
43728 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43729 index c439c82..1f20f57 100644
43730 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43731 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43732 @@ -297,7 +297,7 @@ struct lis3lv02d {
43733 struct input_polled_dev *idev; /* input device */
43734 struct platform_device *pdev; /* platform device */
43735 struct regulator_bulk_data regulators[2];
43736 - atomic_t count; /* interrupt count after last read */
43737 + atomic_unchecked_t count; /* interrupt count after last read */
43738 union axis_conversion ac; /* hw -> logical axis */
43739 int mapped_btns[3];
43740
43741 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43742 index 2f30bad..c4c13d0 100644
43743 --- a/drivers/misc/sgi-gru/gruhandles.c
43744 +++ b/drivers/misc/sgi-gru/gruhandles.c
43745 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43746 unsigned long nsec;
43747
43748 nsec = CLKS2NSEC(clks);
43749 - atomic_long_inc(&mcs_op_statistics[op].count);
43750 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43751 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43752 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43753 if (mcs_op_statistics[op].max < nsec)
43754 mcs_op_statistics[op].max = nsec;
43755 }
43756 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43757 index 4f76359..cdfcb2e 100644
43758 --- a/drivers/misc/sgi-gru/gruprocfs.c
43759 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43760 @@ -32,9 +32,9 @@
43761
43762 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43763
43764 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43765 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43766 {
43767 - unsigned long val = atomic_long_read(v);
43768 + unsigned long val = atomic_long_read_unchecked(v);
43769
43770 seq_printf(s, "%16lu %s\n", val, id);
43771 }
43772 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43773
43774 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43775 for (op = 0; op < mcsop_last; op++) {
43776 - count = atomic_long_read(&mcs_op_statistics[op].count);
43777 - total = atomic_long_read(&mcs_op_statistics[op].total);
43778 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43779 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43780 max = mcs_op_statistics[op].max;
43781 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43782 count ? total / count : 0, max);
43783 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43784 index 5c3ce24..4915ccb 100644
43785 --- a/drivers/misc/sgi-gru/grutables.h
43786 +++ b/drivers/misc/sgi-gru/grutables.h
43787 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43788 * GRU statistics.
43789 */
43790 struct gru_stats_s {
43791 - atomic_long_t vdata_alloc;
43792 - atomic_long_t vdata_free;
43793 - atomic_long_t gts_alloc;
43794 - atomic_long_t gts_free;
43795 - atomic_long_t gms_alloc;
43796 - atomic_long_t gms_free;
43797 - atomic_long_t gts_double_allocate;
43798 - atomic_long_t assign_context;
43799 - atomic_long_t assign_context_failed;
43800 - atomic_long_t free_context;
43801 - atomic_long_t load_user_context;
43802 - atomic_long_t load_kernel_context;
43803 - atomic_long_t lock_kernel_context;
43804 - atomic_long_t unlock_kernel_context;
43805 - atomic_long_t steal_user_context;
43806 - atomic_long_t steal_kernel_context;
43807 - atomic_long_t steal_context_failed;
43808 - atomic_long_t nopfn;
43809 - atomic_long_t asid_new;
43810 - atomic_long_t asid_next;
43811 - atomic_long_t asid_wrap;
43812 - atomic_long_t asid_reuse;
43813 - atomic_long_t intr;
43814 - atomic_long_t intr_cbr;
43815 - atomic_long_t intr_tfh;
43816 - atomic_long_t intr_spurious;
43817 - atomic_long_t intr_mm_lock_failed;
43818 - atomic_long_t call_os;
43819 - atomic_long_t call_os_wait_queue;
43820 - atomic_long_t user_flush_tlb;
43821 - atomic_long_t user_unload_context;
43822 - atomic_long_t user_exception;
43823 - atomic_long_t set_context_option;
43824 - atomic_long_t check_context_retarget_intr;
43825 - atomic_long_t check_context_unload;
43826 - atomic_long_t tlb_dropin;
43827 - atomic_long_t tlb_preload_page;
43828 - atomic_long_t tlb_dropin_fail_no_asid;
43829 - atomic_long_t tlb_dropin_fail_upm;
43830 - atomic_long_t tlb_dropin_fail_invalid;
43831 - atomic_long_t tlb_dropin_fail_range_active;
43832 - atomic_long_t tlb_dropin_fail_idle;
43833 - atomic_long_t tlb_dropin_fail_fmm;
43834 - atomic_long_t tlb_dropin_fail_no_exception;
43835 - atomic_long_t tfh_stale_on_fault;
43836 - atomic_long_t mmu_invalidate_range;
43837 - atomic_long_t mmu_invalidate_page;
43838 - atomic_long_t flush_tlb;
43839 - atomic_long_t flush_tlb_gru;
43840 - atomic_long_t flush_tlb_gru_tgh;
43841 - atomic_long_t flush_tlb_gru_zero_asid;
43842 + atomic_long_unchecked_t vdata_alloc;
43843 + atomic_long_unchecked_t vdata_free;
43844 + atomic_long_unchecked_t gts_alloc;
43845 + atomic_long_unchecked_t gts_free;
43846 + atomic_long_unchecked_t gms_alloc;
43847 + atomic_long_unchecked_t gms_free;
43848 + atomic_long_unchecked_t gts_double_allocate;
43849 + atomic_long_unchecked_t assign_context;
43850 + atomic_long_unchecked_t assign_context_failed;
43851 + atomic_long_unchecked_t free_context;
43852 + atomic_long_unchecked_t load_user_context;
43853 + atomic_long_unchecked_t load_kernel_context;
43854 + atomic_long_unchecked_t lock_kernel_context;
43855 + atomic_long_unchecked_t unlock_kernel_context;
43856 + atomic_long_unchecked_t steal_user_context;
43857 + atomic_long_unchecked_t steal_kernel_context;
43858 + atomic_long_unchecked_t steal_context_failed;
43859 + atomic_long_unchecked_t nopfn;
43860 + atomic_long_unchecked_t asid_new;
43861 + atomic_long_unchecked_t asid_next;
43862 + atomic_long_unchecked_t asid_wrap;
43863 + atomic_long_unchecked_t asid_reuse;
43864 + atomic_long_unchecked_t intr;
43865 + atomic_long_unchecked_t intr_cbr;
43866 + atomic_long_unchecked_t intr_tfh;
43867 + atomic_long_unchecked_t intr_spurious;
43868 + atomic_long_unchecked_t intr_mm_lock_failed;
43869 + atomic_long_unchecked_t call_os;
43870 + atomic_long_unchecked_t call_os_wait_queue;
43871 + atomic_long_unchecked_t user_flush_tlb;
43872 + atomic_long_unchecked_t user_unload_context;
43873 + atomic_long_unchecked_t user_exception;
43874 + atomic_long_unchecked_t set_context_option;
43875 + atomic_long_unchecked_t check_context_retarget_intr;
43876 + atomic_long_unchecked_t check_context_unload;
43877 + atomic_long_unchecked_t tlb_dropin;
43878 + atomic_long_unchecked_t tlb_preload_page;
43879 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43880 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43881 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43882 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43883 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43884 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43885 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43886 + atomic_long_unchecked_t tfh_stale_on_fault;
43887 + atomic_long_unchecked_t mmu_invalidate_range;
43888 + atomic_long_unchecked_t mmu_invalidate_page;
43889 + atomic_long_unchecked_t flush_tlb;
43890 + atomic_long_unchecked_t flush_tlb_gru;
43891 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43892 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43893
43894 - atomic_long_t copy_gpa;
43895 - atomic_long_t read_gpa;
43896 + atomic_long_unchecked_t copy_gpa;
43897 + atomic_long_unchecked_t read_gpa;
43898
43899 - atomic_long_t mesq_receive;
43900 - atomic_long_t mesq_receive_none;
43901 - atomic_long_t mesq_send;
43902 - atomic_long_t mesq_send_failed;
43903 - atomic_long_t mesq_noop;
43904 - atomic_long_t mesq_send_unexpected_error;
43905 - atomic_long_t mesq_send_lb_overflow;
43906 - atomic_long_t mesq_send_qlimit_reached;
43907 - atomic_long_t mesq_send_amo_nacked;
43908 - atomic_long_t mesq_send_put_nacked;
43909 - atomic_long_t mesq_page_overflow;
43910 - atomic_long_t mesq_qf_locked;
43911 - atomic_long_t mesq_qf_noop_not_full;
43912 - atomic_long_t mesq_qf_switch_head_failed;
43913 - atomic_long_t mesq_qf_unexpected_error;
43914 - atomic_long_t mesq_noop_unexpected_error;
43915 - atomic_long_t mesq_noop_lb_overflow;
43916 - atomic_long_t mesq_noop_qlimit_reached;
43917 - atomic_long_t mesq_noop_amo_nacked;
43918 - atomic_long_t mesq_noop_put_nacked;
43919 - atomic_long_t mesq_noop_page_overflow;
43920 + atomic_long_unchecked_t mesq_receive;
43921 + atomic_long_unchecked_t mesq_receive_none;
43922 + atomic_long_unchecked_t mesq_send;
43923 + atomic_long_unchecked_t mesq_send_failed;
43924 + atomic_long_unchecked_t mesq_noop;
43925 + atomic_long_unchecked_t mesq_send_unexpected_error;
43926 + atomic_long_unchecked_t mesq_send_lb_overflow;
43927 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43928 + atomic_long_unchecked_t mesq_send_amo_nacked;
43929 + atomic_long_unchecked_t mesq_send_put_nacked;
43930 + atomic_long_unchecked_t mesq_page_overflow;
43931 + atomic_long_unchecked_t mesq_qf_locked;
43932 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43933 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43934 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43935 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43936 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43937 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43938 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43939 + atomic_long_unchecked_t mesq_noop_put_nacked;
43940 + atomic_long_unchecked_t mesq_noop_page_overflow;
43941
43942 };
43943
43944 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43945 tghop_invalidate, mcsop_last};
43946
43947 struct mcs_op_statistic {
43948 - atomic_long_t count;
43949 - atomic_long_t total;
43950 + atomic_long_unchecked_t count;
43951 + atomic_long_unchecked_t total;
43952 unsigned long max;
43953 };
43954
43955 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43956
43957 #define STAT(id) do { \
43958 if (gru_options & OPT_STATS) \
43959 - atomic_long_inc(&gru_stats.id); \
43960 + atomic_long_inc_unchecked(&gru_stats.id); \
43961 } while (0)
43962
43963 #ifdef CONFIG_SGI_GRU_DEBUG
43964 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43965 index c862cd4..0d176fe 100644
43966 --- a/drivers/misc/sgi-xp/xp.h
43967 +++ b/drivers/misc/sgi-xp/xp.h
43968 @@ -288,7 +288,7 @@ struct xpc_interface {
43969 xpc_notify_func, void *);
43970 void (*received) (short, int, void *);
43971 enum xp_retval (*partid_to_nasids) (short, void *);
43972 -};
43973 +} __no_const;
43974
43975 extern struct xpc_interface xpc_interface;
43976
43977 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43978 index b94d5f7..7f494c5 100644
43979 --- a/drivers/misc/sgi-xp/xpc.h
43980 +++ b/drivers/misc/sgi-xp/xpc.h
43981 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43982 void (*received_payload) (struct xpc_channel *, void *);
43983 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43984 };
43985 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43986
43987 /* struct xpc_partition act_state values (for XPC HB) */
43988
43989 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43990 /* found in xpc_main.c */
43991 extern struct device *xpc_part;
43992 extern struct device *xpc_chan;
43993 -extern struct xpc_arch_operations xpc_arch_ops;
43994 +extern xpc_arch_operations_no_const xpc_arch_ops;
43995 extern int xpc_disengage_timelimit;
43996 extern int xpc_disengage_timedout;
43997 extern int xpc_activate_IRQ_rcvd;
43998 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43999 index 82dc574..8539ab2 100644
44000 --- a/drivers/misc/sgi-xp/xpc_main.c
44001 +++ b/drivers/misc/sgi-xp/xpc_main.c
44002 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
44003 .notifier_call = xpc_system_die,
44004 };
44005
44006 -struct xpc_arch_operations xpc_arch_ops;
44007 +xpc_arch_operations_no_const xpc_arch_ops;
44008
44009 /*
44010 * Timer function to enforce the timelimit on the partition disengage.
44011 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
44012
44013 if (((die_args->trapnr == X86_TRAP_MF) ||
44014 (die_args->trapnr == X86_TRAP_XF)) &&
44015 - !user_mode_vm(die_args->regs))
44016 + !user_mode(die_args->regs))
44017 xpc_die_deactivate();
44018
44019 break;
44020 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
44021 index 837fc73..acb5862 100644
44022 --- a/drivers/mmc/core/mmc_ops.c
44023 +++ b/drivers/mmc/core/mmc_ops.c
44024 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
44025 void *data_buf;
44026 int is_on_stack;
44027
44028 - is_on_stack = object_is_on_stack(buf);
44029 + is_on_stack = object_starts_on_stack(buf);
44030 if (is_on_stack) {
44031 /*
44032 * dma onto stack is unsafe/nonportable, but callers to this
44033 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
44034 index 81b2994..dce857e 100644
44035 --- a/drivers/mmc/host/dw_mmc.h
44036 +++ b/drivers/mmc/host/dw_mmc.h
44037 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
44038 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
44039 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
44040 int (*parse_dt)(struct dw_mci *host);
44041 -};
44042 +} __do_const;
44043 #endif /* _DW_MMC_H_ */
44044 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
44045 index 926aaf6..8e153e2 100644
44046 --- a/drivers/mmc/host/sdhci-s3c.c
44047 +++ b/drivers/mmc/host/sdhci-s3c.c
44048 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
44049 * we can use overriding functions instead of default.
44050 */
44051 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
44052 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
44053 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
44054 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
44055 + pax_open_kernel();
44056 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
44057 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
44058 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
44059 + pax_close_kernel();
44060 }
44061
44062 /* It supports additional host capabilities if needed */
44063 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
44064 index 0c8bb6b..6f35deb 100644
44065 --- a/drivers/mtd/nand/denali.c
44066 +++ b/drivers/mtd/nand/denali.c
44067 @@ -24,6 +24,7 @@
44068 #include <linux/slab.h>
44069 #include <linux/mtd/mtd.h>
44070 #include <linux/module.h>
44071 +#include <linux/slab.h>
44072
44073 #include "denali.h"
44074
44075 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
44076 index 51b9d6a..52af9a7 100644
44077 --- a/drivers/mtd/nftlmount.c
44078 +++ b/drivers/mtd/nftlmount.c
44079 @@ -24,6 +24,7 @@
44080 #include <asm/errno.h>
44081 #include <linux/delay.h>
44082 #include <linux/slab.h>
44083 +#include <linux/sched.h>
44084 #include <linux/mtd/mtd.h>
44085 #include <linux/mtd/nand.h>
44086 #include <linux/mtd/nftl.h>
44087 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
44088 index f9d5615..99dd95f 100644
44089 --- a/drivers/mtd/sm_ftl.c
44090 +++ b/drivers/mtd/sm_ftl.c
44091 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
44092 #define SM_CIS_VENDOR_OFFSET 0x59
44093 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
44094 {
44095 - struct attribute_group *attr_group;
44096 + attribute_group_no_const *attr_group;
44097 struct attribute **attributes;
44098 struct sm_sysfs_attribute *vendor_attribute;
44099
44100 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
44101 index e48cb33..72e73fc 100644
44102 --- a/drivers/net/bonding/bond_main.c
44103 +++ b/drivers/net/bonding/bond_main.c
44104 @@ -4832,7 +4832,7 @@ static unsigned int bond_get_num_tx_queues(void)
44105 return tx_queues;
44106 }
44107
44108 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
44109 +static struct rtnl_link_ops bond_link_ops = {
44110 .kind = "bond",
44111 .priv_size = sizeof(struct bonding),
44112 .setup = bond_setup,
44113 @@ -4957,8 +4957,8 @@ static void __exit bonding_exit(void)
44114
44115 bond_destroy_debugfs();
44116
44117 - rtnl_link_unregister(&bond_link_ops);
44118 unregister_pernet_subsys(&bond_net_ops);
44119 + rtnl_link_unregister(&bond_link_ops);
44120
44121 #ifdef CONFIG_NET_POLL_CONTROLLER
44122 /*
44123 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
44124 index e1d2643..7f4133b 100644
44125 --- a/drivers/net/ethernet/8390/ax88796.c
44126 +++ b/drivers/net/ethernet/8390/ax88796.c
44127 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
44128 if (ax->plat->reg_offsets)
44129 ei_local->reg_offset = ax->plat->reg_offsets;
44130 else {
44131 + resource_size_t _mem_size = mem_size;
44132 + do_div(_mem_size, 0x18);
44133 ei_local->reg_offset = ax->reg_offsets;
44134 for (ret = 0; ret < 0x18; ret++)
44135 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
44136 + ax->reg_offsets[ret] = _mem_size * ret;
44137 }
44138
44139 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
44140 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44141 index c07a6d0..ca88c45 100644
44142 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44143 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44144 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
44145 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
44146 {
44147 /* RX_MODE controlling object */
44148 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
44149 + bnx2x_init_rx_mode_obj(bp);
44150
44151 /* multicast configuration controlling object */
44152 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
44153 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44154 index 8f03c98..dd0ef10 100644
44155 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44156 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44157 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
44158 return rc;
44159 }
44160
44161 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44162 - struct bnx2x_rx_mode_obj *o)
44163 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
44164 {
44165 if (CHIP_IS_E1x(bp)) {
44166 - o->wait_comp = bnx2x_empty_rx_mode_wait;
44167 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
44168 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
44169 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
44170 } else {
44171 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
44172 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
44173 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
44174 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
44175 }
44176 }
44177
44178 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44179 index 798dfe9..05d0a44 100644
44180 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44181 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44182 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
44183
44184 /********************* RX MODE ****************/
44185
44186 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44187 - struct bnx2x_rx_mode_obj *o);
44188 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
44189
44190 /**
44191 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
44192 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
44193 index cd63d11..b67dd78 100644
44194 --- a/drivers/net/ethernet/broadcom/tg3.h
44195 +++ b/drivers/net/ethernet/broadcom/tg3.h
44196 @@ -147,6 +147,7 @@
44197 #define CHIPREV_ID_5750_A0 0x4000
44198 #define CHIPREV_ID_5750_A1 0x4001
44199 #define CHIPREV_ID_5750_A3 0x4003
44200 +#define CHIPREV_ID_5750_C1 0x4201
44201 #define CHIPREV_ID_5750_C2 0x4202
44202 #define CHIPREV_ID_5752_A0_HW 0x5000
44203 #define CHIPREV_ID_5752_A0 0x6000
44204 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44205 index 8cffcdf..aadf043 100644
44206 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44207 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44208 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44209 */
44210 struct l2t_skb_cb {
44211 arp_failure_handler_func arp_failure_handler;
44212 -};
44213 +} __no_const;
44214
44215 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44216
44217 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44218 index 4c83003..2a2a5b9 100644
44219 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44220 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44221 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44222 for (i=0; i<ETH_ALEN; i++) {
44223 tmp.addr[i] = dev->dev_addr[i];
44224 }
44225 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44226 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44227 break;
44228
44229 case DE4X5_SET_HWADDR: /* Set the hardware address */
44230 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44231 spin_lock_irqsave(&lp->lock, flags);
44232 memcpy(&statbuf, &lp->pktStats, ioc->len);
44233 spin_unlock_irqrestore(&lp->lock, flags);
44234 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44235 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44236 return -EFAULT;
44237 break;
44238 }
44239 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44240 index 3d91a5e..1014702 100644
44241 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44242 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44243 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44244
44245 if (wrapped)
44246 newacc += 65536;
44247 - ACCESS_ONCE(*acc) = newacc;
44248 + ACCESS_ONCE_RW(*acc) = newacc;
44249 }
44250
44251 void populate_erx_stats(struct be_adapter *adapter,
44252 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44253 index 934e1ae..b262e6b 100644
44254 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44255 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44256 @@ -31,6 +31,8 @@
44257 #include <linux/netdevice.h>
44258 #include <linux/phy.h>
44259 #include <linux/platform_device.h>
44260 +#include <linux/interrupt.h>
44261 +#include <linux/irqreturn.h>
44262 #include <net/ip.h>
44263
44264 #include "ftgmac100.h"
44265 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44266 index 4658f4c..407d155 100644
44267 --- a/drivers/net/ethernet/faraday/ftmac100.c
44268 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44269 @@ -31,6 +31,8 @@
44270 #include <linux/module.h>
44271 #include <linux/netdevice.h>
44272 #include <linux/platform_device.h>
44273 +#include <linux/interrupt.h>
44274 +#include <linux/irqreturn.h>
44275
44276 #include "ftmac100.h"
44277
44278 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44279 index 331987d..3be1135 100644
44280 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44281 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44282 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44283 }
44284
44285 /* update the base incval used to calculate frequency adjustment */
44286 - ACCESS_ONCE(adapter->base_incval) = incval;
44287 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44288 smp_mb();
44289
44290 /* need lock to prevent incorrect read while modifying cyclecounter */
44291 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44292 index fbe5363..266b4e3 100644
44293 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44294 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44295 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44296 struct __vxge_hw_fifo *fifo;
44297 struct vxge_hw_fifo_config *config;
44298 u32 txdl_size, txdl_per_memblock;
44299 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44300 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44301 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44302 + };
44303 +
44304 struct __vxge_hw_virtualpath *vpath;
44305
44306 if ((vp == NULL) || (attr == NULL)) {
44307 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44308 goto exit;
44309 }
44310
44311 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44312 -
44313 fifo->mempool =
44314 __vxge_hw_mempool_create(vpath->hldev,
44315 fifo->config->memblock_size,
44316 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44317 index 345d987..af69721 100644
44318 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44319 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44320 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44321 op_mode = QLC_83XX_DEFAULT_OPMODE;
44322
44323 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44324 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44325 + pax_open_kernel();
44326 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44327 + pax_close_kernel();
44328 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44329 } else {
44330 return -EIO;
44331 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44332 index 599d1fd..59868fe 100644
44333 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44334 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44335 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44336 case QLCNIC_NON_PRIV_FUNC:
44337 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44338 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44339 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44340 + pax_open_kernel();
44341 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44342 + pax_close_kernel();
44343 break;
44344 case QLCNIC_PRIV_FUNC:
44345 ahw->op_mode = QLCNIC_PRIV_FUNC;
44346 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44347 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44348 + pax_open_kernel();
44349 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44350 + pax_close_kernel();
44351 break;
44352 case QLCNIC_MGMT_FUNC:
44353 ahw->op_mode = QLCNIC_MGMT_FUNC;
44354 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44355 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44356 + pax_open_kernel();
44357 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44358 + pax_close_kernel();
44359 break;
44360 default:
44361 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44362 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44363 index 85e5c97..76f97ec 100644
44364 --- a/drivers/net/ethernet/realtek/r8169.c
44365 +++ b/drivers/net/ethernet/realtek/r8169.c
44366 @@ -759,22 +759,22 @@ struct rtl8169_private {
44367 struct mdio_ops {
44368 void (*write)(struct rtl8169_private *, int, int);
44369 int (*read)(struct rtl8169_private *, int);
44370 - } mdio_ops;
44371 + } __no_const mdio_ops;
44372
44373 struct pll_power_ops {
44374 void (*down)(struct rtl8169_private *);
44375 void (*up)(struct rtl8169_private *);
44376 - } pll_power_ops;
44377 + } __no_const pll_power_ops;
44378
44379 struct jumbo_ops {
44380 void (*enable)(struct rtl8169_private *);
44381 void (*disable)(struct rtl8169_private *);
44382 - } jumbo_ops;
44383 + } __no_const jumbo_ops;
44384
44385 struct csi_ops {
44386 void (*write)(struct rtl8169_private *, int, int);
44387 u32 (*read)(struct rtl8169_private *, int);
44388 - } csi_ops;
44389 + } __no_const csi_ops;
44390
44391 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44392 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44393 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44394 index b495394..0748c54 100644
44395 --- a/drivers/net/ethernet/sfc/ptp.c
44396 +++ b/drivers/net/ethernet/sfc/ptp.c
44397 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44398 (u32)((u64)ptp->start.dma_addr >> 32));
44399
44400 /* Clear flag that signals MC ready */
44401 - ACCESS_ONCE(*start) = 0;
44402 + ACCESS_ONCE_RW(*start) = 0;
44403 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44404 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44405
44406 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44407 index 50617c5..b13724c 100644
44408 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44409 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44410 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44411
44412 writel(value, ioaddr + MMC_CNTRL);
44413
44414 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44415 - MMC_CNTRL, value);
44416 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44417 +// MMC_CNTRL, value);
44418 }
44419
44420 /* To mask all all interrupts.*/
44421 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44422 index e6fe0d8..2b7d752 100644
44423 --- a/drivers/net/hyperv/hyperv_net.h
44424 +++ b/drivers/net/hyperv/hyperv_net.h
44425 @@ -101,7 +101,7 @@ struct rndis_device {
44426
44427 enum rndis_device_state state;
44428 bool link_state;
44429 - atomic_t new_req_id;
44430 + atomic_unchecked_t new_req_id;
44431
44432 spinlock_t request_lock;
44433 struct list_head req_list;
44434 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44435 index 0775f0a..d4fb316 100644
44436 --- a/drivers/net/hyperv/rndis_filter.c
44437 +++ b/drivers/net/hyperv/rndis_filter.c
44438 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44439 * template
44440 */
44441 set = &rndis_msg->msg.set_req;
44442 - set->req_id = atomic_inc_return(&dev->new_req_id);
44443 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44444
44445 /* Add to the request list */
44446 spin_lock_irqsave(&dev->request_lock, flags);
44447 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44448
44449 /* Setup the rndis set */
44450 halt = &request->request_msg.msg.halt_req;
44451 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44452 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44453
44454 /* Ignore return since this msg is optional. */
44455 rndis_filter_send_request(dev, request);
44456 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44457 index bf0d55e..82bcfbd1 100644
44458 --- a/drivers/net/ieee802154/fakehard.c
44459 +++ b/drivers/net/ieee802154/fakehard.c
44460 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44461 phy->transmit_power = 0xbf;
44462
44463 dev->netdev_ops = &fake_ops;
44464 - dev->ml_priv = &fake_mlme;
44465 + dev->ml_priv = (void *)&fake_mlme;
44466
44467 priv = netdev_priv(dev);
44468 priv->phy = phy;
44469 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44470 index 16b43bf..ead0c35 100644
44471 --- a/drivers/net/macvlan.c
44472 +++ b/drivers/net/macvlan.c
44473 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44474 int macvlan_link_register(struct rtnl_link_ops *ops)
44475 {
44476 /* common fields */
44477 - ops->priv_size = sizeof(struct macvlan_dev);
44478 - ops->validate = macvlan_validate;
44479 - ops->maxtype = IFLA_MACVLAN_MAX;
44480 - ops->policy = macvlan_policy;
44481 - ops->changelink = macvlan_changelink;
44482 - ops->get_size = macvlan_get_size;
44483 - ops->fill_info = macvlan_fill_info;
44484 + pax_open_kernel();
44485 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44486 + *(void **)&ops->validate = macvlan_validate;
44487 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44488 + *(const void **)&ops->policy = macvlan_policy;
44489 + *(void **)&ops->changelink = macvlan_changelink;
44490 + *(void **)&ops->get_size = macvlan_get_size;
44491 + *(void **)&ops->fill_info = macvlan_fill_info;
44492 + pax_close_kernel();
44493
44494 return rtnl_link_register(ops);
44495 };
44496 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44497 return NOTIFY_DONE;
44498 }
44499
44500 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44501 +static struct notifier_block macvlan_notifier_block = {
44502 .notifier_call = macvlan_device_event,
44503 };
44504
44505 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44506 index ea53abb..2e4d087 100644
44507 --- a/drivers/net/macvtap.c
44508 +++ b/drivers/net/macvtap.c
44509 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44510 return NOTIFY_DONE;
44511 }
44512
44513 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44514 +static struct notifier_block macvtap_notifier_block = {
44515 .notifier_call = macvtap_device_event,
44516 };
44517
44518 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44519 index daec9b0..6428fcb 100644
44520 --- a/drivers/net/phy/mdio-bitbang.c
44521 +++ b/drivers/net/phy/mdio-bitbang.c
44522 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44523 struct mdiobb_ctrl *ctrl = bus->priv;
44524
44525 module_put(ctrl->ops->owner);
44526 + mdiobus_unregister(bus);
44527 mdiobus_free(bus);
44528 }
44529 EXPORT_SYMBOL(free_mdio_bitbang);
44530 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44531 index 72ff14b..11d442d 100644
44532 --- a/drivers/net/ppp/ppp_generic.c
44533 +++ b/drivers/net/ppp/ppp_generic.c
44534 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44535 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44536 struct ppp_stats stats;
44537 struct ppp_comp_stats cstats;
44538 - char *vers;
44539
44540 switch (cmd) {
44541 case SIOCGPPPSTATS:
44542 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44543 break;
44544
44545 case SIOCGPPPVER:
44546 - vers = PPP_VERSION;
44547 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44548 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44549 break;
44550 err = 0;
44551 break;
44552 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44553 index 1252d9c..80e660b 100644
44554 --- a/drivers/net/slip/slhc.c
44555 +++ b/drivers/net/slip/slhc.c
44556 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44557 register struct tcphdr *thp;
44558 register struct iphdr *ip;
44559 register struct cstate *cs;
44560 - int len, hdrlen;
44561 + long len, hdrlen;
44562 unsigned char *cp = icp;
44563
44564 /* We've got a compressed packet; read the change byte */
44565 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44566 index bff7e0b..7315137 100644
44567 --- a/drivers/net/team/team.c
44568 +++ b/drivers/net/team/team.c
44569 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44570 return NOTIFY_DONE;
44571 }
44572
44573 -static struct notifier_block team_notifier_block __read_mostly = {
44574 +static struct notifier_block team_notifier_block = {
44575 .notifier_call = team_device_event,
44576 };
44577
44578 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44579 index 71af122..b3c20f3 100644
44580 --- a/drivers/net/tun.c
44581 +++ b/drivers/net/tun.c
44582 @@ -1691,11 +1691,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
44583 INIT_LIST_HEAD(&tun->disabled);
44584 err = tun_attach(tun, file);
44585 if (err < 0)
44586 - goto err_free_dev;
44587 + goto err_free_flow;
44588
44589 err = register_netdevice(tun->dev);
44590 if (err < 0)
44591 - goto err_free_dev;
44592 + goto err_detach;
44593
44594 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
44595 device_create_file(&tun->dev->dev, &dev_attr_owner) ||
44596 @@ -1739,7 +1739,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
44597 strcpy(ifr->ifr_name, tun->dev->name);
44598 return 0;
44599
44600 - err_free_dev:
44601 +err_detach:
44602 + tun_detach_all(dev);
44603 +err_free_flow:
44604 + tun_flow_uninit(tun);
44605 + security_tun_dev_free_security(tun->security);
44606 +err_free_dev:
44607 free_netdev(dev);
44608 return err;
44609 }
44610 @@ -1869,7 +1874,7 @@ unlock:
44611 }
44612
44613 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44614 - unsigned long arg, int ifreq_len)
44615 + unsigned long arg, size_t ifreq_len)
44616 {
44617 struct tun_file *tfile = file->private_data;
44618 struct tun_struct *tun;
44619 @@ -1881,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44620 int vnet_hdr_sz;
44621 int ret;
44622
44623 + if (ifreq_len > sizeof ifr)
44624 + return -EFAULT;
44625 +
44626 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44627 if (copy_from_user(&ifr, argp, ifreq_len))
44628 return -EFAULT;
44629 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44630 index 86292e6..8d34433 100644
44631 --- a/drivers/net/usb/hso.c
44632 +++ b/drivers/net/usb/hso.c
44633 @@ -71,7 +71,7 @@
44634 #include <asm/byteorder.h>
44635 #include <linux/serial_core.h>
44636 #include <linux/serial.h>
44637 -
44638 +#include <asm/local.h>
44639
44640 #define MOD_AUTHOR "Option Wireless"
44641 #define MOD_DESCRIPTION "USB High Speed Option driver"
44642 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44643 struct urb *urb;
44644
44645 urb = serial->rx_urb[0];
44646 - if (serial->port.count > 0) {
44647 + if (atomic_read(&serial->port.count) > 0) {
44648 count = put_rxbuf_data(urb, serial);
44649 if (count == -1)
44650 return;
44651 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44652 DUMP1(urb->transfer_buffer, urb->actual_length);
44653
44654 /* Anyone listening? */
44655 - if (serial->port.count == 0)
44656 + if (atomic_read(&serial->port.count) == 0)
44657 return;
44658
44659 if (status == 0) {
44660 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44661 tty_port_tty_set(&serial->port, tty);
44662
44663 /* check for port already opened, if not set the termios */
44664 - serial->port.count++;
44665 - if (serial->port.count == 1) {
44666 + if (atomic_inc_return(&serial->port.count) == 1) {
44667 serial->rx_state = RX_IDLE;
44668 /* Force default termio settings */
44669 _hso_serial_set_termios(tty, NULL);
44670 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44671 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44672 if (result) {
44673 hso_stop_serial_device(serial->parent);
44674 - serial->port.count--;
44675 + atomic_dec(&serial->port.count);
44676 kref_put(&serial->parent->ref, hso_serial_ref_free);
44677 }
44678 } else {
44679 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44680
44681 /* reset the rts and dtr */
44682 /* do the actual close */
44683 - serial->port.count--;
44684 + atomic_dec(&serial->port.count);
44685
44686 - if (serial->port.count <= 0) {
44687 - serial->port.count = 0;
44688 + if (atomic_read(&serial->port.count) <= 0) {
44689 + atomic_set(&serial->port.count, 0);
44690 tty_port_tty_set(&serial->port, NULL);
44691 if (!usb_gone)
44692 hso_stop_serial_device(serial->parent);
44693 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44694
44695 /* the actual setup */
44696 spin_lock_irqsave(&serial->serial_lock, flags);
44697 - if (serial->port.count)
44698 + if (atomic_read(&serial->port.count))
44699 _hso_serial_set_termios(tty, old);
44700 else
44701 tty->termios = *old;
44702 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44703 D1("Pending read interrupt on port %d\n", i);
44704 spin_lock(&serial->serial_lock);
44705 if (serial->rx_state == RX_IDLE &&
44706 - serial->port.count > 0) {
44707 + atomic_read(&serial->port.count) > 0) {
44708 /* Setup and send a ctrl req read on
44709 * port i */
44710 if (!serial->rx_urb_filled[0]) {
44711 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44712 /* Start all serial ports */
44713 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44714 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44715 - if (dev2ser(serial_table[i])->port.count) {
44716 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44717 result =
44718 hso_start_serial_device(serial_table[i], GFP_NOIO);
44719 hso_kick_transmit(dev2ser(serial_table[i]));
44720 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44721 index a79e9d3..78cd4fa 100644
44722 --- a/drivers/net/usb/sierra_net.c
44723 +++ b/drivers/net/usb/sierra_net.c
44724 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44725 /* atomic counter partially included in MAC address to make sure 2 devices
44726 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44727 */
44728 -static atomic_t iface_counter = ATOMIC_INIT(0);
44729 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44730
44731 /*
44732 * SYNC Timer Delay definition used to set the expiry time
44733 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44734 dev->net->netdev_ops = &sierra_net_device_ops;
44735
44736 /* change MAC addr to include, ifacenum, and to be unique */
44737 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44738 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44739 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44740
44741 /* we will have to manufacture ethernet headers, prepare template */
44742 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44743 index 767f7af..8162b9d 100644
44744 --- a/drivers/net/vxlan.c
44745 +++ b/drivers/net/vxlan.c
44746 @@ -1868,7 +1868,7 @@ nla_put_failure:
44747 return -EMSGSIZE;
44748 }
44749
44750 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44751 +static struct rtnl_link_ops vxlan_link_ops = {
44752 .kind = "vxlan",
44753 .maxtype = IFLA_VXLAN_MAX,
44754 .policy = vxlan_policy,
44755 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44756 index 0b60295..b8bfa5b 100644
44757 --- a/drivers/net/wimax/i2400m/rx.c
44758 +++ b/drivers/net/wimax/i2400m/rx.c
44759 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44760 if (i2400m->rx_roq == NULL)
44761 goto error_roq_alloc;
44762
44763 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44764 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44765 GFP_KERNEL);
44766 if (rd == NULL) {
44767 result = -ENOMEM;
44768 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44769 index 34c8a33..3261fdc 100644
44770 --- a/drivers/net/wireless/at76c50x-usb.c
44771 +++ b/drivers/net/wireless/at76c50x-usb.c
44772 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44773 }
44774
44775 /* Convert timeout from the DFU status to jiffies */
44776 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44777 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44778 {
44779 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44780 | (s->poll_timeout[1] << 8)
44781 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44782 index 2b3426b..1f564be 100644
44783 --- a/drivers/net/wireless/ath/ath10k/core.c
44784 +++ b/drivers/net/wireless/ath/ath10k/core.c
44785 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44786
44787 int ath10k_core_register(struct ath10k *ar)
44788 {
44789 - struct ath10k_htc_ops htc_ops;
44790 + static struct ath10k_htc_ops htc_ops = {
44791 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44792 + };
44793 struct bmi_target_info target_info;
44794 int status;
44795
44796 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44797 if (status)
44798 goto err;
44799
44800 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44801 -
44802 ar->htc = ath10k_htc_create(ar, &htc_ops);
44803 if (IS_ERR(ar->htc)) {
44804 status = PTR_ERR(ar->htc);
44805 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44806 index 74363c9..237b926 100644
44807 --- a/drivers/net/wireless/ath/ath10k/htc.c
44808 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44809 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44810 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44811 struct ath10k_htc_ops *htc_ops)
44812 {
44813 - struct ath10k_hif_cb htc_callbacks;
44814 + static struct ath10k_hif_cb htc_callbacks = {
44815 + .rx_completion = ath10k_htc_rx_completion_handler,
44816 + .tx_completion = ath10k_htc_tx_completion_handler,
44817 + };
44818 struct ath10k_htc_ep *ep = NULL;
44819 struct ath10k_htc *htc = NULL;
44820
44821 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44822 ath10k_htc_reset_endpoint_states(htc);
44823
44824 /* setup HIF layer callbacks */
44825 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44826 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44827 htc->ar = ar;
44828
44829 /* Get HIF default pipe for HTC message exchange */
44830 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44831 index 8d78253..bebbb68 100644
44832 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44833 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44834 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44835 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44836 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44837
44838 - ACCESS_ONCE(ads->ds_link) = i->link;
44839 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44840 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44841 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44842
44843 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44844 ctl6 = SM(i->keytype, AR_EncrType);
44845 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44846
44847 if ((i->is_first || i->is_last) &&
44848 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44849 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44850 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44851 | set11nTries(i->rates, 1)
44852 | set11nTries(i->rates, 2)
44853 | set11nTries(i->rates, 3)
44854 | (i->dur_update ? AR_DurUpdateEna : 0)
44855 | SM(0, AR_BurstDur);
44856
44857 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44858 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44859 | set11nRate(i->rates, 1)
44860 | set11nRate(i->rates, 2)
44861 | set11nRate(i->rates, 3);
44862 } else {
44863 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44864 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44865 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44866 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44867 }
44868
44869 if (!i->is_first) {
44870 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44871 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44872 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44873 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44874 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44875 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44876 return;
44877 }
44878
44879 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44880 break;
44881 }
44882
44883 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44884 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44885 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44886 | SM(i->txpower, AR_XmitPower)
44887 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44888 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44889 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44890 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44891
44892 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44893 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44894 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44895 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44896
44897 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44898 return;
44899
44900 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44901 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44902 | set11nPktDurRTSCTS(i->rates, 1);
44903
44904 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44905 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44906 | set11nPktDurRTSCTS(i->rates, 3);
44907
44908 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44909 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44910 | set11nRateFlags(i->rates, 1)
44911 | set11nRateFlags(i->rates, 2)
44912 | set11nRateFlags(i->rates, 3)
44913 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44914 index 5163abd..3ada4c2 100644
44915 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44916 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44917 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44918 (i->qcu << AR_TxQcuNum_S) | desc_len;
44919
44920 checksum += val;
44921 - ACCESS_ONCE(ads->info) = val;
44922 + ACCESS_ONCE_RW(ads->info) = val;
44923
44924 checksum += i->link;
44925 - ACCESS_ONCE(ads->link) = i->link;
44926 + ACCESS_ONCE_RW(ads->link) = i->link;
44927
44928 checksum += i->buf_addr[0];
44929 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44930 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44931 checksum += i->buf_addr[1];
44932 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44933 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44934 checksum += i->buf_addr[2];
44935 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44936 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44937 checksum += i->buf_addr[3];
44938 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44939 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44940
44941 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44942 - ACCESS_ONCE(ads->ctl3) = val;
44943 + ACCESS_ONCE_RW(ads->ctl3) = val;
44944 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44945 - ACCESS_ONCE(ads->ctl5) = val;
44946 + ACCESS_ONCE_RW(ads->ctl5) = val;
44947 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44948 - ACCESS_ONCE(ads->ctl7) = val;
44949 + ACCESS_ONCE_RW(ads->ctl7) = val;
44950 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44951 - ACCESS_ONCE(ads->ctl9) = val;
44952 + ACCESS_ONCE_RW(ads->ctl9) = val;
44953
44954 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44955 - ACCESS_ONCE(ads->ctl10) = checksum;
44956 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44957
44958 if (i->is_first || i->is_last) {
44959 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44960 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44961 | set11nTries(i->rates, 1)
44962 | set11nTries(i->rates, 2)
44963 | set11nTries(i->rates, 3)
44964 | (i->dur_update ? AR_DurUpdateEna : 0)
44965 | SM(0, AR_BurstDur);
44966
44967 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44968 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44969 | set11nRate(i->rates, 1)
44970 | set11nRate(i->rates, 2)
44971 | set11nRate(i->rates, 3);
44972 } else {
44973 - ACCESS_ONCE(ads->ctl13) = 0;
44974 - ACCESS_ONCE(ads->ctl14) = 0;
44975 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44976 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44977 }
44978
44979 ads->ctl20 = 0;
44980 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44981
44982 ctl17 = SM(i->keytype, AR_EncrType);
44983 if (!i->is_first) {
44984 - ACCESS_ONCE(ads->ctl11) = 0;
44985 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44986 - ACCESS_ONCE(ads->ctl15) = 0;
44987 - ACCESS_ONCE(ads->ctl16) = 0;
44988 - ACCESS_ONCE(ads->ctl17) = ctl17;
44989 - ACCESS_ONCE(ads->ctl18) = 0;
44990 - ACCESS_ONCE(ads->ctl19) = 0;
44991 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44992 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44993 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44994 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44995 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44996 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44997 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44998 return;
44999 }
45000
45001 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
45002 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
45003 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
45004 | SM(i->txpower, AR_XmitPower)
45005 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
45006 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45007 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
45008 ctl12 |= SM(val, AR_PAPRDChainMask);
45009
45010 - ACCESS_ONCE(ads->ctl12) = ctl12;
45011 - ACCESS_ONCE(ads->ctl17) = ctl17;
45012 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
45013 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
45014
45015 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
45016 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
45017 | set11nPktDurRTSCTS(i->rates, 1);
45018
45019 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
45020 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
45021 | set11nPktDurRTSCTS(i->rates, 3);
45022
45023 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
45024 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
45025 | set11nRateFlags(i->rates, 1)
45026 | set11nRateFlags(i->rates, 2)
45027 | set11nRateFlags(i->rates, 3)
45028 | SM(i->rtscts_rate, AR_RTSCTSRate);
45029
45030 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
45031 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
45032 }
45033
45034 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
45035 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
45036 index cd74b3a..6a28d24 100644
45037 --- a/drivers/net/wireless/ath/ath9k/hw.h
45038 +++ b/drivers/net/wireless/ath/ath9k/hw.h
45039 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
45040
45041 /* ANI */
45042 void (*ani_cache_ini_regs)(struct ath_hw *ah);
45043 -};
45044 +} __no_const;
45045
45046 /**
45047 * struct ath_spec_scan - parameters for Atheros spectral scan
45048 @@ -721,7 +721,7 @@ struct ath_hw_ops {
45049 struct ath_spec_scan *param);
45050 void (*spectral_scan_trigger)(struct ath_hw *ah);
45051 void (*spectral_scan_wait)(struct ath_hw *ah);
45052 -};
45053 +} __no_const;
45054
45055 struct ath_nf_limits {
45056 s16 max;
45057 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
45058 index 9581d07..84f6a76 100644
45059 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
45060 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
45061 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
45062 */
45063 if (il3945_mod_params.disable_hw_scan) {
45064 D_INFO("Disabling hw_scan\n");
45065 - il3945_mac_ops.hw_scan = NULL;
45066 + pax_open_kernel();
45067 + *(void **)&il3945_mac_ops.hw_scan = NULL;
45068 + pax_close_kernel();
45069 }
45070
45071 D_INFO("*** LOAD DRIVER ***\n");
45072 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45073 index d532948..e0d8bb1 100644
45074 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45075 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45076 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
45077 {
45078 struct iwl_priv *priv = file->private_data;
45079 char buf[64];
45080 - int buf_size;
45081 + size_t buf_size;
45082 u32 offset, len;
45083
45084 memset(buf, 0, sizeof(buf));
45085 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
45086 struct iwl_priv *priv = file->private_data;
45087
45088 char buf[8];
45089 - int buf_size;
45090 + size_t buf_size;
45091 u32 reset_flag;
45092
45093 memset(buf, 0, sizeof(buf));
45094 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
45095 {
45096 struct iwl_priv *priv = file->private_data;
45097 char buf[8];
45098 - int buf_size;
45099 + size_t buf_size;
45100 int ht40;
45101
45102 memset(buf, 0, sizeof(buf));
45103 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
45104 {
45105 struct iwl_priv *priv = file->private_data;
45106 char buf[8];
45107 - int buf_size;
45108 + size_t buf_size;
45109 int value;
45110
45111 memset(buf, 0, sizeof(buf));
45112 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
45113 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
45114 DEBUGFS_READ_FILE_OPS(current_sleep_command);
45115
45116 -static const char *fmt_value = " %-30s %10u\n";
45117 -static const char *fmt_hex = " %-30s 0x%02X\n";
45118 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
45119 -static const char *fmt_header =
45120 +static const char fmt_value[] = " %-30s %10u\n";
45121 +static const char fmt_hex[] = " %-30s 0x%02X\n";
45122 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
45123 +static const char fmt_header[] =
45124 "%-32s current cumulative delta max\n";
45125
45126 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
45127 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
45128 {
45129 struct iwl_priv *priv = file->private_data;
45130 char buf[8];
45131 - int buf_size;
45132 + size_t buf_size;
45133 int clear;
45134
45135 memset(buf, 0, sizeof(buf));
45136 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
45137 {
45138 struct iwl_priv *priv = file->private_data;
45139 char buf[8];
45140 - int buf_size;
45141 + size_t buf_size;
45142 int trace;
45143
45144 memset(buf, 0, sizeof(buf));
45145 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
45146 {
45147 struct iwl_priv *priv = file->private_data;
45148 char buf[8];
45149 - int buf_size;
45150 + size_t buf_size;
45151 int missed;
45152
45153 memset(buf, 0, sizeof(buf));
45154 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
45155
45156 struct iwl_priv *priv = file->private_data;
45157 char buf[8];
45158 - int buf_size;
45159 + size_t buf_size;
45160 int plcp;
45161
45162 memset(buf, 0, sizeof(buf));
45163 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
45164
45165 struct iwl_priv *priv = file->private_data;
45166 char buf[8];
45167 - int buf_size;
45168 + size_t buf_size;
45169 int flush;
45170
45171 memset(buf, 0, sizeof(buf));
45172 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
45173
45174 struct iwl_priv *priv = file->private_data;
45175 char buf[8];
45176 - int buf_size;
45177 + size_t buf_size;
45178 int rts;
45179
45180 if (!priv->cfg->ht_params)
45181 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
45182 {
45183 struct iwl_priv *priv = file->private_data;
45184 char buf[8];
45185 - int buf_size;
45186 + size_t buf_size;
45187
45188 memset(buf, 0, sizeof(buf));
45189 buf_size = min(count, sizeof(buf) - 1);
45190 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
45191 struct iwl_priv *priv = file->private_data;
45192 u32 event_log_flag;
45193 char buf[8];
45194 - int buf_size;
45195 + size_t buf_size;
45196
45197 /* check that the interface is up */
45198 if (!iwl_is_ready(priv))
45199 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
45200 struct iwl_priv *priv = file->private_data;
45201 char buf[8];
45202 u32 calib_disabled;
45203 - int buf_size;
45204 + size_t buf_size;
45205
45206 memset(buf, 0, sizeof(buf));
45207 buf_size = min(count, sizeof(buf) - 1);
45208 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
45209 index 1531a4f..21d2641 100644
45210 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
45211 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45212 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45213 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45214 {
45215 struct iwl_nvm_data *data = priv->nvm_data;
45216 - char *debug_msg;
45217 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45218
45219 if (data->sku_cap_11n_enable &&
45220 !priv->cfg->ht_params) {
45221 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45222 return -EINVAL;
45223 }
45224
45225 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45226 IWL_DEBUG_INFO(priv, debug_msg,
45227 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45228 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45229 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45230 index 390e2f0..75cfbaf 100644
45231 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45232 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45233 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45234 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45235
45236 char buf[8];
45237 - int buf_size;
45238 + size_t buf_size;
45239 u32 reset_flag;
45240
45241 memset(buf, 0, sizeof(buf));
45242 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45243 {
45244 struct iwl_trans *trans = file->private_data;
45245 char buf[8];
45246 - int buf_size;
45247 + size_t buf_size;
45248 int csr;
45249
45250 memset(buf, 0, sizeof(buf));
45251 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45252 index cb34c78..9fec0dc 100644
45253 --- a/drivers/net/wireless/mac80211_hwsim.c
45254 +++ b/drivers/net/wireless/mac80211_hwsim.c
45255 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
45256
45257 if (channels > 1) {
45258 hwsim_if_comb.num_different_channels = channels;
45259 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45260 - mac80211_hwsim_ops.cancel_hw_scan =
45261 - mac80211_hwsim_cancel_hw_scan;
45262 - mac80211_hwsim_ops.sw_scan_start = NULL;
45263 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45264 - mac80211_hwsim_ops.remain_on_channel =
45265 - mac80211_hwsim_roc;
45266 - mac80211_hwsim_ops.cancel_remain_on_channel =
45267 - mac80211_hwsim_croc;
45268 - mac80211_hwsim_ops.add_chanctx =
45269 - mac80211_hwsim_add_chanctx;
45270 - mac80211_hwsim_ops.remove_chanctx =
45271 - mac80211_hwsim_remove_chanctx;
45272 - mac80211_hwsim_ops.change_chanctx =
45273 - mac80211_hwsim_change_chanctx;
45274 - mac80211_hwsim_ops.assign_vif_chanctx =
45275 - mac80211_hwsim_assign_vif_chanctx;
45276 - mac80211_hwsim_ops.unassign_vif_chanctx =
45277 - mac80211_hwsim_unassign_vif_chanctx;
45278 + pax_open_kernel();
45279 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45280 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45281 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45282 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45283 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45284 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45285 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45286 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45287 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45288 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45289 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45290 + pax_close_kernel();
45291 }
45292
45293 spin_lock_init(&hwsim_radio_lock);
45294 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45295 index 8169a85..7fa3b47 100644
45296 --- a/drivers/net/wireless/rndis_wlan.c
45297 +++ b/drivers/net/wireless/rndis_wlan.c
45298 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45299
45300 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45301
45302 - if (rts_threshold < 0 || rts_threshold > 2347)
45303 + if (rts_threshold > 2347)
45304 rts_threshold = 2347;
45305
45306 tmp = cpu_to_le32(rts_threshold);
45307 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45308 index ee3fc57..ed5ddc9 100644
45309 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45310 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45311 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45312 * for hardware which doesn't support hardware
45313 * sequence counting.
45314 */
45315 - atomic_t seqno;
45316 + atomic_unchecked_t seqno;
45317 };
45318
45319 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45320 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45321 index aa95c6c..a59dd67 100644
45322 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45323 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45324 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45325 * sequence counter given by mac80211.
45326 */
45327 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45328 - seqno = atomic_add_return(0x10, &intf->seqno);
45329 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45330 else
45331 - seqno = atomic_read(&intf->seqno);
45332 + seqno = atomic_read_unchecked(&intf->seqno);
45333
45334 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45335 hdr->seq_ctrl |= cpu_to_le16(seqno);
45336 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45337 index e2b3d9c..67a5184 100644
45338 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45339 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45340 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45341
45342 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45343
45344 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45345 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45346 + pax_open_kernel();
45347 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45348 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45349 + pax_close_kernel();
45350
45351 wl1251_info("using dedicated interrupt line");
45352 } else {
45353 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45354 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45355 + pax_open_kernel();
45356 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45357 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45358 + pax_close_kernel();
45359
45360 wl1251_info("using SDIO interrupt");
45361 }
45362 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45363 index 1c627da..69f7d17 100644
45364 --- a/drivers/net/wireless/ti/wl12xx/main.c
45365 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45366 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45367 sizeof(wl->conf.mem));
45368
45369 /* read data preparation is only needed by wl127x */
45370 - wl->ops->prepare_read = wl127x_prepare_read;
45371 + pax_open_kernel();
45372 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45373 + pax_close_kernel();
45374
45375 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45376 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45377 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45378 sizeof(wl->conf.mem));
45379
45380 /* read data preparation is only needed by wl127x */
45381 - wl->ops->prepare_read = wl127x_prepare_read;
45382 + pax_open_kernel();
45383 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45384 + pax_close_kernel();
45385
45386 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45387 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45388 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45389 index 7aa0eb8..5a9ef38 100644
45390 --- a/drivers/net/wireless/ti/wl18xx/main.c
45391 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45392 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45393 }
45394
45395 if (!checksum_param) {
45396 - wl18xx_ops.set_rx_csum = NULL;
45397 - wl18xx_ops.init_vif = NULL;
45398 + pax_open_kernel();
45399 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45400 + *(void **)&wl18xx_ops.init_vif = NULL;
45401 + pax_close_kernel();
45402 }
45403
45404 /* Enable 11a Band only if we have 5G antennas */
45405 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45406 index 7ef0b4a..ff65c28 100644
45407 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45408 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45409 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45410 {
45411 struct zd_usb *usb = urb->context;
45412 struct zd_usb_interrupt *intr = &usb->intr;
45413 - int len;
45414 + unsigned int len;
45415 u16 int_num;
45416
45417 ZD_ASSERT(in_interrupt());
45418 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45419 index d93b2b6..ae50401 100644
45420 --- a/drivers/oprofile/buffer_sync.c
45421 +++ b/drivers/oprofile/buffer_sync.c
45422 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45423 if (cookie == NO_COOKIE)
45424 offset = pc;
45425 if (cookie == INVALID_COOKIE) {
45426 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45427 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45428 offset = pc;
45429 }
45430 if (cookie != last_cookie) {
45431 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45432 /* add userspace sample */
45433
45434 if (!mm) {
45435 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45436 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45437 return 0;
45438 }
45439
45440 cookie = lookup_dcookie(mm, s->eip, &offset);
45441
45442 if (cookie == INVALID_COOKIE) {
45443 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45444 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45445 return 0;
45446 }
45447
45448 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45449 /* ignore backtraces if failed to add a sample */
45450 if (state == sb_bt_start) {
45451 state = sb_bt_ignore;
45452 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45453 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45454 }
45455 }
45456 release_mm(mm);
45457 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45458 index c0cc4e7..44d4e54 100644
45459 --- a/drivers/oprofile/event_buffer.c
45460 +++ b/drivers/oprofile/event_buffer.c
45461 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45462 }
45463
45464 if (buffer_pos == buffer_size) {
45465 - atomic_inc(&oprofile_stats.event_lost_overflow);
45466 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45467 return;
45468 }
45469
45470 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45471 index ed2c3ec..deda85a 100644
45472 --- a/drivers/oprofile/oprof.c
45473 +++ b/drivers/oprofile/oprof.c
45474 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45475 if (oprofile_ops.switch_events())
45476 return;
45477
45478 - atomic_inc(&oprofile_stats.multiplex_counter);
45479 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45480 start_switch_worker();
45481 }
45482
45483 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45484 index 84a208d..d61b0a1 100644
45485 --- a/drivers/oprofile/oprofile_files.c
45486 +++ b/drivers/oprofile/oprofile_files.c
45487 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45488
45489 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45490
45491 -static ssize_t timeout_read(struct file *file, char __user *buf,
45492 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45493 size_t count, loff_t *offset)
45494 {
45495 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45496 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45497 index 917d28e..d62d981 100644
45498 --- a/drivers/oprofile/oprofile_stats.c
45499 +++ b/drivers/oprofile/oprofile_stats.c
45500 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45501 cpu_buf->sample_invalid_eip = 0;
45502 }
45503
45504 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45505 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45506 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45507 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45508 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45509 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45510 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45511 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45512 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45513 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45514 }
45515
45516
45517 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45518 index 38b6fc0..b5cbfce 100644
45519 --- a/drivers/oprofile/oprofile_stats.h
45520 +++ b/drivers/oprofile/oprofile_stats.h
45521 @@ -13,11 +13,11 @@
45522 #include <linux/atomic.h>
45523
45524 struct oprofile_stat_struct {
45525 - atomic_t sample_lost_no_mm;
45526 - atomic_t sample_lost_no_mapping;
45527 - atomic_t bt_lost_no_mapping;
45528 - atomic_t event_lost_overflow;
45529 - atomic_t multiplex_counter;
45530 + atomic_unchecked_t sample_lost_no_mm;
45531 + atomic_unchecked_t sample_lost_no_mapping;
45532 + atomic_unchecked_t bt_lost_no_mapping;
45533 + atomic_unchecked_t event_lost_overflow;
45534 + atomic_unchecked_t multiplex_counter;
45535 };
45536
45537 extern struct oprofile_stat_struct oprofile_stats;
45538 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45539 index 7c12d9c..558bf3bb 100644
45540 --- a/drivers/oprofile/oprofilefs.c
45541 +++ b/drivers/oprofile/oprofilefs.c
45542 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45543
45544
45545 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45546 - char const *name, atomic_t *val)
45547 + char const *name, atomic_unchecked_t *val)
45548 {
45549 return __oprofilefs_create_file(sb, root, name,
45550 &atomic_ro_fops, 0444, val);
45551 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45552 index 61be1d9..dec05d7 100644
45553 --- a/drivers/oprofile/timer_int.c
45554 +++ b/drivers/oprofile/timer_int.c
45555 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45556 return NOTIFY_OK;
45557 }
45558
45559 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45560 +static struct notifier_block oprofile_cpu_notifier = {
45561 .notifier_call = oprofile_cpu_notify,
45562 };
45563
45564 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45565 index 92ed045..62d39bd7 100644
45566 --- a/drivers/parport/procfs.c
45567 +++ b/drivers/parport/procfs.c
45568 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45569
45570 *ppos += len;
45571
45572 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45573 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45574 }
45575
45576 #ifdef CONFIG_PARPORT_1284
45577 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45578
45579 *ppos += len;
45580
45581 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45582 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45583 }
45584 #endif /* IEEE1284.3 support. */
45585
45586 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45587 index c35e8ad..fc33beb 100644
45588 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45589 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45590 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45591 goto init_cleanup;
45592 }
45593
45594 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45595 + pax_open_kernel();
45596 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45597 + pax_close_kernel();
45598 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45599
45600 return retval;
45601 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45602 index a6a71c4..c91097b 100644
45603 --- a/drivers/pci/hotplug/cpcihp_generic.c
45604 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45605 @@ -73,7 +73,6 @@ static u16 port;
45606 static unsigned int enum_bit;
45607 static u8 enum_mask;
45608
45609 -static struct cpci_hp_controller_ops generic_hpc_ops;
45610 static struct cpci_hp_controller generic_hpc;
45611
45612 static int __init validate_parameters(void)
45613 @@ -139,6 +138,10 @@ static int query_enum(void)
45614 return ((value & enum_mask) == enum_mask);
45615 }
45616
45617 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45618 + .query_enum = query_enum,
45619 +};
45620 +
45621 static int __init cpcihp_generic_init(void)
45622 {
45623 int status;
45624 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45625 pci_dev_put(dev);
45626
45627 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45628 - generic_hpc_ops.query_enum = query_enum;
45629 generic_hpc.ops = &generic_hpc_ops;
45630
45631 status = cpci_hp_register_controller(&generic_hpc);
45632 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45633 index 449b4bb..257e2e8 100644
45634 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45635 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45636 @@ -59,7 +59,6 @@
45637 /* local variables */
45638 static bool debug;
45639 static bool poll;
45640 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45641 static struct cpci_hp_controller zt5550_hpc;
45642
45643 /* Primary cPCI bus bridge device */
45644 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45645 return 0;
45646 }
45647
45648 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45649 + .query_enum = zt5550_hc_query_enum,
45650 +};
45651 +
45652 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45653 {
45654 int status;
45655 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45656 dbg("returned from zt5550_hc_config");
45657
45658 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45659 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45660 zt5550_hpc.ops = &zt5550_hpc_ops;
45661 if(!poll) {
45662 zt5550_hpc.irq = hc_dev->irq;
45663 zt5550_hpc.irq_flags = IRQF_SHARED;
45664 zt5550_hpc.dev_id = hc_dev;
45665
45666 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45667 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45668 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45669 + pax_open_kernel();
45670 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45671 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45672 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45673 + pax_open_kernel();
45674 } else {
45675 info("using ENUM# polling mode");
45676 }
45677 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45678 index 76ba8a1..20ca857 100644
45679 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45680 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45681 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45682
45683 void compaq_nvram_init (void __iomem *rom_start)
45684 {
45685 +
45686 +#ifndef CONFIG_PAX_KERNEXEC
45687 if (rom_start) {
45688 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45689 }
45690 +#endif
45691 +
45692 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45693
45694 /* initialize our int15 lock */
45695 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45696 index ec20f74..c1d961e 100644
45697 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45698 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45699 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45700 return -EINVAL;
45701 }
45702
45703 - slot->ops->owner = owner;
45704 - slot->ops->mod_name = mod_name;
45705 + pax_open_kernel();
45706 + *(struct module **)&slot->ops->owner = owner;
45707 + *(const char **)&slot->ops->mod_name = mod_name;
45708 + pax_close_kernel();
45709
45710 mutex_lock(&pci_hp_mutex);
45711 /*
45712 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45713 index 7d72c5e..edce02c 100644
45714 --- a/drivers/pci/hotplug/pciehp_core.c
45715 +++ b/drivers/pci/hotplug/pciehp_core.c
45716 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45717 struct slot *slot = ctrl->slot;
45718 struct hotplug_slot *hotplug = NULL;
45719 struct hotplug_slot_info *info = NULL;
45720 - struct hotplug_slot_ops *ops = NULL;
45721 + hotplug_slot_ops_no_const *ops = NULL;
45722 char name[SLOT_NAME_SIZE];
45723 int retval = -ENOMEM;
45724
45725 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45726 index c0dbe1f..94cf3d8 100644
45727 --- a/drivers/pci/pci-sysfs.c
45728 +++ b/drivers/pci/pci-sysfs.c
45729 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45730 {
45731 /* allocate attribute structure, piggyback attribute name */
45732 int name_len = write_combine ? 13 : 10;
45733 - struct bin_attribute *res_attr;
45734 + bin_attribute_no_const *res_attr;
45735 int retval;
45736
45737 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45738 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45739 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45740 {
45741 int retval;
45742 - struct bin_attribute *attr;
45743 + bin_attribute_no_const *attr;
45744
45745 /* If the device has VPD, try to expose it in sysfs. */
45746 if (dev->vpd) {
45747 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45748 {
45749 int retval;
45750 int rom_size = 0;
45751 - struct bin_attribute *attr;
45752 + bin_attribute_no_const *attr;
45753
45754 if (!sysfs_initialized)
45755 return -EACCES;
45756 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45757 index d1182c4..2a138ec 100644
45758 --- a/drivers/pci/pci.h
45759 +++ b/drivers/pci/pci.h
45760 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45761 struct pci_vpd {
45762 unsigned int len;
45763 const struct pci_vpd_ops *ops;
45764 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45765 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45766 };
45767
45768 int pci_vpd_pci22_init(struct pci_dev *dev);
45769 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45770 index 403a443..034e050 100644
45771 --- a/drivers/pci/pcie/aspm.c
45772 +++ b/drivers/pci/pcie/aspm.c
45773 @@ -27,9 +27,9 @@
45774 #define MODULE_PARAM_PREFIX "pcie_aspm."
45775
45776 /* Note: those are not register definitions */
45777 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45778 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45779 -#define ASPM_STATE_L1 (4) /* L1 state */
45780 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45781 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45782 +#define ASPM_STATE_L1 (4U) /* L1 state */
45783 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45784 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45785
45786 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45787 index 46ada5c..20da716 100644
45788 --- a/drivers/pci/probe.c
45789 +++ b/drivers/pci/probe.c
45790 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45791 struct pci_bus_region region, inverted_region;
45792 bool bar_too_big = false, bar_disabled = false;
45793
45794 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45795 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45796
45797 /* No printks while decoding is disabled! */
45798 if (!dev->mmio_always_on) {
45799 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45800 index cdc7836..528635c 100644
45801 --- a/drivers/pci/proc.c
45802 +++ b/drivers/pci/proc.c
45803 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45804 static int __init pci_proc_init(void)
45805 {
45806 struct pci_dev *dev = NULL;
45807 +
45808 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45809 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45810 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45811 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45812 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45813 +#endif
45814 +#else
45815 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45816 +#endif
45817 proc_create("devices", 0, proc_bus_pci_dir,
45818 &proc_bus_pci_dev_operations);
45819 proc_initialized = 1;
45820 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45821 index 3e5b4497..dcdfb70 100644
45822 --- a/drivers/platform/x86/chromeos_laptop.c
45823 +++ b/drivers/platform/x86/chromeos_laptop.c
45824 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45825 return 0;
45826 }
45827
45828 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45829 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45830 {
45831 .ident = "Samsung Series 5 550 - Touchpad",
45832 .matches = {
45833 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45834 index 62f8030..c7f2a45 100644
45835 --- a/drivers/platform/x86/msi-laptop.c
45836 +++ b/drivers/platform/x86/msi-laptop.c
45837 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45838
45839 if (!quirks->ec_read_only) {
45840 /* allow userland write sysfs file */
45841 - dev_attr_bluetooth.store = store_bluetooth;
45842 - dev_attr_wlan.store = store_wlan;
45843 - dev_attr_threeg.store = store_threeg;
45844 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45845 - dev_attr_wlan.attr.mode |= S_IWUSR;
45846 - dev_attr_threeg.attr.mode |= S_IWUSR;
45847 + pax_open_kernel();
45848 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45849 + *(void **)&dev_attr_wlan.store = store_wlan;
45850 + *(void **)&dev_attr_threeg.store = store_threeg;
45851 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45852 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45853 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45854 + pax_close_kernel();
45855 }
45856
45857 /* disable hardware control by fn key */
45858 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45859 index 3a1b6bf..b453930 100644
45860 --- a/drivers/platform/x86/sony-laptop.c
45861 +++ b/drivers/platform/x86/sony-laptop.c
45862 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45863 }
45864
45865 /* High speed charging function */
45866 -static struct device_attribute *hsc_handle;
45867 +static device_attribute_no_const *hsc_handle;
45868
45869 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45870 struct device_attribute *attr,
45871 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45872 index 54d31c0..3f896d3 100644
45873 --- a/drivers/platform/x86/thinkpad_acpi.c
45874 +++ b/drivers/platform/x86/thinkpad_acpi.c
45875 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45876 return 0;
45877 }
45878
45879 -void static hotkey_mask_warn_incomplete_mask(void)
45880 +static void hotkey_mask_warn_incomplete_mask(void)
45881 {
45882 /* log only what the user can fix... */
45883 const u32 wantedmask = hotkey_driver_mask &
45884 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45885 }
45886 }
45887
45888 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45889 - struct tp_nvram_state *newn,
45890 - const u32 event_mask)
45891 -{
45892 -
45893 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45894 do { \
45895 if ((event_mask & (1 << __scancode)) && \
45896 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45897 tpacpi_hotkey_send_key(__scancode); \
45898 } while (0)
45899
45900 - void issue_volchange(const unsigned int oldvol,
45901 - const unsigned int newvol)
45902 - {
45903 - unsigned int i = oldvol;
45904 +static void issue_volchange(const unsigned int oldvol,
45905 + const unsigned int newvol,
45906 + const u32 event_mask)
45907 +{
45908 + unsigned int i = oldvol;
45909
45910 - while (i > newvol) {
45911 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45912 - i--;
45913 - }
45914 - while (i < newvol) {
45915 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45916 - i++;
45917 - }
45918 + while (i > newvol) {
45919 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45920 + i--;
45921 }
45922 + while (i < newvol) {
45923 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45924 + i++;
45925 + }
45926 +}
45927
45928 - void issue_brightnesschange(const unsigned int oldbrt,
45929 - const unsigned int newbrt)
45930 - {
45931 - unsigned int i = oldbrt;
45932 +static void issue_brightnesschange(const unsigned int oldbrt,
45933 + const unsigned int newbrt,
45934 + const u32 event_mask)
45935 +{
45936 + unsigned int i = oldbrt;
45937
45938 - while (i > newbrt) {
45939 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45940 - i--;
45941 - }
45942 - while (i < newbrt) {
45943 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45944 - i++;
45945 - }
45946 + while (i > newbrt) {
45947 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45948 + i--;
45949 + }
45950 + while (i < newbrt) {
45951 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45952 + i++;
45953 }
45954 +}
45955
45956 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45957 + struct tp_nvram_state *newn,
45958 + const u32 event_mask)
45959 +{
45960 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45961 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45962 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45963 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45964 oldn->volume_level != newn->volume_level) {
45965 /* recently muted, or repeated mute keypress, or
45966 * multiple presses ending in mute */
45967 - issue_volchange(oldn->volume_level, newn->volume_level);
45968 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45969 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45970 }
45971 } else {
45972 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45973 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45974 }
45975 if (oldn->volume_level != newn->volume_level) {
45976 - issue_volchange(oldn->volume_level, newn->volume_level);
45977 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45978 } else if (oldn->volume_toggle != newn->volume_toggle) {
45979 /* repeated vol up/down keypress at end of scale ? */
45980 if (newn->volume_level == 0)
45981 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45982 /* handle brightness */
45983 if (oldn->brightness_level != newn->brightness_level) {
45984 issue_brightnesschange(oldn->brightness_level,
45985 - newn->brightness_level);
45986 + newn->brightness_level,
45987 + event_mask);
45988 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45989 /* repeated key presses that didn't change state */
45990 if (newn->brightness_level == 0)
45991 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45992 && !tp_features.bright_unkfw)
45993 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45994 }
45995 +}
45996
45997 #undef TPACPI_COMPARE_KEY
45998 #undef TPACPI_MAY_SEND_KEY
45999 -}
46000
46001 /*
46002 * Polling driver
46003 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
46004 index 769d265..a3a05ca 100644
46005 --- a/drivers/pnp/pnpbios/bioscalls.c
46006 +++ b/drivers/pnp/pnpbios/bioscalls.c
46007 @@ -58,7 +58,7 @@ do { \
46008 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
46009 } while(0)
46010
46011 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
46012 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
46013 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
46014
46015 /*
46016 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46017
46018 cpu = get_cpu();
46019 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
46020 +
46021 + pax_open_kernel();
46022 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
46023 + pax_close_kernel();
46024
46025 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
46026 spin_lock_irqsave(&pnp_bios_lock, flags);
46027 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46028 :"memory");
46029 spin_unlock_irqrestore(&pnp_bios_lock, flags);
46030
46031 + pax_open_kernel();
46032 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
46033 + pax_close_kernel();
46034 +
46035 put_cpu();
46036
46037 /* If we get here and this is set then the PnP BIOS faulted on us. */
46038 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
46039 return status;
46040 }
46041
46042 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
46043 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
46044 {
46045 int i;
46046
46047 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46048 pnp_bios_callpoint.offset = header->fields.pm16offset;
46049 pnp_bios_callpoint.segment = PNP_CS16;
46050
46051 + pax_open_kernel();
46052 +
46053 for_each_possible_cpu(i) {
46054 struct desc_struct *gdt = get_cpu_gdt_table(i);
46055 if (!gdt)
46056 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46057 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
46058 (unsigned long)__va(header->fields.pm16dseg));
46059 }
46060 +
46061 + pax_close_kernel();
46062 }
46063 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
46064 index d95e101..67f0c3f 100644
46065 --- a/drivers/pnp/resource.c
46066 +++ b/drivers/pnp/resource.c
46067 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
46068 return 1;
46069
46070 /* check if the resource is valid */
46071 - if (*irq < 0 || *irq > 15)
46072 + if (*irq > 15)
46073 return 0;
46074
46075 /* check if the resource is reserved */
46076 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
46077 return 1;
46078
46079 /* check if the resource is valid */
46080 - if (*dma < 0 || *dma == 4 || *dma > 7)
46081 + if (*dma == 4 || *dma > 7)
46082 return 0;
46083
46084 /* check if the resource is reserved */
46085 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
46086 index 0c52e2a..3421ab7 100644
46087 --- a/drivers/power/pda_power.c
46088 +++ b/drivers/power/pda_power.c
46089 @@ -37,7 +37,11 @@ static int polling;
46090
46091 #if IS_ENABLED(CONFIG_USB_PHY)
46092 static struct usb_phy *transceiver;
46093 -static struct notifier_block otg_nb;
46094 +static int otg_handle_notification(struct notifier_block *nb,
46095 + unsigned long event, void *unused);
46096 +static struct notifier_block otg_nb = {
46097 + .notifier_call = otg_handle_notification
46098 +};
46099 #endif
46100
46101 static struct regulator *ac_draw;
46102 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
46103
46104 #if IS_ENABLED(CONFIG_USB_PHY)
46105 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
46106 - otg_nb.notifier_call = otg_handle_notification;
46107 ret = usb_register_notifier(transceiver, &otg_nb);
46108 if (ret) {
46109 dev_err(dev, "failure to register otg notifier\n");
46110 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
46111 index cc439fd..8fa30df 100644
46112 --- a/drivers/power/power_supply.h
46113 +++ b/drivers/power/power_supply.h
46114 @@ -16,12 +16,12 @@ struct power_supply;
46115
46116 #ifdef CONFIG_SYSFS
46117
46118 -extern void power_supply_init_attrs(struct device_type *dev_type);
46119 +extern void power_supply_init_attrs(void);
46120 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
46121
46122 #else
46123
46124 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
46125 +static inline void power_supply_init_attrs(void) {}
46126 #define power_supply_uevent NULL
46127
46128 #endif /* CONFIG_SYSFS */
46129 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
46130 index 3b2d5df..3207114 100644
46131 --- a/drivers/power/power_supply_core.c
46132 +++ b/drivers/power/power_supply_core.c
46133 @@ -24,7 +24,10 @@
46134 struct class *power_supply_class;
46135 EXPORT_SYMBOL_GPL(power_supply_class);
46136
46137 -static struct device_type power_supply_dev_type;
46138 +extern const struct attribute_group *power_supply_attr_groups[];
46139 +static struct device_type power_supply_dev_type = {
46140 + .groups = power_supply_attr_groups,
46141 +};
46142
46143 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
46144 struct power_supply *supply)
46145 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
46146 return PTR_ERR(power_supply_class);
46147
46148 power_supply_class->dev_uevent = power_supply_uevent;
46149 - power_supply_init_attrs(&power_supply_dev_type);
46150 + power_supply_init_attrs();
46151
46152 return 0;
46153 }
46154 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
46155 index 29178f7..c65f324 100644
46156 --- a/drivers/power/power_supply_sysfs.c
46157 +++ b/drivers/power/power_supply_sysfs.c
46158 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
46159 .is_visible = power_supply_attr_is_visible,
46160 };
46161
46162 -static const struct attribute_group *power_supply_attr_groups[] = {
46163 +const struct attribute_group *power_supply_attr_groups[] = {
46164 &power_supply_attr_group,
46165 NULL,
46166 };
46167
46168 -void power_supply_init_attrs(struct device_type *dev_type)
46169 +void power_supply_init_attrs(void)
46170 {
46171 int i;
46172
46173 - dev_type->groups = power_supply_attr_groups;
46174 -
46175 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
46176 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
46177 }
46178 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
46179 index 288c75a..065bc84 100644
46180 --- a/drivers/regulator/core.c
46181 +++ b/drivers/regulator/core.c
46182 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46183 {
46184 const struct regulation_constraints *constraints = NULL;
46185 const struct regulator_init_data *init_data;
46186 - static atomic_t regulator_no = ATOMIC_INIT(0);
46187 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
46188 struct regulator_dev *rdev;
46189 struct device *dev;
46190 int ret, i;
46191 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46192 rdev->dev.of_node = config->of_node;
46193 rdev->dev.parent = dev;
46194 dev_set_name(&rdev->dev, "regulator.%d",
46195 - atomic_inc_return(&regulator_no) - 1);
46196 + atomic_inc_return_unchecked(&regulator_no) - 1);
46197 ret = device_register(&rdev->dev);
46198 if (ret != 0) {
46199 put_device(&rdev->dev);
46200 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
46201 index d428ef9..fdc0357 100644
46202 --- a/drivers/regulator/max8660.c
46203 +++ b/drivers/regulator/max8660.c
46204 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
46205 max8660->shadow_regs[MAX8660_OVER1] = 5;
46206 } else {
46207 /* Otherwise devices can be toggled via software */
46208 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
46209 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
46210 + pax_open_kernel();
46211 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46212 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46213 + pax_close_kernel();
46214 }
46215
46216 /*
46217 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46218 index 0c5195a..637a453d 100644
46219 --- a/drivers/regulator/max8973-regulator.c
46220 +++ b/drivers/regulator/max8973-regulator.c
46221 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
46222 if (!pdata || !pdata->enable_ext_control) {
46223 max->desc.enable_reg = MAX8973_VOUT;
46224 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46225 - max->ops.enable = regulator_enable_regmap;
46226 - max->ops.disable = regulator_disable_regmap;
46227 - max->ops.is_enabled = regulator_is_enabled_regmap;
46228 + pax_open_kernel();
46229 + *(void **)&max->ops.enable = regulator_enable_regmap;
46230 + *(void **)&max->ops.disable = regulator_disable_regmap;
46231 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46232 + pax_close_kernel();
46233 }
46234
46235 if (pdata) {
46236 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46237 index 1037e07..e64dea1 100644
46238 --- a/drivers/regulator/mc13892-regulator.c
46239 +++ b/drivers/regulator/mc13892-regulator.c
46240 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46241 }
46242 mc13xxx_unlock(mc13892);
46243
46244 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46245 + pax_open_kernel();
46246 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46247 = mc13892_vcam_set_mode;
46248 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46249 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46250 = mc13892_vcam_get_mode;
46251 + pax_close_kernel();
46252
46253 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46254 ARRAY_SIZE(mc13892_regulators));
46255 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46256 index be06d71..264aee9 100644
46257 --- a/drivers/rtc/rtc-cmos.c
46258 +++ b/drivers/rtc/rtc-cmos.c
46259 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46260 hpet_rtc_timer_init();
46261
46262 /* export at least the first block of NVRAM */
46263 - nvram.size = address_space - NVRAM_OFFSET;
46264 + pax_open_kernel();
46265 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46266 + pax_close_kernel();
46267 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46268 if (retval < 0) {
46269 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46270 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46271 index d049393..bb20be0 100644
46272 --- a/drivers/rtc/rtc-dev.c
46273 +++ b/drivers/rtc/rtc-dev.c
46274 @@ -16,6 +16,7 @@
46275 #include <linux/module.h>
46276 #include <linux/rtc.h>
46277 #include <linux/sched.h>
46278 +#include <linux/grsecurity.h>
46279 #include "rtc-core.h"
46280
46281 static dev_t rtc_devt;
46282 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46283 if (copy_from_user(&tm, uarg, sizeof(tm)))
46284 return -EFAULT;
46285
46286 + gr_log_timechange();
46287 +
46288 return rtc_set_time(rtc, &tm);
46289
46290 case RTC_PIE_ON:
46291 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46292 index ca18fd1..055e42d 100644
46293 --- a/drivers/rtc/rtc-ds1307.c
46294 +++ b/drivers/rtc/rtc-ds1307.c
46295 @@ -107,7 +107,7 @@ struct ds1307 {
46296 u8 offset; /* register's offset */
46297 u8 regs[11];
46298 u16 nvram_offset;
46299 - struct bin_attribute *nvram;
46300 + bin_attribute_no_const *nvram;
46301 enum ds_type type;
46302 unsigned long flags;
46303 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46304 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46305 index fcb0329..d77b7f2 100644
46306 --- a/drivers/rtc/rtc-m48t59.c
46307 +++ b/drivers/rtc/rtc-m48t59.c
46308 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46309 if (IS_ERR(m48t59->rtc))
46310 return PTR_ERR(m48t59->rtc);
46311
46312 - m48t59_nvram_attr.size = pdata->offset;
46313 + pax_open_kernel();
46314 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46315 + pax_close_kernel();
46316
46317 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46318 if (ret)
46319 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46320 index e693af6..2e525b6 100644
46321 --- a/drivers/scsi/bfa/bfa_fcpim.h
46322 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46323 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46324
46325 struct bfa_itn_s {
46326 bfa_isr_func_t isr;
46327 -};
46328 +} __no_const;
46329
46330 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46331 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46332 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46333 index 90814fe..4384138 100644
46334 --- a/drivers/scsi/bfa/bfa_ioc.h
46335 +++ b/drivers/scsi/bfa/bfa_ioc.h
46336 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46337 bfa_ioc_disable_cbfn_t disable_cbfn;
46338 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46339 bfa_ioc_reset_cbfn_t reset_cbfn;
46340 -};
46341 +} __no_const;
46342
46343 /*
46344 * IOC event notification mechanism.
46345 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46346 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46347 enum bfi_ioc_state fwstate);
46348 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46349 -};
46350 +} __no_const;
46351
46352 /*
46353 * Queue element to wait for room in request queue. FIFO order is
46354 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46355 index c9382d6..6619864 100644
46356 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46357 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46358 @@ -33,8 +33,8 @@
46359 */
46360 #include "libfcoe.h"
46361
46362 -static atomic_t ctlr_num;
46363 -static atomic_t fcf_num;
46364 +static atomic_unchecked_t ctlr_num;
46365 +static atomic_unchecked_t fcf_num;
46366
46367 /*
46368 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46369 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46370 if (!ctlr)
46371 goto out;
46372
46373 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46374 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46375 ctlr->f = f;
46376 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46377 INIT_LIST_HEAD(&ctlr->fcfs);
46378 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46379 fcf->dev.parent = &ctlr->dev;
46380 fcf->dev.bus = &fcoe_bus_type;
46381 fcf->dev.type = &fcoe_fcf_device_type;
46382 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46383 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46384 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46385
46386 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46387 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46388 {
46389 int error;
46390
46391 - atomic_set(&ctlr_num, 0);
46392 - atomic_set(&fcf_num, 0);
46393 + atomic_set_unchecked(&ctlr_num, 0);
46394 + atomic_set_unchecked(&fcf_num, 0);
46395
46396 error = bus_register(&fcoe_bus_type);
46397 if (error)
46398 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46399 index df0c3c7..b00e1d0 100644
46400 --- a/drivers/scsi/hosts.c
46401 +++ b/drivers/scsi/hosts.c
46402 @@ -42,7 +42,7 @@
46403 #include "scsi_logging.h"
46404
46405
46406 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46407 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46408
46409
46410 static void scsi_host_cls_release(struct device *dev)
46411 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46412 * subtract one because we increment first then return, but we need to
46413 * know what the next host number was before increment
46414 */
46415 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46416 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46417 shost->dma_channel = 0xff;
46418
46419 /* These three are default values which can be overridden */
46420 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46421 index 7f4f790..b75b92a 100644
46422 --- a/drivers/scsi/hpsa.c
46423 +++ b/drivers/scsi/hpsa.c
46424 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46425 unsigned long flags;
46426
46427 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46428 - return h->access.command_completed(h, q);
46429 + return h->access->command_completed(h, q);
46430
46431 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46432 a = rq->head[rq->current_entry];
46433 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46434 while (!list_empty(&h->reqQ)) {
46435 c = list_entry(h->reqQ.next, struct CommandList, list);
46436 /* can't do anything if fifo is full */
46437 - if ((h->access.fifo_full(h))) {
46438 + if ((h->access->fifo_full(h))) {
46439 dev_warn(&h->pdev->dev, "fifo full\n");
46440 break;
46441 }
46442 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46443
46444 /* Tell the controller execute command */
46445 spin_unlock_irqrestore(&h->lock, flags);
46446 - h->access.submit_command(h, c);
46447 + h->access->submit_command(h, c);
46448 spin_lock_irqsave(&h->lock, flags);
46449 }
46450 spin_unlock_irqrestore(&h->lock, flags);
46451 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46452
46453 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46454 {
46455 - return h->access.command_completed(h, q);
46456 + return h->access->command_completed(h, q);
46457 }
46458
46459 static inline bool interrupt_pending(struct ctlr_info *h)
46460 {
46461 - return h->access.intr_pending(h);
46462 + return h->access->intr_pending(h);
46463 }
46464
46465 static inline long interrupt_not_for_us(struct ctlr_info *h)
46466 {
46467 - return (h->access.intr_pending(h) == 0) ||
46468 + return (h->access->intr_pending(h) == 0) ||
46469 (h->interrupts_enabled == 0);
46470 }
46471
46472 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46473 if (prod_index < 0)
46474 return -ENODEV;
46475 h->product_name = products[prod_index].product_name;
46476 - h->access = *(products[prod_index].access);
46477 + h->access = products[prod_index].access;
46478
46479 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46480 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46481 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46482
46483 assert_spin_locked(&lockup_detector_lock);
46484 remove_ctlr_from_lockup_detector_list(h);
46485 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46486 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46487 spin_lock_irqsave(&h->lock, flags);
46488 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46489 spin_unlock_irqrestore(&h->lock, flags);
46490 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46491 }
46492
46493 /* make sure the board interrupts are off */
46494 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46495 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46496
46497 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46498 goto clean2;
46499 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46500 * fake ones to scoop up any residual completions.
46501 */
46502 spin_lock_irqsave(&h->lock, flags);
46503 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46504 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46505 spin_unlock_irqrestore(&h->lock, flags);
46506 free_irqs(h);
46507 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46508 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46509 dev_info(&h->pdev->dev, "Board READY.\n");
46510 dev_info(&h->pdev->dev,
46511 "Waiting for stale completions to drain.\n");
46512 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46513 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46514 msleep(10000);
46515 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46516 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46517
46518 rc = controller_reset_failed(h->cfgtable);
46519 if (rc)
46520 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46521 }
46522
46523 /* Turn the interrupts on so we can service requests */
46524 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46525 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46526
46527 hpsa_hba_inquiry(h);
46528 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46529 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46530 * To write all data in the battery backed cache to disks
46531 */
46532 hpsa_flush_cache(h);
46533 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46534 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46535 hpsa_free_irqs_and_disable_msix(h);
46536 }
46537
46538 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46539 return;
46540 }
46541 /* Change the access methods to the performant access methods */
46542 - h->access = SA5_performant_access;
46543 + h->access = &SA5_performant_access;
46544 h->transMethod = CFGTBL_Trans_Performant;
46545 }
46546
46547 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46548 index 9816479..c5d4e97 100644
46549 --- a/drivers/scsi/hpsa.h
46550 +++ b/drivers/scsi/hpsa.h
46551 @@ -79,7 +79,7 @@ struct ctlr_info {
46552 unsigned int msix_vector;
46553 unsigned int msi_vector;
46554 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46555 - struct access_method access;
46556 + struct access_method *access;
46557
46558 /* queue and queue Info */
46559 struct list_head reqQ;
46560 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46561 index 5879929..32b241d 100644
46562 --- a/drivers/scsi/libfc/fc_exch.c
46563 +++ b/drivers/scsi/libfc/fc_exch.c
46564 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46565 u16 pool_max_index;
46566
46567 struct {
46568 - atomic_t no_free_exch;
46569 - atomic_t no_free_exch_xid;
46570 - atomic_t xid_not_found;
46571 - atomic_t xid_busy;
46572 - atomic_t seq_not_found;
46573 - atomic_t non_bls_resp;
46574 + atomic_unchecked_t no_free_exch;
46575 + atomic_unchecked_t no_free_exch_xid;
46576 + atomic_unchecked_t xid_not_found;
46577 + atomic_unchecked_t xid_busy;
46578 + atomic_unchecked_t seq_not_found;
46579 + atomic_unchecked_t non_bls_resp;
46580 } stats;
46581 };
46582
46583 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46584 /* allocate memory for exchange */
46585 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46586 if (!ep) {
46587 - atomic_inc(&mp->stats.no_free_exch);
46588 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46589 goto out;
46590 }
46591 memset(ep, 0, sizeof(*ep));
46592 @@ -797,7 +797,7 @@ out:
46593 return ep;
46594 err:
46595 spin_unlock_bh(&pool->lock);
46596 - atomic_inc(&mp->stats.no_free_exch_xid);
46597 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46598 mempool_free(ep, mp->ep_pool);
46599 return NULL;
46600 }
46601 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46602 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46603 ep = fc_exch_find(mp, xid);
46604 if (!ep) {
46605 - atomic_inc(&mp->stats.xid_not_found);
46606 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46607 reject = FC_RJT_OX_ID;
46608 goto out;
46609 }
46610 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46611 ep = fc_exch_find(mp, xid);
46612 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46613 if (ep) {
46614 - atomic_inc(&mp->stats.xid_busy);
46615 + atomic_inc_unchecked(&mp->stats.xid_busy);
46616 reject = FC_RJT_RX_ID;
46617 goto rel;
46618 }
46619 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46620 }
46621 xid = ep->xid; /* get our XID */
46622 } else if (!ep) {
46623 - atomic_inc(&mp->stats.xid_not_found);
46624 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46625 reject = FC_RJT_RX_ID; /* XID not found */
46626 goto out;
46627 }
46628 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46629 } else {
46630 sp = &ep->seq;
46631 if (sp->id != fh->fh_seq_id) {
46632 - atomic_inc(&mp->stats.seq_not_found);
46633 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46634 if (f_ctl & FC_FC_END_SEQ) {
46635 /*
46636 * Update sequence_id based on incoming last
46637 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46638
46639 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46640 if (!ep) {
46641 - atomic_inc(&mp->stats.xid_not_found);
46642 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46643 goto out;
46644 }
46645 if (ep->esb_stat & ESB_ST_COMPLETE) {
46646 - atomic_inc(&mp->stats.xid_not_found);
46647 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46648 goto rel;
46649 }
46650 if (ep->rxid == FC_XID_UNKNOWN)
46651 ep->rxid = ntohs(fh->fh_rx_id);
46652 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46653 - atomic_inc(&mp->stats.xid_not_found);
46654 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46655 goto rel;
46656 }
46657 if (ep->did != ntoh24(fh->fh_s_id) &&
46658 ep->did != FC_FID_FLOGI) {
46659 - atomic_inc(&mp->stats.xid_not_found);
46660 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46661 goto rel;
46662 }
46663 sof = fr_sof(fp);
46664 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46665 sp->ssb_stat |= SSB_ST_RESP;
46666 sp->id = fh->fh_seq_id;
46667 } else if (sp->id != fh->fh_seq_id) {
46668 - atomic_inc(&mp->stats.seq_not_found);
46669 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46670 goto rel;
46671 }
46672
46673 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46674 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46675
46676 if (!sp)
46677 - atomic_inc(&mp->stats.xid_not_found);
46678 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46679 else
46680 - atomic_inc(&mp->stats.non_bls_resp);
46681 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46682
46683 fc_frame_free(fp);
46684 }
46685 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46686
46687 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46688 mp = ema->mp;
46689 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46690 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46691 st->fc_no_free_exch_xid +=
46692 - atomic_read(&mp->stats.no_free_exch_xid);
46693 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46694 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46695 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46696 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46697 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46698 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46699 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46700 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46701 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46702 }
46703 }
46704 EXPORT_SYMBOL(fc_exch_update_stats);
46705 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46706 index 161c98e..6d563b3 100644
46707 --- a/drivers/scsi/libsas/sas_ata.c
46708 +++ b/drivers/scsi/libsas/sas_ata.c
46709 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46710 .postreset = ata_std_postreset,
46711 .error_handler = ata_std_error_handler,
46712 .post_internal_cmd = sas_ata_post_internal,
46713 - .qc_defer = ata_std_qc_defer,
46714 + .qc_defer = ata_std_qc_defer,
46715 .qc_prep = ata_noop_qc_prep,
46716 .qc_issue = sas_ata_qc_issue,
46717 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46718 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46719 index 93f222d..73e977b 100644
46720 --- a/drivers/scsi/lpfc/lpfc.h
46721 +++ b/drivers/scsi/lpfc/lpfc.h
46722 @@ -431,7 +431,7 @@ struct lpfc_vport {
46723 struct dentry *debug_nodelist;
46724 struct dentry *vport_debugfs_root;
46725 struct lpfc_debugfs_trc *disc_trc;
46726 - atomic_t disc_trc_cnt;
46727 + atomic_unchecked_t disc_trc_cnt;
46728 #endif
46729 uint8_t stat_data_enabled;
46730 uint8_t stat_data_blocked;
46731 @@ -865,8 +865,8 @@ struct lpfc_hba {
46732 struct timer_list fabric_block_timer;
46733 unsigned long bit_flags;
46734 #define FABRIC_COMANDS_BLOCKED 0
46735 - atomic_t num_rsrc_err;
46736 - atomic_t num_cmd_success;
46737 + atomic_unchecked_t num_rsrc_err;
46738 + atomic_unchecked_t num_cmd_success;
46739 unsigned long last_rsrc_error_time;
46740 unsigned long last_ramp_down_time;
46741 unsigned long last_ramp_up_time;
46742 @@ -902,7 +902,7 @@ struct lpfc_hba {
46743
46744 struct dentry *debug_slow_ring_trc;
46745 struct lpfc_debugfs_trc *slow_ring_trc;
46746 - atomic_t slow_ring_trc_cnt;
46747 + atomic_unchecked_t slow_ring_trc_cnt;
46748 /* iDiag debugfs sub-directory */
46749 struct dentry *idiag_root;
46750 struct dentry *idiag_pci_cfg;
46751 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46752 index 60084e6..0e2e700 100644
46753 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46754 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46755 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46756
46757 #include <linux/debugfs.h>
46758
46759 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46760 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46761 static unsigned long lpfc_debugfs_start_time = 0L;
46762
46763 /* iDiag */
46764 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46765 lpfc_debugfs_enable = 0;
46766
46767 len = 0;
46768 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46769 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46770 (lpfc_debugfs_max_disc_trc - 1);
46771 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46772 dtp = vport->disc_trc + i;
46773 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46774 lpfc_debugfs_enable = 0;
46775
46776 len = 0;
46777 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46778 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46779 (lpfc_debugfs_max_slow_ring_trc - 1);
46780 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46781 dtp = phba->slow_ring_trc + i;
46782 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46783 !vport || !vport->disc_trc)
46784 return;
46785
46786 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46787 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46788 (lpfc_debugfs_max_disc_trc - 1);
46789 dtp = vport->disc_trc + index;
46790 dtp->fmt = fmt;
46791 dtp->data1 = data1;
46792 dtp->data2 = data2;
46793 dtp->data3 = data3;
46794 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46795 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46796 dtp->jif = jiffies;
46797 #endif
46798 return;
46799 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46800 !phba || !phba->slow_ring_trc)
46801 return;
46802
46803 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46804 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46805 (lpfc_debugfs_max_slow_ring_trc - 1);
46806 dtp = phba->slow_ring_trc + index;
46807 dtp->fmt = fmt;
46808 dtp->data1 = data1;
46809 dtp->data2 = data2;
46810 dtp->data3 = data3;
46811 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46812 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46813 dtp->jif = jiffies;
46814 #endif
46815 return;
46816 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46817 "slow_ring buffer\n");
46818 goto debug_failed;
46819 }
46820 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46821 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46822 memset(phba->slow_ring_trc, 0,
46823 (sizeof(struct lpfc_debugfs_trc) *
46824 lpfc_debugfs_max_slow_ring_trc));
46825 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46826 "buffer\n");
46827 goto debug_failed;
46828 }
46829 - atomic_set(&vport->disc_trc_cnt, 0);
46830 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46831
46832 snprintf(name, sizeof(name), "discovery_trace");
46833 vport->debug_disc_trc =
46834 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46835 index e0b20fa..30c2c0d 100644
46836 --- a/drivers/scsi/lpfc/lpfc_init.c
46837 +++ b/drivers/scsi/lpfc/lpfc_init.c
46838 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46839 "misc_register returned with status %d", error);
46840
46841 if (lpfc_enable_npiv) {
46842 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46843 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46844 + pax_open_kernel();
46845 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46846 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46847 + pax_close_kernel();
46848 }
46849 lpfc_transport_template =
46850 fc_attach_transport(&lpfc_transport_functions);
46851 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46852 index 243de1d..f40e3e5 100644
46853 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46854 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46855 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46856 uint32_t evt_posted;
46857
46858 spin_lock_irqsave(&phba->hbalock, flags);
46859 - atomic_inc(&phba->num_rsrc_err);
46860 + atomic_inc_unchecked(&phba->num_rsrc_err);
46861 phba->last_rsrc_error_time = jiffies;
46862
46863 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46864 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46865 unsigned long flags;
46866 struct lpfc_hba *phba = vport->phba;
46867 uint32_t evt_posted;
46868 - atomic_inc(&phba->num_cmd_success);
46869 + atomic_inc_unchecked(&phba->num_cmd_success);
46870
46871 if (vport->cfg_lun_queue_depth <= queue_depth)
46872 return;
46873 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46874 unsigned long num_rsrc_err, num_cmd_success;
46875 int i;
46876
46877 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46878 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46879 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46880 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46881
46882 /*
46883 * The error and success command counters are global per
46884 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46885 }
46886 }
46887 lpfc_destroy_vport_work_array(phba, vports);
46888 - atomic_set(&phba->num_rsrc_err, 0);
46889 - atomic_set(&phba->num_cmd_success, 0);
46890 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46891 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46892 }
46893
46894 /**
46895 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46896 }
46897 }
46898 lpfc_destroy_vport_work_array(phba, vports);
46899 - atomic_set(&phba->num_rsrc_err, 0);
46900 - atomic_set(&phba->num_cmd_success, 0);
46901 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46902 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46903 }
46904
46905 /**
46906 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46907 index 1eb7b028..b2a6080 100644
46908 --- a/drivers/scsi/pmcraid.c
46909 +++ b/drivers/scsi/pmcraid.c
46910 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46911 res->scsi_dev = scsi_dev;
46912 scsi_dev->hostdata = res;
46913 res->change_detected = 0;
46914 - atomic_set(&res->read_failures, 0);
46915 - atomic_set(&res->write_failures, 0);
46916 + atomic_set_unchecked(&res->read_failures, 0);
46917 + atomic_set_unchecked(&res->write_failures, 0);
46918 rc = 0;
46919 }
46920 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46921 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46922
46923 /* If this was a SCSI read/write command keep count of errors */
46924 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46925 - atomic_inc(&res->read_failures);
46926 + atomic_inc_unchecked(&res->read_failures);
46927 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46928 - atomic_inc(&res->write_failures);
46929 + atomic_inc_unchecked(&res->write_failures);
46930
46931 if (!RES_IS_GSCSI(res->cfg_entry) &&
46932 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46933 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46934 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46935 * hrrq_id assigned here in queuecommand
46936 */
46937 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46938 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46939 pinstance->num_hrrq;
46940 cmd->cmd_done = pmcraid_io_done;
46941
46942 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46943 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46944 * hrrq_id assigned here in queuecommand
46945 */
46946 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46947 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46948 pinstance->num_hrrq;
46949
46950 if (request_size) {
46951 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46952
46953 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46954 /* add resources only after host is added into system */
46955 - if (!atomic_read(&pinstance->expose_resources))
46956 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46957 return;
46958
46959 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46960 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46961 init_waitqueue_head(&pinstance->reset_wait_q);
46962
46963 atomic_set(&pinstance->outstanding_cmds, 0);
46964 - atomic_set(&pinstance->last_message_id, 0);
46965 - atomic_set(&pinstance->expose_resources, 0);
46966 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46967 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46968
46969 INIT_LIST_HEAD(&pinstance->free_res_q);
46970 INIT_LIST_HEAD(&pinstance->used_res_q);
46971 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46972 /* Schedule worker thread to handle CCN and take care of adding and
46973 * removing devices to OS
46974 */
46975 - atomic_set(&pinstance->expose_resources, 1);
46976 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46977 schedule_work(&pinstance->worker_q);
46978 return rc;
46979
46980 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46981 index e1d150f..6c6df44 100644
46982 --- a/drivers/scsi/pmcraid.h
46983 +++ b/drivers/scsi/pmcraid.h
46984 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46985 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46986
46987 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46988 - atomic_t last_message_id;
46989 + atomic_unchecked_t last_message_id;
46990
46991 /* configuration table */
46992 struct pmcraid_config_table *cfg_table;
46993 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46994 atomic_t outstanding_cmds;
46995
46996 /* should add/delete resources to mid-layer now ?*/
46997 - atomic_t expose_resources;
46998 + atomic_unchecked_t expose_resources;
46999
47000
47001
47002 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
47003 struct pmcraid_config_table_entry_ext cfg_entry_ext;
47004 };
47005 struct scsi_device *scsi_dev; /* Link scsi_device structure */
47006 - atomic_t read_failures; /* count of failed READ commands */
47007 - atomic_t write_failures; /* count of failed WRITE commands */
47008 + atomic_unchecked_t read_failures; /* count of failed READ commands */
47009 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
47010
47011 /* To indicate add/delete/modify during CCN */
47012 u8 change_detected;
47013 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
47014 index d7a99ae..801df70 100644
47015 --- a/drivers/scsi/qla2xxx/qla_attr.c
47016 +++ b/drivers/scsi/qla2xxx/qla_attr.c
47017 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
47018 return 0;
47019 }
47020
47021 -struct fc_function_template qla2xxx_transport_functions = {
47022 +fc_function_template_no_const qla2xxx_transport_functions = {
47023
47024 .show_host_node_name = 1,
47025 .show_host_port_name = 1,
47026 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
47027 .bsg_timeout = qla24xx_bsg_timeout,
47028 };
47029
47030 -struct fc_function_template qla2xxx_transport_vport_functions = {
47031 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
47032
47033 .show_host_node_name = 1,
47034 .show_host_port_name = 1,
47035 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
47036 index 2d98232..a84298e 100644
47037 --- a/drivers/scsi/qla2xxx/qla_gbl.h
47038 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
47039 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
47040 struct device_attribute;
47041 extern struct device_attribute *qla2x00_host_attrs[];
47042 struct fc_function_template;
47043 -extern struct fc_function_template qla2xxx_transport_functions;
47044 -extern struct fc_function_template qla2xxx_transport_vport_functions;
47045 +extern fc_function_template_no_const qla2xxx_transport_functions;
47046 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
47047 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
47048 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
47049 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
47050 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
47051 index 3e21e9f..426ba79 100644
47052 --- a/drivers/scsi/qla2xxx/qla_os.c
47053 +++ b/drivers/scsi/qla2xxx/qla_os.c
47054 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
47055 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
47056 /* Ok, a 64bit DMA mask is applicable. */
47057 ha->flags.enable_64bit_addressing = 1;
47058 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47059 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47060 + pax_open_kernel();
47061 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47062 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47063 + pax_close_kernel();
47064 return;
47065 }
47066 }
47067 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
47068 index ddf16a8..80f4dd0 100644
47069 --- a/drivers/scsi/qla4xxx/ql4_def.h
47070 +++ b/drivers/scsi/qla4xxx/ql4_def.h
47071 @@ -291,7 +291,7 @@ struct ddb_entry {
47072 * (4000 only) */
47073 atomic_t relogin_timer; /* Max Time to wait for
47074 * relogin to complete */
47075 - atomic_t relogin_retry_count; /* Num of times relogin has been
47076 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
47077 * retried */
47078 uint32_t default_time2wait; /* Default Min time between
47079 * relogins (+aens) */
47080 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
47081 index b246b3c..897004d 100644
47082 --- a/drivers/scsi/qla4xxx/ql4_os.c
47083 +++ b/drivers/scsi/qla4xxx/ql4_os.c
47084 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
47085 */
47086 if (!iscsi_is_session_online(cls_sess)) {
47087 /* Reset retry relogin timer */
47088 - atomic_inc(&ddb_entry->relogin_retry_count);
47089 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
47090 DEBUG2(ql4_printk(KERN_INFO, ha,
47091 "%s: index[%d] relogin timed out-retrying"
47092 " relogin (%d), retry (%d)\n", __func__,
47093 ddb_entry->fw_ddb_index,
47094 - atomic_read(&ddb_entry->relogin_retry_count),
47095 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
47096 ddb_entry->default_time2wait + 4));
47097 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
47098 atomic_set(&ddb_entry->retry_relogin_timer,
47099 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
47100
47101 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
47102 atomic_set(&ddb_entry->relogin_timer, 0);
47103 - atomic_set(&ddb_entry->relogin_retry_count, 0);
47104 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
47105 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
47106 ddb_entry->default_relogin_timeout =
47107 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
47108 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
47109 index eaa808e..95f8841 100644
47110 --- a/drivers/scsi/scsi.c
47111 +++ b/drivers/scsi/scsi.c
47112 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
47113 unsigned long timeout;
47114 int rtn = 0;
47115
47116 - atomic_inc(&cmd->device->iorequest_cnt);
47117 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47118
47119 /* check if the device is still usable */
47120 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
47121 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
47122 index 124392f..75eb43e 100644
47123 --- a/drivers/scsi/scsi_lib.c
47124 +++ b/drivers/scsi/scsi_lib.c
47125 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
47126 shost = sdev->host;
47127 scsi_init_cmd_errh(cmd);
47128 cmd->result = DID_NO_CONNECT << 16;
47129 - atomic_inc(&cmd->device->iorequest_cnt);
47130 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47131
47132 /*
47133 * SCSI request completion path will do scsi_device_unbusy(),
47134 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
47135
47136 INIT_LIST_HEAD(&cmd->eh_entry);
47137
47138 - atomic_inc(&cmd->device->iodone_cnt);
47139 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
47140 if (cmd->result)
47141 - atomic_inc(&cmd->device->ioerr_cnt);
47142 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
47143
47144 disposition = scsi_decide_disposition(cmd);
47145 if (disposition != SUCCESS &&
47146 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
47147 index 7e50061..71db7a6 100644
47148 --- a/drivers/scsi/scsi_sysfs.c
47149 +++ b/drivers/scsi/scsi_sysfs.c
47150 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
47151 char *buf) \
47152 { \
47153 struct scsi_device *sdev = to_scsi_device(dev); \
47154 - unsigned long long count = atomic_read(&sdev->field); \
47155 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
47156 return snprintf(buf, 20, "0x%llx\n", count); \
47157 } \
47158 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
47159 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
47160 index 84a1fdf..693b0d6 100644
47161 --- a/drivers/scsi/scsi_tgt_lib.c
47162 +++ b/drivers/scsi/scsi_tgt_lib.c
47163 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47164 int err;
47165
47166 dprintk("%lx %u\n", uaddr, len);
47167 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47168 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47169 if (err) {
47170 /*
47171 * TODO: need to fixup sg_tablesize, max_segment_size,
47172 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47173 index 4628fd5..a94a1c2 100644
47174 --- a/drivers/scsi/scsi_transport_fc.c
47175 +++ b/drivers/scsi/scsi_transport_fc.c
47176 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47177 * Netlink Infrastructure
47178 */
47179
47180 -static atomic_t fc_event_seq;
47181 +static atomic_unchecked_t fc_event_seq;
47182
47183 /**
47184 * fc_get_event_number - Obtain the next sequential FC event number
47185 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47186 u32
47187 fc_get_event_number(void)
47188 {
47189 - return atomic_add_return(1, &fc_event_seq);
47190 + return atomic_add_return_unchecked(1, &fc_event_seq);
47191 }
47192 EXPORT_SYMBOL(fc_get_event_number);
47193
47194 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47195 {
47196 int error;
47197
47198 - atomic_set(&fc_event_seq, 0);
47199 + atomic_set_unchecked(&fc_event_seq, 0);
47200
47201 error = transport_class_register(&fc_host_class);
47202 if (error)
47203 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47204 char *cp;
47205
47206 *val = simple_strtoul(buf, &cp, 0);
47207 - if ((*cp && (*cp != '\n')) || (*val < 0))
47208 + if (*cp && (*cp != '\n'))
47209 return -EINVAL;
47210 /*
47211 * Check for overflow; dev_loss_tmo is u32
47212 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47213 index abf7c40..c3240ed 100644
47214 --- a/drivers/scsi/scsi_transport_iscsi.c
47215 +++ b/drivers/scsi/scsi_transport_iscsi.c
47216 @@ -80,7 +80,7 @@ struct iscsi_internal {
47217 struct transport_container session_cont;
47218 };
47219
47220 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47221 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47222 static struct workqueue_struct *iscsi_eh_timer_workq;
47223
47224 static DEFINE_IDA(iscsi_sess_ida);
47225 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47226 int err;
47227
47228 ihost = shost->shost_data;
47229 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47230 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47231
47232 if (target_id == ISCSI_MAX_TARGET) {
47233 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47234 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47235 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47236 ISCSI_TRANSPORT_VERSION);
47237
47238 - atomic_set(&iscsi_session_nr, 0);
47239 + atomic_set_unchecked(&iscsi_session_nr, 0);
47240
47241 err = class_register(&iscsi_transport_class);
47242 if (err)
47243 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47244 index f379c7f..e8fc69c 100644
47245 --- a/drivers/scsi/scsi_transport_srp.c
47246 +++ b/drivers/scsi/scsi_transport_srp.c
47247 @@ -33,7 +33,7 @@
47248 #include "scsi_transport_srp_internal.h"
47249
47250 struct srp_host_attrs {
47251 - atomic_t next_port_id;
47252 + atomic_unchecked_t next_port_id;
47253 };
47254 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47255
47256 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47257 struct Scsi_Host *shost = dev_to_shost(dev);
47258 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47259
47260 - atomic_set(&srp_host->next_port_id, 0);
47261 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47262 return 0;
47263 }
47264
47265 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47266 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47267 rport->roles = ids->roles;
47268
47269 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47270 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47271 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47272
47273 transport_setup_device(&rport->dev);
47274 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47275 index 86fcf2c..26d8594 100644
47276 --- a/drivers/scsi/sd.c
47277 +++ b/drivers/scsi/sd.c
47278 @@ -2938,7 +2938,7 @@ static int sd_probe(struct device *dev)
47279 sdkp->disk = gd;
47280 sdkp->index = index;
47281 atomic_set(&sdkp->openers, 0);
47282 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47283 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47284
47285 if (!sdp->request_queue->rq_timeout) {
47286 if (sdp->type != TYPE_MOD)
47287 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47288 index df5e961..df6b97f 100644
47289 --- a/drivers/scsi/sg.c
47290 +++ b/drivers/scsi/sg.c
47291 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47292 sdp->disk->disk_name,
47293 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47294 NULL,
47295 - (char *)arg);
47296 + (char __user *)arg);
47297 case BLKTRACESTART:
47298 return blk_trace_startstop(sdp->device->request_queue, 1);
47299 case BLKTRACESTOP:
47300 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47301 index 978dda2..cb19aa0 100644
47302 --- a/drivers/spi/spi.c
47303 +++ b/drivers/spi/spi.c
47304 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47305 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47306
47307 /* portable code must never pass more than 32 bytes */
47308 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47309 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47310
47311 static u8 *buf;
47312
47313 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47314 index ee3a57f..18368c1 100644
47315 --- a/drivers/staging/android/timed_output.c
47316 +++ b/drivers/staging/android/timed_output.c
47317 @@ -25,7 +25,7 @@
47318 #include "timed_output.h"
47319
47320 static struct class *timed_output_class;
47321 -static atomic_t device_count;
47322 +static atomic_unchecked_t device_count;
47323
47324 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47325 char *buf)
47326 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47327 timed_output_class = class_create(THIS_MODULE, "timed_output");
47328 if (IS_ERR(timed_output_class))
47329 return PTR_ERR(timed_output_class);
47330 - atomic_set(&device_count, 0);
47331 + atomic_set_unchecked(&device_count, 0);
47332 }
47333
47334 return 0;
47335 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47336 if (ret < 0)
47337 return ret;
47338
47339 - tdev->index = atomic_inc_return(&device_count);
47340 + tdev->index = atomic_inc_return_unchecked(&device_count);
47341 tdev->dev = device_create(timed_output_class, NULL,
47342 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47343 if (IS_ERR(tdev->dev))
47344 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47345 index 3675020..e80d92c 100644
47346 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47347 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47348 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47349
47350 static int solo_sysfs_init(struct solo_dev *solo_dev)
47351 {
47352 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47353 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47354 struct device *dev = &solo_dev->dev;
47355 const char *driver;
47356 int i;
47357 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47358 index 3335941..2b26186 100644
47359 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47360 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47361 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47362
47363 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47364 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47365 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47366 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47367 if (p2m_id < 0)
47368 p2m_id = -p2m_id;
47369 }
47370 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47371 index 6f91d2e..3f011d2 100644
47372 --- a/drivers/staging/media/solo6x10/solo6x10.h
47373 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47374 @@ -238,7 +238,7 @@ struct solo_dev {
47375
47376 /* P2M DMA Engine */
47377 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47378 - atomic_t p2m_count;
47379 + atomic_unchecked_t p2m_count;
47380 int p2m_jiffies;
47381 unsigned int p2m_timeouts;
47382
47383 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47384 index 34afc16..ffe44dd 100644
47385 --- a/drivers/staging/octeon/ethernet-rx.c
47386 +++ b/drivers/staging/octeon/ethernet-rx.c
47387 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47388 /* Increment RX stats for virtual ports */
47389 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47390 #ifdef CONFIG_64BIT
47391 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47392 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47393 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47394 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47395 #else
47396 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47397 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47398 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47399 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47400 #endif
47401 }
47402 netif_receive_skb(skb);
47403 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47404 dev->name);
47405 */
47406 #ifdef CONFIG_64BIT
47407 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47408 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47409 #else
47410 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47411 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47412 #endif
47413 dev_kfree_skb_irq(skb);
47414 }
47415 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47416 index c3a90e7..023619a 100644
47417 --- a/drivers/staging/octeon/ethernet.c
47418 +++ b/drivers/staging/octeon/ethernet.c
47419 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47420 * since the RX tasklet also increments it.
47421 */
47422 #ifdef CONFIG_64BIT
47423 - atomic64_add(rx_status.dropped_packets,
47424 - (atomic64_t *)&priv->stats.rx_dropped);
47425 + atomic64_add_unchecked(rx_status.dropped_packets,
47426 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47427 #else
47428 - atomic_add(rx_status.dropped_packets,
47429 - (atomic_t *)&priv->stats.rx_dropped);
47430 + atomic_add_unchecked(rx_status.dropped_packets,
47431 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47432 #endif
47433 }
47434
47435 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47436 index dc23395..cf7e9b1 100644
47437 --- a/drivers/staging/rtl8712/rtl871x_io.h
47438 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47439 @@ -108,7 +108,7 @@ struct _io_ops {
47440 u8 *pmem);
47441 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47442 u8 *pmem);
47443 -};
47444 +} __no_const;
47445
47446 struct io_req {
47447 struct list_head list;
47448 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47449 index 1f5088b..0e59820 100644
47450 --- a/drivers/staging/sbe-2t3e3/netdev.c
47451 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47452 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47453 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47454
47455 if (rlen)
47456 - if (copy_to_user(data, &resp, rlen))
47457 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47458 return -EFAULT;
47459
47460 return 0;
47461 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47462 index a863a98..d272795 100644
47463 --- a/drivers/staging/usbip/vhci.h
47464 +++ b/drivers/staging/usbip/vhci.h
47465 @@ -83,7 +83,7 @@ struct vhci_hcd {
47466 unsigned resuming:1;
47467 unsigned long re_timeout;
47468
47469 - atomic_t seqnum;
47470 + atomic_unchecked_t seqnum;
47471
47472 /*
47473 * NOTE:
47474 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47475 index d7974cb..d78076b 100644
47476 --- a/drivers/staging/usbip/vhci_hcd.c
47477 +++ b/drivers/staging/usbip/vhci_hcd.c
47478 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47479
47480 spin_lock(&vdev->priv_lock);
47481
47482 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47483 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47484 if (priv->seqnum == 0xffff)
47485 dev_info(&urb->dev->dev, "seqnum max\n");
47486
47487 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47488 return -ENOMEM;
47489 }
47490
47491 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47492 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47493 if (unlink->seqnum == 0xffff)
47494 pr_info("seqnum max\n");
47495
47496 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47497 vdev->rhport = rhport;
47498 }
47499
47500 - atomic_set(&vhci->seqnum, 0);
47501 + atomic_set_unchecked(&vhci->seqnum, 0);
47502 spin_lock_init(&vhci->lock);
47503
47504 hcd->power_budget = 0; /* no limit */
47505 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47506 index d07fcb5..358e1e1 100644
47507 --- a/drivers/staging/usbip/vhci_rx.c
47508 +++ b/drivers/staging/usbip/vhci_rx.c
47509 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47510 if (!urb) {
47511 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47512 pr_info("max seqnum %d\n",
47513 - atomic_read(&the_controller->seqnum));
47514 + atomic_read_unchecked(&the_controller->seqnum));
47515 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47516 return;
47517 }
47518 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47519 index 57a08c5..5b4bb7c 100644
47520 --- a/drivers/staging/vt6655/hostap.c
47521 +++ b/drivers/staging/vt6655/hostap.c
47522 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47523 *
47524 */
47525
47526 +static net_device_ops_no_const apdev_netdev_ops;
47527 +
47528 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47529 {
47530 PSDevice apdev_priv;
47531 struct net_device *dev = pDevice->dev;
47532 int ret;
47533 - const struct net_device_ops apdev_netdev_ops = {
47534 - .ndo_start_xmit = pDevice->tx_80211,
47535 - };
47536
47537 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47538
47539 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47540 *apdev_priv = *pDevice;
47541 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47542
47543 + /* only half broken now */
47544 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47545 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47546
47547 pDevice->apdev->type = ARPHRD_IEEE80211;
47548 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47549 index c699a30..b90a5fd 100644
47550 --- a/drivers/staging/vt6656/hostap.c
47551 +++ b/drivers/staging/vt6656/hostap.c
47552 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47553 *
47554 */
47555
47556 +static net_device_ops_no_const apdev_netdev_ops;
47557 +
47558 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47559 {
47560 struct vnt_private *apdev_priv;
47561 struct net_device *dev = pDevice->dev;
47562 int ret;
47563 - const struct net_device_ops apdev_netdev_ops = {
47564 - .ndo_start_xmit = pDevice->tx_80211,
47565 - };
47566
47567 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47568
47569 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47570 *apdev_priv = *pDevice;
47571 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47572
47573 + /* only half broken now */
47574 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47575 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47576
47577 pDevice->apdev->type = ARPHRD_IEEE80211;
47578 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47579 index d128ce2..fc1f9a1 100644
47580 --- a/drivers/staging/zcache/tmem.h
47581 +++ b/drivers/staging/zcache/tmem.h
47582 @@ -225,7 +225,7 @@ struct tmem_pamops {
47583 bool (*is_remote)(void *);
47584 int (*replace_in_obj)(void *, struct tmem_obj *);
47585 #endif
47586 -};
47587 +} __no_const;
47588 extern void tmem_register_pamops(struct tmem_pamops *m);
47589
47590 /* memory allocation methods provided by the host implementation */
47591 @@ -234,7 +234,7 @@ struct tmem_hostops {
47592 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47593 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47594 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47595 -};
47596 +} __no_const;
47597 extern void tmem_register_hostops(struct tmem_hostops *m);
47598
47599 /* core tmem accessor functions */
47600 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47601 index e51b09a..5ebac31 100644
47602 --- a/drivers/target/sbp/sbp_target.c
47603 +++ b/drivers/target/sbp/sbp_target.c
47604 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47605
47606 #define SESSION_MAINTENANCE_INTERVAL HZ
47607
47608 -static atomic_t login_id = ATOMIC_INIT(0);
47609 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47610
47611 static void session_maintenance_work(struct work_struct *);
47612 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47613 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47614 login->lun = se_lun;
47615 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47616 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47617 - login->login_id = atomic_inc_return(&login_id);
47618 + login->login_id = atomic_inc_return_unchecked(&login_id);
47619
47620 login->tgt_agt = sbp_target_agent_register(login);
47621 if (IS_ERR(login->tgt_agt)) {
47622 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47623 index 8f4142f..b127f7d 100644
47624 --- a/drivers/target/target_core_device.c
47625 +++ b/drivers/target/target_core_device.c
47626 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47627 spin_lock_init(&dev->se_port_lock);
47628 spin_lock_init(&dev->se_tmr_lock);
47629 spin_lock_init(&dev->qf_cmd_lock);
47630 - atomic_set(&dev->dev_ordered_id, 0);
47631 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47632 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47633 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47634 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47635 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47636 index d8e49d7..6fcfdec 100644
47637 --- a/drivers/target/target_core_transport.c
47638 +++ b/drivers/target/target_core_transport.c
47639 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47640 * Used to determine when ORDERED commands should go from
47641 * Dormant to Active status.
47642 */
47643 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47644 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47645 smp_mb__after_atomic_inc();
47646 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47647 cmd->se_ordered_id, cmd->sam_task_attr,
47648 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47649 index 33f83fe..d80f8e1 100644
47650 --- a/drivers/tty/cyclades.c
47651 +++ b/drivers/tty/cyclades.c
47652 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47653 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47654 info->port.count);
47655 #endif
47656 - info->port.count++;
47657 + atomic_inc(&info->port.count);
47658 #ifdef CY_DEBUG_COUNT
47659 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47660 - current->pid, info->port.count);
47661 + current->pid, atomic_read(&info->port.count));
47662 #endif
47663
47664 /*
47665 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47666 for (j = 0; j < cy_card[i].nports; j++) {
47667 info = &cy_card[i].ports[j];
47668
47669 - if (info->port.count) {
47670 + if (atomic_read(&info->port.count)) {
47671 /* XXX is the ldisc num worth this? */
47672 struct tty_struct *tty;
47673 struct tty_ldisc *ld;
47674 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47675 index eb255e8..f637a57 100644
47676 --- a/drivers/tty/hvc/hvc_console.c
47677 +++ b/drivers/tty/hvc/hvc_console.c
47678 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47679
47680 spin_lock_irqsave(&hp->port.lock, flags);
47681 /* Check and then increment for fast path open. */
47682 - if (hp->port.count++ > 0) {
47683 + if (atomic_inc_return(&hp->port.count) > 1) {
47684 spin_unlock_irqrestore(&hp->port.lock, flags);
47685 hvc_kick();
47686 return 0;
47687 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47688
47689 spin_lock_irqsave(&hp->port.lock, flags);
47690
47691 - if (--hp->port.count == 0) {
47692 + if (atomic_dec_return(&hp->port.count) == 0) {
47693 spin_unlock_irqrestore(&hp->port.lock, flags);
47694 /* We are done with the tty pointer now. */
47695 tty_port_tty_set(&hp->port, NULL);
47696 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47697 */
47698 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47699 } else {
47700 - if (hp->port.count < 0)
47701 + if (atomic_read(&hp->port.count) < 0)
47702 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47703 - hp->vtermno, hp->port.count);
47704 + hp->vtermno, atomic_read(&hp->port.count));
47705 spin_unlock_irqrestore(&hp->port.lock, flags);
47706 }
47707 }
47708 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47709 * open->hangup case this can be called after the final close so prevent
47710 * that from happening for now.
47711 */
47712 - if (hp->port.count <= 0) {
47713 + if (atomic_read(&hp->port.count) <= 0) {
47714 spin_unlock_irqrestore(&hp->port.lock, flags);
47715 return;
47716 }
47717
47718 - hp->port.count = 0;
47719 + atomic_set(&hp->port.count, 0);
47720 spin_unlock_irqrestore(&hp->port.lock, flags);
47721 tty_port_tty_set(&hp->port, NULL);
47722
47723 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47724 return -EPIPE;
47725
47726 /* FIXME what's this (unprotected) check for? */
47727 - if (hp->port.count <= 0)
47728 + if (atomic_read(&hp->port.count) <= 0)
47729 return -EIO;
47730
47731 spin_lock_irqsave(&hp->lock, flags);
47732 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47733 index 81e939e..95ead10 100644
47734 --- a/drivers/tty/hvc/hvcs.c
47735 +++ b/drivers/tty/hvc/hvcs.c
47736 @@ -83,6 +83,7 @@
47737 #include <asm/hvcserver.h>
47738 #include <asm/uaccess.h>
47739 #include <asm/vio.h>
47740 +#include <asm/local.h>
47741
47742 /*
47743 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47744 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47745
47746 spin_lock_irqsave(&hvcsd->lock, flags);
47747
47748 - if (hvcsd->port.count > 0) {
47749 + if (atomic_read(&hvcsd->port.count) > 0) {
47750 spin_unlock_irqrestore(&hvcsd->lock, flags);
47751 printk(KERN_INFO "HVCS: vterm state unchanged. "
47752 "The hvcs device node is still in use.\n");
47753 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47754 }
47755 }
47756
47757 - hvcsd->port.count = 0;
47758 + atomic_set(&hvcsd->port.count, 0);
47759 hvcsd->port.tty = tty;
47760 tty->driver_data = hvcsd;
47761
47762 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47763 unsigned long flags;
47764
47765 spin_lock_irqsave(&hvcsd->lock, flags);
47766 - hvcsd->port.count++;
47767 + atomic_inc(&hvcsd->port.count);
47768 hvcsd->todo_mask |= HVCS_SCHED_READ;
47769 spin_unlock_irqrestore(&hvcsd->lock, flags);
47770
47771 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47772 hvcsd = tty->driver_data;
47773
47774 spin_lock_irqsave(&hvcsd->lock, flags);
47775 - if (--hvcsd->port.count == 0) {
47776 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47777
47778 vio_disable_interrupts(hvcsd->vdev);
47779
47780 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47781
47782 free_irq(irq, hvcsd);
47783 return;
47784 - } else if (hvcsd->port.count < 0) {
47785 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47786 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47787 " is missmanaged.\n",
47788 - hvcsd->vdev->unit_address, hvcsd->port.count);
47789 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47790 }
47791
47792 spin_unlock_irqrestore(&hvcsd->lock, flags);
47793 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47794
47795 spin_lock_irqsave(&hvcsd->lock, flags);
47796 /* Preserve this so that we know how many kref refs to put */
47797 - temp_open_count = hvcsd->port.count;
47798 + temp_open_count = atomic_read(&hvcsd->port.count);
47799
47800 /*
47801 * Don't kref put inside the spinlock because the destruction
47802 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47803 tty->driver_data = NULL;
47804 hvcsd->port.tty = NULL;
47805
47806 - hvcsd->port.count = 0;
47807 + atomic_set(&hvcsd->port.count, 0);
47808
47809 /* This will drop any buffered data on the floor which is OK in a hangup
47810 * scenario. */
47811 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47812 * the middle of a write operation? This is a crummy place to do this
47813 * but we want to keep it all in the spinlock.
47814 */
47815 - if (hvcsd->port.count <= 0) {
47816 + if (atomic_read(&hvcsd->port.count) <= 0) {
47817 spin_unlock_irqrestore(&hvcsd->lock, flags);
47818 return -ENODEV;
47819 }
47820 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47821 {
47822 struct hvcs_struct *hvcsd = tty->driver_data;
47823
47824 - if (!hvcsd || hvcsd->port.count <= 0)
47825 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47826 return 0;
47827
47828 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47829 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47830 index 4190199..48f2920 100644
47831 --- a/drivers/tty/hvc/hvsi.c
47832 +++ b/drivers/tty/hvc/hvsi.c
47833 @@ -85,7 +85,7 @@ struct hvsi_struct {
47834 int n_outbuf;
47835 uint32_t vtermno;
47836 uint32_t virq;
47837 - atomic_t seqno; /* HVSI packet sequence number */
47838 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47839 uint16_t mctrl;
47840 uint8_t state; /* HVSI protocol state */
47841 uint8_t flags;
47842 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47843
47844 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47845 packet.hdr.len = sizeof(struct hvsi_query_response);
47846 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47847 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47848 packet.verb = VSV_SEND_VERSION_NUMBER;
47849 packet.u.version = HVSI_VERSION;
47850 packet.query_seqno = query_seqno+1;
47851 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47852
47853 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47854 packet.hdr.len = sizeof(struct hvsi_query);
47855 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47856 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47857 packet.verb = verb;
47858
47859 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47860 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47861 int wrote;
47862
47863 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47864 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47865 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47866 packet.hdr.len = sizeof(struct hvsi_control);
47867 packet.verb = VSV_SET_MODEM_CTL;
47868 packet.mask = HVSI_TSDTR;
47869 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47870 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47871
47872 packet.hdr.type = VS_DATA_PACKET_HEADER;
47873 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47874 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47875 packet.hdr.len = count + sizeof(struct hvsi_header);
47876 memcpy(&packet.data, buf, count);
47877
47878 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47879 struct hvsi_control packet __ALIGNED__;
47880
47881 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47882 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47883 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47884 packet.hdr.len = 6;
47885 packet.verb = VSV_CLOSE_PROTOCOL;
47886
47887 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47888 index ac27671..0f627ee 100644
47889 --- a/drivers/tty/hvc/hvsi_lib.c
47890 +++ b/drivers/tty/hvc/hvsi_lib.c
47891 @@ -9,7 +9,7 @@
47892
47893 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47894 {
47895 - packet->seqno = atomic_inc_return(&pv->seqno);
47896 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47897
47898 /* Assumes that always succeeds, works in practice */
47899 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47900 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47901
47902 /* Reset state */
47903 pv->established = 0;
47904 - atomic_set(&pv->seqno, 0);
47905 + atomic_set_unchecked(&pv->seqno, 0);
47906
47907 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47908
47909 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47910 pv->mctrl_update = 0;
47911 q.hdr.type = VS_QUERY_PACKET_HEADER;
47912 q.hdr.len = sizeof(struct hvsi_query);
47913 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47914 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47915 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47916 rc = hvsi_send_packet(pv, &q.hdr);
47917 if (rc <= 0) {
47918 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47919 index 8fd72ff..34a0bed 100644
47920 --- a/drivers/tty/ipwireless/tty.c
47921 +++ b/drivers/tty/ipwireless/tty.c
47922 @@ -29,6 +29,7 @@
47923 #include <linux/tty_driver.h>
47924 #include <linux/tty_flip.h>
47925 #include <linux/uaccess.h>
47926 +#include <asm/local.h>
47927
47928 #include "tty.h"
47929 #include "network.h"
47930 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47931 mutex_unlock(&tty->ipw_tty_mutex);
47932 return -ENODEV;
47933 }
47934 - if (tty->port.count == 0)
47935 + if (atomic_read(&tty->port.count) == 0)
47936 tty->tx_bytes_queued = 0;
47937
47938 - tty->port.count++;
47939 + atomic_inc(&tty->port.count);
47940
47941 tty->port.tty = linux_tty;
47942 linux_tty->driver_data = tty;
47943 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47944
47945 static void do_ipw_close(struct ipw_tty *tty)
47946 {
47947 - tty->port.count--;
47948 -
47949 - if (tty->port.count == 0) {
47950 + if (atomic_dec_return(&tty->port.count) == 0) {
47951 struct tty_struct *linux_tty = tty->port.tty;
47952
47953 if (linux_tty != NULL) {
47954 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47955 return;
47956
47957 mutex_lock(&tty->ipw_tty_mutex);
47958 - if (tty->port.count == 0) {
47959 + if (atomic_read(&tty->port.count) == 0) {
47960 mutex_unlock(&tty->ipw_tty_mutex);
47961 return;
47962 }
47963 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47964
47965 mutex_lock(&tty->ipw_tty_mutex);
47966
47967 - if (!tty->port.count) {
47968 + if (!atomic_read(&tty->port.count)) {
47969 mutex_unlock(&tty->ipw_tty_mutex);
47970 return;
47971 }
47972 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47973 return -ENODEV;
47974
47975 mutex_lock(&tty->ipw_tty_mutex);
47976 - if (!tty->port.count) {
47977 + if (!atomic_read(&tty->port.count)) {
47978 mutex_unlock(&tty->ipw_tty_mutex);
47979 return -EINVAL;
47980 }
47981 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47982 if (!tty)
47983 return -ENODEV;
47984
47985 - if (!tty->port.count)
47986 + if (!atomic_read(&tty->port.count))
47987 return -EINVAL;
47988
47989 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47990 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47991 if (!tty)
47992 return 0;
47993
47994 - if (!tty->port.count)
47995 + if (!atomic_read(&tty->port.count))
47996 return 0;
47997
47998 return tty->tx_bytes_queued;
47999 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
48000 if (!tty)
48001 return -ENODEV;
48002
48003 - if (!tty->port.count)
48004 + if (!atomic_read(&tty->port.count))
48005 return -EINVAL;
48006
48007 return get_control_lines(tty);
48008 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
48009 if (!tty)
48010 return -ENODEV;
48011
48012 - if (!tty->port.count)
48013 + if (!atomic_read(&tty->port.count))
48014 return -EINVAL;
48015
48016 return set_control_lines(tty, set, clear);
48017 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
48018 if (!tty)
48019 return -ENODEV;
48020
48021 - if (!tty->port.count)
48022 + if (!atomic_read(&tty->port.count))
48023 return -EINVAL;
48024
48025 /* FIXME: Exactly how is the tty object locked here .. */
48026 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
48027 * are gone */
48028 mutex_lock(&ttyj->ipw_tty_mutex);
48029 }
48030 - while (ttyj->port.count)
48031 + while (atomic_read(&ttyj->port.count))
48032 do_ipw_close(ttyj);
48033 ipwireless_disassociate_network_ttys(network,
48034 ttyj->channel_idx);
48035 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
48036 index 1deaca4..c8582d4 100644
48037 --- a/drivers/tty/moxa.c
48038 +++ b/drivers/tty/moxa.c
48039 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
48040 }
48041
48042 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
48043 - ch->port.count++;
48044 + atomic_inc(&ch->port.count);
48045 tty->driver_data = ch;
48046 tty_port_tty_set(&ch->port, tty);
48047 mutex_lock(&ch->port.mutex);
48048 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
48049 index 6422390..49003ac8 100644
48050 --- a/drivers/tty/n_gsm.c
48051 +++ b/drivers/tty/n_gsm.c
48052 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
48053 spin_lock_init(&dlci->lock);
48054 mutex_init(&dlci->mutex);
48055 dlci->fifo = &dlci->_fifo;
48056 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
48057 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
48058 kfree(dlci);
48059 return NULL;
48060 }
48061 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
48062 struct gsm_dlci *dlci = tty->driver_data;
48063 struct tty_port *port = &dlci->port;
48064
48065 - port->count++;
48066 + atomic_inc(&port->count);
48067 dlci_get(dlci);
48068 dlci_get(dlci->gsm->dlci[0]);
48069 mux_get(dlci->gsm);
48070 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
48071 index 4bf0fc0..433bd58 100644
48072 --- a/drivers/tty/n_tty.c
48073 +++ b/drivers/tty/n_tty.c
48074 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
48075 {
48076 *ops = tty_ldisc_N_TTY;
48077 ops->owner = NULL;
48078 - ops->refcount = ops->flags = 0;
48079 + atomic_set(&ops->refcount, 0);
48080 + ops->flags = 0;
48081 }
48082 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
48083 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
48084 index abfd990..5ab5da9 100644
48085 --- a/drivers/tty/pty.c
48086 +++ b/drivers/tty/pty.c
48087 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
48088 panic("Couldn't register Unix98 pts driver");
48089
48090 /* Now create the /dev/ptmx special device */
48091 + pax_open_kernel();
48092 tty_default_fops(&ptmx_fops);
48093 - ptmx_fops.open = ptmx_open;
48094 + *(void **)&ptmx_fops.open = ptmx_open;
48095 + pax_close_kernel();
48096
48097 cdev_init(&ptmx_cdev, &ptmx_fops);
48098 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
48099 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
48100 index 354564e..fe50d9a 100644
48101 --- a/drivers/tty/rocket.c
48102 +++ b/drivers/tty/rocket.c
48103 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48104 tty->driver_data = info;
48105 tty_port_tty_set(port, tty);
48106
48107 - if (port->count++ == 0) {
48108 + if (atomic_inc_return(&port->count) == 1) {
48109 atomic_inc(&rp_num_ports_open);
48110
48111 #ifdef ROCKET_DEBUG_OPEN
48112 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48113 #endif
48114 }
48115 #ifdef ROCKET_DEBUG_OPEN
48116 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
48117 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
48118 #endif
48119
48120 /*
48121 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
48122 spin_unlock_irqrestore(&info->port.lock, flags);
48123 return;
48124 }
48125 - if (info->port.count)
48126 + if (atomic_read(&info->port.count))
48127 atomic_dec(&rp_num_ports_open);
48128 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
48129 spin_unlock_irqrestore(&info->port.lock, flags);
48130 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
48131 index e2520ab..034e20b 100644
48132 --- a/drivers/tty/serial/ioc4_serial.c
48133 +++ b/drivers/tty/serial/ioc4_serial.c
48134 @@ -437,7 +437,7 @@ struct ioc4_soft {
48135 } is_intr_info[MAX_IOC4_INTR_ENTS];
48136
48137 /* Number of entries active in the above array */
48138 - atomic_t is_num_intrs;
48139 + atomic_unchecked_t is_num_intrs;
48140 } is_intr_type[IOC4_NUM_INTR_TYPES];
48141
48142 /* is_ir_lock must be held while
48143 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
48144 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
48145 || (type == IOC4_OTHER_INTR_TYPE)));
48146
48147 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
48148 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48149 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48150
48151 /* Save off the lower level interrupt handler */
48152 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48153
48154 soft = arg;
48155 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48156 - num_intrs = (int)atomic_read(
48157 + num_intrs = (int)atomic_read_unchecked(
48158 &soft->is_intr_type[intr_type].is_num_intrs);
48159
48160 this_mir = this_ir = pending_intrs(soft, intr_type);
48161 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48162 index 1002054..dd644a8 100644
48163 --- a/drivers/tty/serial/kgdboc.c
48164 +++ b/drivers/tty/serial/kgdboc.c
48165 @@ -24,8 +24,9 @@
48166 #define MAX_CONFIG_LEN 40
48167
48168 static struct kgdb_io kgdboc_io_ops;
48169 +static struct kgdb_io kgdboc_io_ops_console;
48170
48171 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48172 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48173 static int configured = -1;
48174
48175 static char config[MAX_CONFIG_LEN];
48176 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48177 kgdboc_unregister_kbd();
48178 if (configured == 1)
48179 kgdb_unregister_io_module(&kgdboc_io_ops);
48180 + else if (configured == 2)
48181 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48182 }
48183
48184 static int configure_kgdboc(void)
48185 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48186 int err;
48187 char *cptr = config;
48188 struct console *cons;
48189 + int is_console = 0;
48190
48191 err = kgdboc_option_setup(config);
48192 if (err || !strlen(config) || isspace(config[0]))
48193 goto noconfig;
48194
48195 err = -ENODEV;
48196 - kgdboc_io_ops.is_console = 0;
48197 kgdb_tty_driver = NULL;
48198
48199 kgdboc_use_kms = 0;
48200 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48201 int idx;
48202 if (cons->device && cons->device(cons, &idx) == p &&
48203 idx == tty_line) {
48204 - kgdboc_io_ops.is_console = 1;
48205 + is_console = 1;
48206 break;
48207 }
48208 cons = cons->next;
48209 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48210 kgdb_tty_line = tty_line;
48211
48212 do_register:
48213 - err = kgdb_register_io_module(&kgdboc_io_ops);
48214 + if (is_console) {
48215 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48216 + configured = 2;
48217 + } else {
48218 + err = kgdb_register_io_module(&kgdboc_io_ops);
48219 + configured = 1;
48220 + }
48221 if (err)
48222 goto noconfig;
48223
48224 @@ -205,8 +214,6 @@ do_register:
48225 if (err)
48226 goto nmi_con_failed;
48227
48228 - configured = 1;
48229 -
48230 return 0;
48231
48232 nmi_con_failed:
48233 @@ -223,7 +230,7 @@ noconfig:
48234 static int __init init_kgdboc(void)
48235 {
48236 /* Already configured? */
48237 - if (configured == 1)
48238 + if (configured >= 1)
48239 return 0;
48240
48241 return configure_kgdboc();
48242 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48243 if (config[len - 1] == '\n')
48244 config[len - 1] = '\0';
48245
48246 - if (configured == 1)
48247 + if (configured >= 1)
48248 cleanup_kgdboc();
48249
48250 /* Go and configure with the new params. */
48251 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48252 .post_exception = kgdboc_post_exp_handler,
48253 };
48254
48255 +static struct kgdb_io kgdboc_io_ops_console = {
48256 + .name = "kgdboc",
48257 + .read_char = kgdboc_get_char,
48258 + .write_char = kgdboc_put_char,
48259 + .pre_exception = kgdboc_pre_exp_handler,
48260 + .post_exception = kgdboc_post_exp_handler,
48261 + .is_console = 1
48262 +};
48263 +
48264 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48265 /* This is only available if kgdboc is a built in for early debugging */
48266 static int __init kgdboc_early_init(char *opt)
48267 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48268 index 2c6cfb3..048274e 100644
48269 --- a/drivers/tty/serial/msm_serial.c
48270 +++ b/drivers/tty/serial/msm_serial.c
48271 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48272 .cons = MSM_CONSOLE,
48273 };
48274
48275 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48276 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48277
48278 static int __init msm_serial_probe(struct platform_device *pdev)
48279 {
48280 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48281 int irq;
48282
48283 if (pdev->id == -1)
48284 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48285 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48286
48287 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48288 return -ENXIO;
48289 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48290 index 376079b..d8de7aa 100644
48291 --- a/drivers/tty/serial/samsung.c
48292 +++ b/drivers/tty/serial/samsung.c
48293 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48294 }
48295 }
48296
48297 +static int s3c64xx_serial_startup(struct uart_port *port);
48298 static int s3c24xx_serial_startup(struct uart_port *port)
48299 {
48300 struct s3c24xx_uart_port *ourport = to_ourport(port);
48301 int ret;
48302
48303 + /* Startup sequence is different for s3c64xx and higher SoC's */
48304 + if (s3c24xx_serial_has_interrupt_mask(port))
48305 + return s3c64xx_serial_startup(port);
48306 +
48307 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48308 port->mapbase, port->membase);
48309
48310 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48311 /* setup info for port */
48312 port->dev = &platdev->dev;
48313
48314 - /* Startup sequence is different for s3c64xx and higher SoC's */
48315 - if (s3c24xx_serial_has_interrupt_mask(port))
48316 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48317 -
48318 port->uartclk = 1;
48319
48320 if (cfg->uart_flags & UPF_CONS_FLOW) {
48321 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48322 index 28cdd28..56f1d60 100644
48323 --- a/drivers/tty/serial/serial_core.c
48324 +++ b/drivers/tty/serial/serial_core.c
48325 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48326 uart_flush_buffer(tty);
48327 uart_shutdown(tty, state);
48328 spin_lock_irqsave(&port->lock, flags);
48329 - port->count = 0;
48330 + atomic_set(&port->count, 0);
48331 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48332 spin_unlock_irqrestore(&port->lock, flags);
48333 tty_port_tty_set(port, NULL);
48334 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48335 goto end;
48336 }
48337
48338 - port->count++;
48339 + atomic_inc(&port->count);
48340 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48341 retval = -ENXIO;
48342 goto err_dec_count;
48343 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48344 /*
48345 * Make sure the device is in D0 state.
48346 */
48347 - if (port->count == 1)
48348 + if (atomic_read(&port->count) == 1)
48349 uart_change_pm(state, UART_PM_STATE_ON);
48350
48351 /*
48352 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48353 end:
48354 return retval;
48355 err_dec_count:
48356 - port->count--;
48357 + atomic_inc(&port->count);
48358 mutex_unlock(&port->mutex);
48359 goto end;
48360 }
48361 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48362 index 8eaf1ab..85c030d 100644
48363 --- a/drivers/tty/synclink.c
48364 +++ b/drivers/tty/synclink.c
48365 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48366
48367 if (debug_level >= DEBUG_LEVEL_INFO)
48368 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48369 - __FILE__,__LINE__, info->device_name, info->port.count);
48370 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48371
48372 if (tty_port_close_start(&info->port, tty, filp) == 0)
48373 goto cleanup;
48374 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48375 cleanup:
48376 if (debug_level >= DEBUG_LEVEL_INFO)
48377 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48378 - tty->driver->name, info->port.count);
48379 + tty->driver->name, atomic_read(&info->port.count));
48380
48381 } /* end of mgsl_close() */
48382
48383 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48384
48385 mgsl_flush_buffer(tty);
48386 shutdown(info);
48387 -
48388 - info->port.count = 0;
48389 +
48390 + atomic_set(&info->port.count, 0);
48391 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48392 info->port.tty = NULL;
48393
48394 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48395
48396 if (debug_level >= DEBUG_LEVEL_INFO)
48397 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48398 - __FILE__,__LINE__, tty->driver->name, port->count );
48399 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48400
48401 spin_lock_irqsave(&info->irq_spinlock, flags);
48402 if (!tty_hung_up_p(filp)) {
48403 extra_count = true;
48404 - port->count--;
48405 + atomic_dec(&port->count);
48406 }
48407 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48408 port->blocked_open++;
48409 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48410
48411 if (debug_level >= DEBUG_LEVEL_INFO)
48412 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48413 - __FILE__,__LINE__, tty->driver->name, port->count );
48414 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48415
48416 tty_unlock(tty);
48417 schedule();
48418 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48419
48420 /* FIXME: Racy on hangup during close wait */
48421 if (extra_count)
48422 - port->count++;
48423 + atomic_inc(&port->count);
48424 port->blocked_open--;
48425
48426 if (debug_level >= DEBUG_LEVEL_INFO)
48427 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48428 - __FILE__,__LINE__, tty->driver->name, port->count );
48429 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48430
48431 if (!retval)
48432 port->flags |= ASYNC_NORMAL_ACTIVE;
48433 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48434
48435 if (debug_level >= DEBUG_LEVEL_INFO)
48436 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48437 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48438 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48439
48440 /* If port is closing, signal caller to try again */
48441 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48442 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48443 spin_unlock_irqrestore(&info->netlock, flags);
48444 goto cleanup;
48445 }
48446 - info->port.count++;
48447 + atomic_inc(&info->port.count);
48448 spin_unlock_irqrestore(&info->netlock, flags);
48449
48450 - if (info->port.count == 1) {
48451 + if (atomic_read(&info->port.count) == 1) {
48452 /* 1st open on this device, init hardware */
48453 retval = startup(info);
48454 if (retval < 0)
48455 @@ -3446,8 +3446,8 @@ cleanup:
48456 if (retval) {
48457 if (tty->count == 1)
48458 info->port.tty = NULL; /* tty layer will release tty struct */
48459 - if(info->port.count)
48460 - info->port.count--;
48461 + if (atomic_read(&info->port.count))
48462 + atomic_dec(&info->port.count);
48463 }
48464
48465 return retval;
48466 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48467 unsigned short new_crctype;
48468
48469 /* return error if TTY interface open */
48470 - if (info->port.count)
48471 + if (atomic_read(&info->port.count))
48472 return -EBUSY;
48473
48474 switch (encoding)
48475 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48476
48477 /* arbitrate between network and tty opens */
48478 spin_lock_irqsave(&info->netlock, flags);
48479 - if (info->port.count != 0 || info->netcount != 0) {
48480 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48481 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48482 spin_unlock_irqrestore(&info->netlock, flags);
48483 return -EBUSY;
48484 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48485 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48486
48487 /* return error if TTY interface open */
48488 - if (info->port.count)
48489 + if (atomic_read(&info->port.count))
48490 return -EBUSY;
48491
48492 if (cmd != SIOCWANDEV)
48493 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48494 index 1abf946..1ee34fc 100644
48495 --- a/drivers/tty/synclink_gt.c
48496 +++ b/drivers/tty/synclink_gt.c
48497 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48498 tty->driver_data = info;
48499 info->port.tty = tty;
48500
48501 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48502 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48503
48504 /* If port is closing, signal caller to try again */
48505 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48506 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48507 mutex_unlock(&info->port.mutex);
48508 goto cleanup;
48509 }
48510 - info->port.count++;
48511 + atomic_inc(&info->port.count);
48512 spin_unlock_irqrestore(&info->netlock, flags);
48513
48514 - if (info->port.count == 1) {
48515 + if (atomic_read(&info->port.count) == 1) {
48516 /* 1st open on this device, init hardware */
48517 retval = startup(info);
48518 if (retval < 0) {
48519 @@ -715,8 +715,8 @@ cleanup:
48520 if (retval) {
48521 if (tty->count == 1)
48522 info->port.tty = NULL; /* tty layer will release tty struct */
48523 - if(info->port.count)
48524 - info->port.count--;
48525 + if(atomic_read(&info->port.count))
48526 + atomic_dec(&info->port.count);
48527 }
48528
48529 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48530 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48531
48532 if (sanity_check(info, tty->name, "close"))
48533 return;
48534 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48535 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48536
48537 if (tty_port_close_start(&info->port, tty, filp) == 0)
48538 goto cleanup;
48539 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48540 tty_port_close_end(&info->port, tty);
48541 info->port.tty = NULL;
48542 cleanup:
48543 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48544 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48545 }
48546
48547 static void hangup(struct tty_struct *tty)
48548 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48549 shutdown(info);
48550
48551 spin_lock_irqsave(&info->port.lock, flags);
48552 - info->port.count = 0;
48553 + atomic_set(&info->port.count, 0);
48554 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48555 info->port.tty = NULL;
48556 spin_unlock_irqrestore(&info->port.lock, flags);
48557 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48558 unsigned short new_crctype;
48559
48560 /* return error if TTY interface open */
48561 - if (info->port.count)
48562 + if (atomic_read(&info->port.count))
48563 return -EBUSY;
48564
48565 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48566 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48567
48568 /* arbitrate between network and tty opens */
48569 spin_lock_irqsave(&info->netlock, flags);
48570 - if (info->port.count != 0 || info->netcount != 0) {
48571 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48572 DBGINFO(("%s hdlc_open busy\n", dev->name));
48573 spin_unlock_irqrestore(&info->netlock, flags);
48574 return -EBUSY;
48575 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48576 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48577
48578 /* return error if TTY interface open */
48579 - if (info->port.count)
48580 + if (atomic_read(&info->port.count))
48581 return -EBUSY;
48582
48583 if (cmd != SIOCWANDEV)
48584 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48585 if (port == NULL)
48586 continue;
48587 spin_lock(&port->lock);
48588 - if ((port->port.count || port->netcount) &&
48589 + if ((atomic_read(&port->port.count) || port->netcount) &&
48590 port->pending_bh && !port->bh_running &&
48591 !port->bh_requested) {
48592 DBGISR(("%s bh queued\n", port->device_name));
48593 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48594 spin_lock_irqsave(&info->lock, flags);
48595 if (!tty_hung_up_p(filp)) {
48596 extra_count = true;
48597 - port->count--;
48598 + atomic_dec(&port->count);
48599 }
48600 spin_unlock_irqrestore(&info->lock, flags);
48601 port->blocked_open++;
48602 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48603 remove_wait_queue(&port->open_wait, &wait);
48604
48605 if (extra_count)
48606 - port->count++;
48607 + atomic_inc(&port->count);
48608 port->blocked_open--;
48609
48610 if (!retval)
48611 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48612 index dc6e969..5dc8786 100644
48613 --- a/drivers/tty/synclinkmp.c
48614 +++ b/drivers/tty/synclinkmp.c
48615 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48616
48617 if (debug_level >= DEBUG_LEVEL_INFO)
48618 printk("%s(%d):%s open(), old ref count = %d\n",
48619 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48620 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48621
48622 /* If port is closing, signal caller to try again */
48623 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48624 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48625 spin_unlock_irqrestore(&info->netlock, flags);
48626 goto cleanup;
48627 }
48628 - info->port.count++;
48629 + atomic_inc(&info->port.count);
48630 spin_unlock_irqrestore(&info->netlock, flags);
48631
48632 - if (info->port.count == 1) {
48633 + if (atomic_read(&info->port.count) == 1) {
48634 /* 1st open on this device, init hardware */
48635 retval = startup(info);
48636 if (retval < 0)
48637 @@ -796,8 +796,8 @@ cleanup:
48638 if (retval) {
48639 if (tty->count == 1)
48640 info->port.tty = NULL; /* tty layer will release tty struct */
48641 - if(info->port.count)
48642 - info->port.count--;
48643 + if(atomic_read(&info->port.count))
48644 + atomic_dec(&info->port.count);
48645 }
48646
48647 return retval;
48648 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48649
48650 if (debug_level >= DEBUG_LEVEL_INFO)
48651 printk("%s(%d):%s close() entry, count=%d\n",
48652 - __FILE__,__LINE__, info->device_name, info->port.count);
48653 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48654
48655 if (tty_port_close_start(&info->port, tty, filp) == 0)
48656 goto cleanup;
48657 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48658 cleanup:
48659 if (debug_level >= DEBUG_LEVEL_INFO)
48660 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48661 - tty->driver->name, info->port.count);
48662 + tty->driver->name, atomic_read(&info->port.count));
48663 }
48664
48665 /* Called by tty_hangup() when a hangup is signaled.
48666 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48667 shutdown(info);
48668
48669 spin_lock_irqsave(&info->port.lock, flags);
48670 - info->port.count = 0;
48671 + atomic_set(&info->port.count, 0);
48672 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48673 info->port.tty = NULL;
48674 spin_unlock_irqrestore(&info->port.lock, flags);
48675 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48676 unsigned short new_crctype;
48677
48678 /* return error if TTY interface open */
48679 - if (info->port.count)
48680 + if (atomic_read(&info->port.count))
48681 return -EBUSY;
48682
48683 switch (encoding)
48684 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48685
48686 /* arbitrate between network and tty opens */
48687 spin_lock_irqsave(&info->netlock, flags);
48688 - if (info->port.count != 0 || info->netcount != 0) {
48689 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48690 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48691 spin_unlock_irqrestore(&info->netlock, flags);
48692 return -EBUSY;
48693 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48694 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48695
48696 /* return error if TTY interface open */
48697 - if (info->port.count)
48698 + if (atomic_read(&info->port.count))
48699 return -EBUSY;
48700
48701 if (cmd != SIOCWANDEV)
48702 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48703 * do not request bottom half processing if the
48704 * device is not open in a normal mode.
48705 */
48706 - if ( port && (port->port.count || port->netcount) &&
48707 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48708 port->pending_bh && !port->bh_running &&
48709 !port->bh_requested ) {
48710 if ( debug_level >= DEBUG_LEVEL_ISR )
48711 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48712
48713 if (debug_level >= DEBUG_LEVEL_INFO)
48714 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48715 - __FILE__,__LINE__, tty->driver->name, port->count );
48716 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48717
48718 spin_lock_irqsave(&info->lock, flags);
48719 if (!tty_hung_up_p(filp)) {
48720 extra_count = true;
48721 - port->count--;
48722 + atomic_dec(&port->count);
48723 }
48724 spin_unlock_irqrestore(&info->lock, flags);
48725 port->blocked_open++;
48726 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48727
48728 if (debug_level >= DEBUG_LEVEL_INFO)
48729 printk("%s(%d):%s block_til_ready() count=%d\n",
48730 - __FILE__,__LINE__, tty->driver->name, port->count );
48731 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48732
48733 tty_unlock(tty);
48734 schedule();
48735 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48736 remove_wait_queue(&port->open_wait, &wait);
48737
48738 if (extra_count)
48739 - port->count++;
48740 + atomic_inc(&port->count);
48741 port->blocked_open--;
48742
48743 if (debug_level >= DEBUG_LEVEL_INFO)
48744 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48745 - __FILE__,__LINE__, tty->driver->name, port->count );
48746 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48747
48748 if (!retval)
48749 port->flags |= ASYNC_NORMAL_ACTIVE;
48750 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48751 index d5cc3ac..3263411 100644
48752 --- a/drivers/tty/sysrq.c
48753 +++ b/drivers/tty/sysrq.c
48754 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48755 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48756 size_t count, loff_t *ppos)
48757 {
48758 - if (count) {
48759 + if (count && capable(CAP_SYS_ADMIN)) {
48760 char c;
48761
48762 if (get_user(c, buf))
48763 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48764 index 366af83..6db51c3 100644
48765 --- a/drivers/tty/tty_io.c
48766 +++ b/drivers/tty/tty_io.c
48767 @@ -3467,7 +3467,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48768
48769 void tty_default_fops(struct file_operations *fops)
48770 {
48771 - *fops = tty_fops;
48772 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48773 }
48774
48775 /*
48776 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48777 index 1afe192..73d2c20 100644
48778 --- a/drivers/tty/tty_ldisc.c
48779 +++ b/drivers/tty/tty_ldisc.c
48780 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48781 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48782 tty_ldiscs[disc] = new_ldisc;
48783 new_ldisc->num = disc;
48784 - new_ldisc->refcount = 0;
48785 + atomic_set(&new_ldisc->refcount, 0);
48786 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48787
48788 return ret;
48789 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48790 return -EINVAL;
48791
48792 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48793 - if (tty_ldiscs[disc]->refcount)
48794 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48795 ret = -EBUSY;
48796 else
48797 tty_ldiscs[disc] = NULL;
48798 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48799 if (ldops) {
48800 ret = ERR_PTR(-EAGAIN);
48801 if (try_module_get(ldops->owner)) {
48802 - ldops->refcount++;
48803 + atomic_inc(&ldops->refcount);
48804 ret = ldops;
48805 }
48806 }
48807 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48808 unsigned long flags;
48809
48810 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48811 - ldops->refcount--;
48812 + atomic_dec(&ldops->refcount);
48813 module_put(ldops->owner);
48814 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48815 }
48816 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48817 /* unreleased reader reference(s) will cause this WARN */
48818 WARN_ON(!atomic_dec_and_test(&ld->users));
48819
48820 - ld->ops->refcount--;
48821 + atomic_dec(&ld->ops->refcount);
48822 module_put(ld->ops->owner);
48823 kfree(ld);
48824 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48825 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48826 index f597e88..b7f68ed 100644
48827 --- a/drivers/tty/tty_port.c
48828 +++ b/drivers/tty/tty_port.c
48829 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48830 unsigned long flags;
48831
48832 spin_lock_irqsave(&port->lock, flags);
48833 - port->count = 0;
48834 + atomic_set(&port->count, 0);
48835 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48836 tty = port->tty;
48837 if (tty)
48838 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48839 /* The port lock protects the port counts */
48840 spin_lock_irqsave(&port->lock, flags);
48841 if (!tty_hung_up_p(filp))
48842 - port->count--;
48843 + atomic_dec(&port->count);
48844 port->blocked_open++;
48845 spin_unlock_irqrestore(&port->lock, flags);
48846
48847 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48848 we must not mess that up further */
48849 spin_lock_irqsave(&port->lock, flags);
48850 if (!tty_hung_up_p(filp))
48851 - port->count++;
48852 + atomic_inc(&port->count);
48853 port->blocked_open--;
48854 if (retval == 0)
48855 port->flags |= ASYNC_NORMAL_ACTIVE;
48856 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48857 return 0;
48858 }
48859
48860 - if (tty->count == 1 && port->count != 1) {
48861 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48862 printk(KERN_WARNING
48863 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48864 - port->count);
48865 - port->count = 1;
48866 + atomic_read(&port->count));
48867 + atomic_set(&port->count, 1);
48868 }
48869 - if (--port->count < 0) {
48870 + if (atomic_dec_return(&port->count) < 0) {
48871 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48872 - port->count);
48873 - port->count = 0;
48874 + atomic_read(&port->count));
48875 + atomic_set(&port->count, 0);
48876 }
48877
48878 - if (port->count) {
48879 + if (atomic_read(&port->count)) {
48880 spin_unlock_irqrestore(&port->lock, flags);
48881 if (port->ops->drop)
48882 port->ops->drop(port);
48883 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48884 {
48885 spin_lock_irq(&port->lock);
48886 if (!tty_hung_up_p(filp))
48887 - ++port->count;
48888 + atomic_inc(&port->count);
48889 spin_unlock_irq(&port->lock);
48890 tty_port_tty_set(port, tty);
48891
48892 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48893 index a9af1b9a..1e08e7f 100644
48894 --- a/drivers/tty/vt/keyboard.c
48895 +++ b/drivers/tty/vt/keyboard.c
48896 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48897 kbd->kbdmode == VC_OFF) &&
48898 value != KVAL(K_SAK))
48899 return; /* SAK is allowed even in raw mode */
48900 +
48901 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48902 + {
48903 + void *func = fn_handler[value];
48904 + if (func == fn_show_state || func == fn_show_ptregs ||
48905 + func == fn_show_mem)
48906 + return;
48907 + }
48908 +#endif
48909 +
48910 fn_handler[value](vc);
48911 }
48912
48913 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48914 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48915 return -EFAULT;
48916
48917 - if (!capable(CAP_SYS_TTY_CONFIG))
48918 - perm = 0;
48919 -
48920 switch (cmd) {
48921 case KDGKBENT:
48922 /* Ensure another thread doesn't free it under us */
48923 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48924 spin_unlock_irqrestore(&kbd_event_lock, flags);
48925 return put_user(val, &user_kbe->kb_value);
48926 case KDSKBENT:
48927 + if (!capable(CAP_SYS_TTY_CONFIG))
48928 + perm = 0;
48929 +
48930 if (!perm)
48931 return -EPERM;
48932 if (!i && v == K_NOSUCHMAP) {
48933 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48934 int i, j, k;
48935 int ret;
48936
48937 - if (!capable(CAP_SYS_TTY_CONFIG))
48938 - perm = 0;
48939 -
48940 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48941 if (!kbs) {
48942 ret = -ENOMEM;
48943 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48944 kfree(kbs);
48945 return ((p && *p) ? -EOVERFLOW : 0);
48946 case KDSKBSENT:
48947 + if (!capable(CAP_SYS_TTY_CONFIG))
48948 + perm = 0;
48949 +
48950 if (!perm) {
48951 ret = -EPERM;
48952 goto reterr;
48953 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48954 index 3b96f18..026a9bf 100644
48955 --- a/drivers/uio/uio.c
48956 +++ b/drivers/uio/uio.c
48957 @@ -25,6 +25,7 @@
48958 #include <linux/kobject.h>
48959 #include <linux/cdev.h>
48960 #include <linux/uio_driver.h>
48961 +#include <asm/local.h>
48962
48963 #define UIO_MAX_DEVICES (1U << MINORBITS)
48964
48965 @@ -32,10 +33,10 @@ struct uio_device {
48966 struct module *owner;
48967 struct device *dev;
48968 int minor;
48969 - atomic_t event;
48970 + atomic_unchecked_t event;
48971 struct fasync_struct *async_queue;
48972 wait_queue_head_t wait;
48973 - int vma_count;
48974 + local_t vma_count;
48975 struct uio_info *info;
48976 struct kobject *map_dir;
48977 struct kobject *portio_dir;
48978 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48979 struct device_attribute *attr, char *buf)
48980 {
48981 struct uio_device *idev = dev_get_drvdata(dev);
48982 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48983 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48984 }
48985
48986 static struct device_attribute uio_class_attributes[] = {
48987 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48988 {
48989 struct uio_device *idev = info->uio_dev;
48990
48991 - atomic_inc(&idev->event);
48992 + atomic_inc_unchecked(&idev->event);
48993 wake_up_interruptible(&idev->wait);
48994 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48995 }
48996 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48997 }
48998
48999 listener->dev = idev;
49000 - listener->event_count = atomic_read(&idev->event);
49001 + listener->event_count = atomic_read_unchecked(&idev->event);
49002 filep->private_data = listener;
49003
49004 if (idev->info->open) {
49005 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
49006 return -EIO;
49007
49008 poll_wait(filep, &idev->wait, wait);
49009 - if (listener->event_count != atomic_read(&idev->event))
49010 + if (listener->event_count != atomic_read_unchecked(&idev->event))
49011 return POLLIN | POLLRDNORM;
49012 return 0;
49013 }
49014 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
49015 do {
49016 set_current_state(TASK_INTERRUPTIBLE);
49017
49018 - event_count = atomic_read(&idev->event);
49019 + event_count = atomic_read_unchecked(&idev->event);
49020 if (event_count != listener->event_count) {
49021 if (copy_to_user(buf, &event_count, count))
49022 retval = -EFAULT;
49023 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
49024 static void uio_vma_open(struct vm_area_struct *vma)
49025 {
49026 struct uio_device *idev = vma->vm_private_data;
49027 - idev->vma_count++;
49028 + local_inc(&idev->vma_count);
49029 }
49030
49031 static void uio_vma_close(struct vm_area_struct *vma)
49032 {
49033 struct uio_device *idev = vma->vm_private_data;
49034 - idev->vma_count--;
49035 + local_dec(&idev->vma_count);
49036 }
49037
49038 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
49039 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
49040 idev->owner = owner;
49041 idev->info = info;
49042 init_waitqueue_head(&idev->wait);
49043 - atomic_set(&idev->event, 0);
49044 + atomic_set_unchecked(&idev->event, 0);
49045
49046 ret = uio_get_minor(idev);
49047 if (ret)
49048 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
49049 index 8a7eb77..c00402f 100644
49050 --- a/drivers/usb/atm/cxacru.c
49051 +++ b/drivers/usb/atm/cxacru.c
49052 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
49053 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
49054 if (ret < 2)
49055 return -EINVAL;
49056 - if (index < 0 || index > 0x7f)
49057 + if (index > 0x7f)
49058 return -EINVAL;
49059 pos += tmp;
49060
49061 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
49062 index 5e0d33a..cc10579 100644
49063 --- a/drivers/usb/atm/usbatm.c
49064 +++ b/drivers/usb/atm/usbatm.c
49065 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49066 if (printk_ratelimit())
49067 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
49068 __func__, vpi, vci);
49069 - atomic_inc(&vcc->stats->rx_err);
49070 + atomic_inc_unchecked(&vcc->stats->rx_err);
49071 return;
49072 }
49073
49074 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49075 if (length > ATM_MAX_AAL5_PDU) {
49076 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
49077 __func__, length, vcc);
49078 - atomic_inc(&vcc->stats->rx_err);
49079 + atomic_inc_unchecked(&vcc->stats->rx_err);
49080 goto out;
49081 }
49082
49083 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49084 if (sarb->len < pdu_length) {
49085 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
49086 __func__, pdu_length, sarb->len, vcc);
49087 - atomic_inc(&vcc->stats->rx_err);
49088 + atomic_inc_unchecked(&vcc->stats->rx_err);
49089 goto out;
49090 }
49091
49092 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
49093 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
49094 __func__, vcc);
49095 - atomic_inc(&vcc->stats->rx_err);
49096 + atomic_inc_unchecked(&vcc->stats->rx_err);
49097 goto out;
49098 }
49099
49100 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49101 if (printk_ratelimit())
49102 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
49103 __func__, length);
49104 - atomic_inc(&vcc->stats->rx_drop);
49105 + atomic_inc_unchecked(&vcc->stats->rx_drop);
49106 goto out;
49107 }
49108
49109 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49110
49111 vcc->push(vcc, skb);
49112
49113 - atomic_inc(&vcc->stats->rx);
49114 + atomic_inc_unchecked(&vcc->stats->rx);
49115 out:
49116 skb_trim(sarb, 0);
49117 }
49118 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
49119 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49120
49121 usbatm_pop(vcc, skb);
49122 - atomic_inc(&vcc->stats->tx);
49123 + atomic_inc_unchecked(&vcc->stats->tx);
49124
49125 skb = skb_dequeue(&instance->sndqueue);
49126 }
49127 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49128 if (!left--)
49129 return sprintf(page,
49130 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49131 - atomic_read(&atm_dev->stats.aal5.tx),
49132 - atomic_read(&atm_dev->stats.aal5.tx_err),
49133 - atomic_read(&atm_dev->stats.aal5.rx),
49134 - atomic_read(&atm_dev->stats.aal5.rx_err),
49135 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49136 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49137 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49138 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49139 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49140 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49141
49142 if (!left--) {
49143 if (instance->disconnected)
49144 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49145 index 2a3bbdf..91d72cf 100644
49146 --- a/drivers/usb/core/devices.c
49147 +++ b/drivers/usb/core/devices.c
49148 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49149 * time it gets called.
49150 */
49151 static struct device_connect_event {
49152 - atomic_t count;
49153 + atomic_unchecked_t count;
49154 wait_queue_head_t wait;
49155 } device_event = {
49156 .count = ATOMIC_INIT(1),
49157 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49158
49159 void usbfs_conn_disc_event(void)
49160 {
49161 - atomic_add(2, &device_event.count);
49162 + atomic_add_unchecked(2, &device_event.count);
49163 wake_up(&device_event.wait);
49164 }
49165
49166 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49167
49168 poll_wait(file, &device_event.wait, wait);
49169
49170 - event_count = atomic_read(&device_event.count);
49171 + event_count = atomic_read_unchecked(&device_event.count);
49172 if (file->f_version != event_count) {
49173 file->f_version = event_count;
49174 return POLLIN | POLLRDNORM;
49175 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49176 index 014dc99..4d25fd7 100644
49177 --- a/drivers/usb/core/hcd.c
49178 +++ b/drivers/usb/core/hcd.c
49179 @@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49180 */
49181 usb_get_urb(urb);
49182 atomic_inc(&urb->use_count);
49183 - atomic_inc(&urb->dev->urbnum);
49184 + atomic_inc_unchecked(&urb->dev->urbnum);
49185 usbmon_urb_submit(&hcd->self, urb);
49186
49187 /* NOTE requirements on root-hub callers (usbfs and the hub
49188 @@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49189 urb->hcpriv = NULL;
49190 INIT_LIST_HEAD(&urb->urb_list);
49191 atomic_dec(&urb->use_count);
49192 - atomic_dec(&urb->dev->urbnum);
49193 + atomic_dec_unchecked(&urb->dev->urbnum);
49194 if (atomic_read(&urb->reject))
49195 wake_up(&usb_kill_urb_queue);
49196 usb_put_urb(urb);
49197 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49198 index 558313d..8cadfa5 100644
49199 --- a/drivers/usb/core/hub.c
49200 +++ b/drivers/usb/core/hub.c
49201 @@ -27,6 +27,7 @@
49202 #include <linux/freezer.h>
49203 #include <linux/random.h>
49204 #include <linux/pm_qos.h>
49205 +#include <linux/grsecurity.h>
49206
49207 #include <asm/uaccess.h>
49208 #include <asm/byteorder.h>
49209 @@ -4426,6 +4427,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49210 goto done;
49211 return;
49212 }
49213 +
49214 + if (gr_handle_new_usb())
49215 + goto done;
49216 +
49217 if (hub_is_superspeed(hub->hdev))
49218 unit_load = 150;
49219 else
49220 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49221 index e7ee1e4..1dfc9ea4 100644
49222 --- a/drivers/usb/core/message.c
49223 +++ b/drivers/usb/core/message.c
49224 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49225 * method can wait for it to complete. Since you don't have a handle on the
49226 * URB used, you can't cancel the request.
49227 */
49228 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49229 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49230 __u8 requesttype, __u16 value, __u16 index, void *data,
49231 __u16 size, int timeout)
49232 {
49233 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49234 index d9284b9..17023c7 100644
49235 --- a/drivers/usb/core/sysfs.c
49236 +++ b/drivers/usb/core/sysfs.c
49237 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49238 struct usb_device *udev;
49239
49240 udev = to_usb_device(dev);
49241 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49242 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49243 }
49244 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49245
49246 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49247 index 7dad603..350f7a9 100644
49248 --- a/drivers/usb/core/usb.c
49249 +++ b/drivers/usb/core/usb.c
49250 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49251 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49252 dev->state = USB_STATE_ATTACHED;
49253 dev->lpm_disable_count = 1;
49254 - atomic_set(&dev->urbnum, 0);
49255 + atomic_set_unchecked(&dev->urbnum, 0);
49256
49257 INIT_LIST_HEAD(&dev->ep0.urb_list);
49258 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49259 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49260 index f77083f..f3e2e34 100644
49261 --- a/drivers/usb/dwc3/gadget.c
49262 +++ b/drivers/usb/dwc3/gadget.c
49263 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49264 if (!usb_endpoint_xfer_isoc(desc))
49265 return 0;
49266
49267 - memset(&trb_link, 0, sizeof(trb_link));
49268 -
49269 /* Link TRB for ISOC. The HWO bit is never reset */
49270 trb_st_hw = &dep->trb_pool[0];
49271
49272 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49273 index 5e29dde..eca992f 100644
49274 --- a/drivers/usb/early/ehci-dbgp.c
49275 +++ b/drivers/usb/early/ehci-dbgp.c
49276 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49277
49278 #ifdef CONFIG_KGDB
49279 static struct kgdb_io kgdbdbgp_io_ops;
49280 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49281 +static struct kgdb_io kgdbdbgp_io_ops_console;
49282 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49283 #else
49284 #define dbgp_kgdb_mode (0)
49285 #endif
49286 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49287 .write_char = kgdbdbgp_write_char,
49288 };
49289
49290 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49291 + .name = "kgdbdbgp",
49292 + .read_char = kgdbdbgp_read_char,
49293 + .write_char = kgdbdbgp_write_char,
49294 + .is_console = 1
49295 +};
49296 +
49297 static int kgdbdbgp_wait_time;
49298
49299 static int __init kgdbdbgp_parse_config(char *str)
49300 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49301 ptr++;
49302 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49303 }
49304 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49305 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49306 + if (early_dbgp_console.index != -1)
49307 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49308 + else
49309 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49310
49311 return 0;
49312 }
49313 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49314 index b369292..9f3ba40 100644
49315 --- a/drivers/usb/gadget/u_serial.c
49316 +++ b/drivers/usb/gadget/u_serial.c
49317 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49318 spin_lock_irq(&port->port_lock);
49319
49320 /* already open? Great. */
49321 - if (port->port.count) {
49322 + if (atomic_read(&port->port.count)) {
49323 status = 0;
49324 - port->port.count++;
49325 + atomic_inc(&port->port.count);
49326
49327 /* currently opening/closing? wait ... */
49328 } else if (port->openclose) {
49329 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49330 tty->driver_data = port;
49331 port->port.tty = tty;
49332
49333 - port->port.count = 1;
49334 + atomic_set(&port->port.count, 1);
49335 port->openclose = false;
49336
49337 /* if connected, start the I/O stream */
49338 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49339
49340 spin_lock_irq(&port->port_lock);
49341
49342 - if (port->port.count != 1) {
49343 - if (port->port.count == 0)
49344 + if (atomic_read(&port->port.count) != 1) {
49345 + if (atomic_read(&port->port.count) == 0)
49346 WARN_ON(1);
49347 else
49348 - --port->port.count;
49349 + atomic_dec(&port->port.count);
49350 goto exit;
49351 }
49352
49353 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49354 * and sleep if necessary
49355 */
49356 port->openclose = true;
49357 - port->port.count = 0;
49358 + atomic_set(&port->port.count, 0);
49359
49360 gser = port->port_usb;
49361 if (gser && gser->disconnect)
49362 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49363 int cond;
49364
49365 spin_lock_irq(&port->port_lock);
49366 - cond = (port->port.count == 0) && !port->openclose;
49367 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49368 spin_unlock_irq(&port->port_lock);
49369 return cond;
49370 }
49371 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49372 /* if it's already open, start I/O ... and notify the serial
49373 * protocol about open/close status (connect/disconnect).
49374 */
49375 - if (port->port.count) {
49376 + if (atomic_read(&port->port.count)) {
49377 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49378 gs_start_io(port);
49379 if (gser->connect)
49380 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49381
49382 port->port_usb = NULL;
49383 gser->ioport = NULL;
49384 - if (port->port.count > 0 || port->openclose) {
49385 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49386 wake_up_interruptible(&port->drain_wait);
49387 if (port->port.tty)
49388 tty_hangup(port->port.tty);
49389 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49390
49391 /* finally, free any unused/unusable I/O buffers */
49392 spin_lock_irqsave(&port->port_lock, flags);
49393 - if (port->port.count == 0 && !port->openclose)
49394 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49395 gs_buf_free(&port->port_write_buf);
49396 gs_free_requests(gser->out, &port->read_pool, NULL);
49397 gs_free_requests(gser->out, &port->read_queue, NULL);
49398 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49399 index ba6a5d6..f88f7f3 100644
49400 --- a/drivers/usb/misc/appledisplay.c
49401 +++ b/drivers/usb/misc/appledisplay.c
49402 @@ -83,7 +83,7 @@ struct appledisplay {
49403 spinlock_t lock;
49404 };
49405
49406 -static atomic_t count_displays = ATOMIC_INIT(0);
49407 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49408 static struct workqueue_struct *wq;
49409
49410 static void appledisplay_complete(struct urb *urb)
49411 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49412
49413 /* Register backlight device */
49414 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49415 - atomic_inc_return(&count_displays) - 1);
49416 + atomic_inc_return_unchecked(&count_displays) - 1);
49417 memset(&props, 0, sizeof(struct backlight_properties));
49418 props.type = BACKLIGHT_RAW;
49419 props.max_brightness = 0xff;
49420 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49421 index afb50ea..7b0b1cf 100644
49422 --- a/drivers/usb/serial/console.c
49423 +++ b/drivers/usb/serial/console.c
49424 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49425
49426 info->port = port;
49427
49428 - ++port->port.count;
49429 + atomic_inc(&port->port.count);
49430 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49431 if (serial->type->set_termios) {
49432 /*
49433 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49434 }
49435 /* Now that any required fake tty operations are completed restore
49436 * the tty port count */
49437 - --port->port.count;
49438 + atomic_dec(&port->port.count);
49439 /* The console is special in terms of closing the device so
49440 * indicate this port is now acting as a system console. */
49441 port->port.console = 1;
49442 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49443 free_tty:
49444 kfree(tty);
49445 reset_open_count:
49446 - port->port.count = 0;
49447 + atomic_set(&port->port.count, 0);
49448 usb_autopm_put_interface(serial->interface);
49449 error_get_interface:
49450 usb_serial_put(serial);
49451 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49452 index 75f70f0..d467e1a 100644
49453 --- a/drivers/usb/storage/usb.h
49454 +++ b/drivers/usb/storage/usb.h
49455 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49456 __u8 useProtocol;
49457 __u8 useTransport;
49458 int (*initFunction)(struct us_data *);
49459 -};
49460 +} __do_const;
49461
49462
49463 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49464 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49465 index d6bea3e..60b250e 100644
49466 --- a/drivers/usb/wusbcore/wa-hc.h
49467 +++ b/drivers/usb/wusbcore/wa-hc.h
49468 @@ -192,7 +192,7 @@ struct wahc {
49469 struct list_head xfer_delayed_list;
49470 spinlock_t xfer_list_lock;
49471 struct work_struct xfer_work;
49472 - atomic_t xfer_id_count;
49473 + atomic_unchecked_t xfer_id_count;
49474 };
49475
49476
49477 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49478 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49479 spin_lock_init(&wa->xfer_list_lock);
49480 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49481 - atomic_set(&wa->xfer_id_count, 1);
49482 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49483 }
49484
49485 /**
49486 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49487 index d3493ca..0c33b7e 100644
49488 --- a/drivers/usb/wusbcore/wa-xfer.c
49489 +++ b/drivers/usb/wusbcore/wa-xfer.c
49490 @@ -297,7 +297,7 @@ out:
49491 */
49492 static void wa_xfer_id_init(struct wa_xfer *xfer)
49493 {
49494 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49495 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49496 }
49497
49498 /*
49499 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49500 index 842f450..d1d7409 100644
49501 --- a/drivers/vfio/vfio.c
49502 +++ b/drivers/vfio/vfio.c
49503 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49504 return 0;
49505
49506 /* TODO Prevent device auto probing */
49507 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49508 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49509 iommu_group_id(group->iommu_group));
49510
49511 return 0;
49512 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49513 index 5174eba..86e764a 100644
49514 --- a/drivers/vhost/vringh.c
49515 +++ b/drivers/vhost/vringh.c
49516 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49517
49518 static inline int putu16_kern(u16 *p, u16 val)
49519 {
49520 - ACCESS_ONCE(*p) = val;
49521 + ACCESS_ONCE_RW(*p) = val;
49522 return 0;
49523 }
49524
49525 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49526 index a4dfe8c..297ddd9 100644
49527 --- a/drivers/video/aty/aty128fb.c
49528 +++ b/drivers/video/aty/aty128fb.c
49529 @@ -149,7 +149,7 @@ enum {
49530 };
49531
49532 /* Must match above enum */
49533 -static char * const r128_family[] = {
49534 +static const char * const r128_family[] = {
49535 "AGP",
49536 "PCI",
49537 "PRO AGP",
49538 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49539 index 9b0f12c..024673d 100644
49540 --- a/drivers/video/aty/atyfb_base.c
49541 +++ b/drivers/video/aty/atyfb_base.c
49542 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49543 par->accel_flags = var->accel_flags; /* hack */
49544
49545 if (var->accel_flags) {
49546 - info->fbops->fb_sync = atyfb_sync;
49547 + pax_open_kernel();
49548 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49549 + pax_close_kernel();
49550 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49551 } else {
49552 - info->fbops->fb_sync = NULL;
49553 + pax_open_kernel();
49554 + *(void **)&info->fbops->fb_sync = NULL;
49555 + pax_close_kernel();
49556 info->flags |= FBINFO_HWACCEL_DISABLED;
49557 }
49558
49559 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49560 index 95ec042..e6affdd 100644
49561 --- a/drivers/video/aty/mach64_cursor.c
49562 +++ b/drivers/video/aty/mach64_cursor.c
49563 @@ -7,6 +7,7 @@
49564 #include <linux/string.h>
49565
49566 #include <asm/io.h>
49567 +#include <asm/pgtable.h>
49568
49569 #ifdef __sparc__
49570 #include <asm/fbio.h>
49571 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49572 info->sprite.buf_align = 16; /* and 64 lines tall. */
49573 info->sprite.flags = FB_PIXMAP_IO;
49574
49575 - info->fbops->fb_cursor = atyfb_cursor;
49576 + pax_open_kernel();
49577 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49578 + pax_close_kernel();
49579
49580 return 0;
49581 }
49582 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49583 index bca6ccc..252107e 100644
49584 --- a/drivers/video/backlight/kb3886_bl.c
49585 +++ b/drivers/video/backlight/kb3886_bl.c
49586 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49587 static unsigned long kb3886bl_flags;
49588 #define KB3886BL_SUSPENDED 0x01
49589
49590 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49591 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49592 {
49593 .ident = "Sahara Touch-iT",
49594 .matches = {
49595 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49596 index 900aa4e..6d49418 100644
49597 --- a/drivers/video/fb_defio.c
49598 +++ b/drivers/video/fb_defio.c
49599 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49600
49601 BUG_ON(!fbdefio);
49602 mutex_init(&fbdefio->lock);
49603 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49604 + pax_open_kernel();
49605 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49606 + pax_close_kernel();
49607 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49608 INIT_LIST_HEAD(&fbdefio->pagelist);
49609 if (fbdefio->delay == 0) /* set a default of 1 s */
49610 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49611 page->mapping = NULL;
49612 }
49613
49614 - info->fbops->fb_mmap = NULL;
49615 + *(void **)&info->fbops->fb_mmap = NULL;
49616 mutex_destroy(&fbdefio->lock);
49617 }
49618 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49619 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49620 index 5c3960d..15cf8fc 100644
49621 --- a/drivers/video/fbcmap.c
49622 +++ b/drivers/video/fbcmap.c
49623 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49624 rc = -ENODEV;
49625 goto out;
49626 }
49627 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49628 - !info->fbops->fb_setcmap)) {
49629 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49630 rc = -EINVAL;
49631 goto out1;
49632 }
49633 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49634 index 36e1fe2..c744820 100644
49635 --- a/drivers/video/fbmem.c
49636 +++ b/drivers/video/fbmem.c
49637 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49638 image->dx += image->width + 8;
49639 }
49640 } else if (rotate == FB_ROTATE_UD) {
49641 - for (x = 0; x < num && image->dx >= 0; x++) {
49642 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49643 info->fbops->fb_imageblit(info, image);
49644 image->dx -= image->width + 8;
49645 }
49646 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49647 image->dy += image->height + 8;
49648 }
49649 } else if (rotate == FB_ROTATE_CCW) {
49650 - for (x = 0; x < num && image->dy >= 0; x++) {
49651 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49652 info->fbops->fb_imageblit(info, image);
49653 image->dy -= image->height + 8;
49654 }
49655 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49656 return -EFAULT;
49657 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49658 return -EINVAL;
49659 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49660 + if (con2fb.framebuffer >= FB_MAX)
49661 return -EINVAL;
49662 if (!registered_fb[con2fb.framebuffer])
49663 request_module("fb%d", con2fb.framebuffer);
49664 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49665 index d4d2c5f..ebbd113 100644
49666 --- a/drivers/video/hyperv_fb.c
49667 +++ b/drivers/video/hyperv_fb.c
49668 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49669 static inline int synthvid_send(struct hv_device *hdev,
49670 struct synthvid_msg *msg)
49671 {
49672 - static atomic64_t request_id = ATOMIC64_INIT(0);
49673 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49674 int ret;
49675
49676 msg->pipe_hdr.type = PIPE_MSG_DATA;
49677 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49678
49679 ret = vmbus_sendpacket(hdev->channel, msg,
49680 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49681 - atomic64_inc_return(&request_id),
49682 + atomic64_inc_return_unchecked(&request_id),
49683 VM_PKT_DATA_INBAND, 0);
49684
49685 if (ret)
49686 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49687 index 7672d2e..b56437f 100644
49688 --- a/drivers/video/i810/i810_accel.c
49689 +++ b/drivers/video/i810/i810_accel.c
49690 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49691 }
49692 }
49693 printk("ringbuffer lockup!!!\n");
49694 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49695 i810_report_error(mmio);
49696 par->dev_flags |= LOCKUP;
49697 info->pixmap.scan_align = 1;
49698 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49699 index 285d552..eafa544 100644
49700 --- a/drivers/video/logo/logo_linux_clut224.ppm
49701 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49702 @@ -1,883 +1,1123 @@
49703 P3
49704 80 80
49705 255
49706 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49707 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49708 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 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 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49711 -10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49712 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49713 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49714 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49715 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49716 -
49717 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49718 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49719 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 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 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49722 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0
49723 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49724 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49725 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49726 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49727 -
49728 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49729 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49730 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 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 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49733 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49734 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49735 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49736 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49737 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49738 -
49739 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49740 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49741 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 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 10 10 10
49743 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49744 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49745 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49746 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49747 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49748 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49749 -
49750 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49751 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49752 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49753 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49754 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49755 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49756 -38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49757 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49758 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49759 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49760 -
49761 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49762 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49763 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49764 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49765 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49766 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49767 -78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49768 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49769 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49770 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49771 -
49772 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49773 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49774 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49775 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49776 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49777 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49778 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49779 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49780 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49781 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49782 -
49783 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49784 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49785 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49786 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49787 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49788 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49789 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49790 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49791 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49792 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49793 -
49794 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49795 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49796 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49797 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49798 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49799 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49800 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0
49801 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49802 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49803 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49804 -
49805 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49806 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49807 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49808 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49809 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49810 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49811 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0
49812 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49813 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49814 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49815 -
49816 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49817 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49818 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49819 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49820 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49821 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49822 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0
49823 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49824 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49825 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49826 -
49827 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49828 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49829 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49830 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49831 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49832 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49833 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0
49834 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49835 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49836 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49837 -
49838 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49839 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49840 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49841 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49842 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49843 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49844 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0
49845 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49846 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49847 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49848 -
49849 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49850 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49851 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49852 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49853 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49854 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49855 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0
49856 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49857 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49858 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49859 -
49860 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49861 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49862 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49863 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49864 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49865 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49866 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0
49867 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49868 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49869 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49870 -
49871 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49872 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49873 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49874 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49875 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49876 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49877 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49878 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49879 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49880 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49881 -
49882 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49883 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49884 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49885 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49886 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49887 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49888 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49889 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49890 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49891 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49892 -
49893 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49894 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49895 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49896 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49897 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49898 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49899 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49900 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49901 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49902 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49903 -
49904 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49905 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49906 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49907 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49908 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49909 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49910 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49911 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49912 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49913 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49914 -
49915 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49916 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49917 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49918 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49919 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49920 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49921 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49922 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49923 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49924 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49925 -
49926 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49927 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49928 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49929 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49930 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49931 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49932 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
49933 -0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49935 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49936 -
49937 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49938 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49939 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49940 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49941 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49942 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49943 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49946 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49947 -
49948 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49949 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49950 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49951 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49952 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49953 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49954 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49957 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49958 -
49959 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49960 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49961 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49962 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49963 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49964 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49965 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49968 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49969 -
49970 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49971 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49972 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49973 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49974 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49975 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49976 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49977 -6 6 6 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49979 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49980 -
49981 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49982 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49983 -3 5 6 1 1 1 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 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49985 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49986 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49987 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49988 -10 10 10 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49990 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49991 -
49992 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49993 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 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 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49996 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49997 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49998 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49999 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50000 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50001 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50002 -
50003 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
50004 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 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 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
50007 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
50008 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
50009 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
50010 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50011 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50012 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50013 -
50014 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
50015 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 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 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
50018 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
50019 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
50020 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
50021 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50022 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50023 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50024 -
50025 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
50026 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 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 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
50029 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
50030 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
50031 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
50032 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50033 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50034 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50035 -
50036 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
50037 -18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 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 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
50040 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
50041 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50042 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
50043 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50044 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50045 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50046 -
50047 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
50048 -52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
50051 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
50052 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50053 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50054 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50055 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50056 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50057 -
50058 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
50059 -36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50060 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50061 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
50062 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
50063 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50064 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50065 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
50066 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50067 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50068 -
50069 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50070 -21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50071 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50072 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
50073 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
50074 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50075 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50076 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
50077 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50078 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50079 -
50080 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50081 -12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50082 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
50083 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
50084 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
50085 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50086 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50087 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
50088 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50089 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50090 -
50091 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50092 -0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0
50093 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
50094 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
50095 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50096 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50097 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50098 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
50099 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50100 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50101 -
50102 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50103 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
50104 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
50105 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
50106 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
50107 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
50108 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
50109 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
50110 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50111 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50112 -
50113 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50114 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
50115 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
50116 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
50117 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
50118 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
50119 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
50120 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
50121 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50122 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50123 -
50124 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50125 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
50126 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
50127 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
50128 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
50129 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
50130 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
50131 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
50132 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50133 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50134 -
50135 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50136 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
50137 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
50138 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
50139 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
50140 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
50141 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
50142 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
50143 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50144 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50145 -
50146 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50147 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
50148 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
50149 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
50150 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50151 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50152 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
50153 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
50154 -42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50155 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50156 -
50157 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50158 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
50159 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
50160 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
50161 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50162 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50163 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
50164 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
50165 -58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50166 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50167 -
50168 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50169 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
50170 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
50171 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50172 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50173 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50174 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
50175 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
50176 -78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50177 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50178 -
50179 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50180 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33
50181 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
50182 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50183 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50184 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50185 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
50186 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
50187 -86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50188 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50189 -
50190 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50191 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50192 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
50193 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50194 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50195 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50196 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
50197 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
50198 -74 74 74 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50199 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50200 -
50201 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50202 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50203 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
50204 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50205 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50206 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50207 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
50208 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50209 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50210 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50211 -
50212 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50213 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50214 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50215 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50216 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50217 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50218 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
50219 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50220 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50221 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50222 -
50223 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50224 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50225 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50226 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50227 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50228 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50229 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50230 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50231 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
50232 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50233 -
50234 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50235 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50236 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50237 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50238 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50239 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50240 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
50241 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50242 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50243 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50244 -
50245 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50246 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50247 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50248 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50249 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50250 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50251 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
50252 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50253 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50254 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50255 -
50256 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50257 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50258 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50259 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50260 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50261 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50262 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
50263 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50264 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50265 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50266 -
50267 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50268 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50269 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50270 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50271 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50272 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50273 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
50274 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50275 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50276 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50277 -
50278 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50279 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50280 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50281 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50282 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50283 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50284 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
50285 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50286 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50287 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50288 -
50289 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50290 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50291 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
50292 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50293 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50294 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50295 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50296 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50297 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50298 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50299 -
50300 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50301 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
50302 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50303 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50304 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50305 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50306 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
50307 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50308 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50309 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50310 -
50311 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50312 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50313 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50314 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50315 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50316 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50317 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50318 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50319 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50320 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50321 -
50322 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50323 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50324 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50325 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50326 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50327 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50328 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50329 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50330 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
50331 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50332 -
50333 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50334 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50335 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50336 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50337 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50338 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50339 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50340 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50341 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
50342 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50343 -
50344 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50345 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50346 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50347 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50348 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50349 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50350 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50351 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50352 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
50353 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50354 -
50355 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50356 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50357 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50358 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50359 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50360 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50361 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50362 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50363 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
50364 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50365 -
50366 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50367 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50368 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50369 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
50370 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50371 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50372 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50373 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50374 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
50375 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50376 -
50377 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50378 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 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 246 190 14 246 190 14
50380 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50381 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50382 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50383 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50384 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50385 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
50386 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50387 -
50388 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50389 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 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 190 14 246 190 14 246 190 14
50391 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50392 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50393 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50394 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50395 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50396 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50397 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50398 -
50399 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50400 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
50401 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50402 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50403 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50404 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50405 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50406 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50407 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50408 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50409 -
50410 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50411 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50412 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50413 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50414 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50415 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50416 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50417 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50418 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50419 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50420 -
50421 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50422 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50423 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50424 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50425 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50426 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50427 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50428 -246 190 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 246 190 14 242 186 14 149 139 69
50430 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50431 -
50432 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50433 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50434 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50435 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50436 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50437 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50438 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50439 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50440 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50441 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50442 -
50443 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50444 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50445 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50446 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50447 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50448 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50449 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50450 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50451 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50452 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50453 -
50454 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50455 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50456 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50457 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50458 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50459 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50460 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50461 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50462 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50463 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50464 -
50465 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50466 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50467 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50468 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50469 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50470 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50471 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50472 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50473 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50474 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50475 -
50476 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50477 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50478 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50479 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50480 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50481 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50482 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50483 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50484 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50485 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50486 -
50487 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50488 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50489 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50490 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50491 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50492 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50493 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50494 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50495 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50496 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50497 -
50498 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50499 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50500 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50501 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50502 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50503 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50504 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50505 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50506 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50507 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50508 -
50509 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50510 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50511 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50512 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50513 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50514 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50515 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50516 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50517 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50518 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50519 -
50520 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50521 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50522 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50523 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50524 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50525 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50526 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50527 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50528 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
50531 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50532 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50533 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50534 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50535 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50536 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50537 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50538 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50539 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50540 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50541 -
50542 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50543 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50544 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50545 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50546 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50547 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50548 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50549 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50550 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50551 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50552 -
50553 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50554 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50555 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50556 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50557 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50558 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50559 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50560 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50561 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50562 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50563 -
50564 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50565 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50566 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50567 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50568 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50569 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50570 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50571 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50572 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50573 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50574 -
50575 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50576 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50577 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50578 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50579 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50580 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50581 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50582 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50583 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50584 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50585 -
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
50625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4
50630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
50639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50641 +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 4 4 4 4 4 4 4 4 4 4 4 4
50644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50647 +4 4 4 4 4 4 4 4 4 4 4 4 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 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50655 +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 4 4 4 4 4 4 4 4 4 4 4 4
50658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50661 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
50666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50669 +4 4 4 4 4 4
50670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50674 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50675 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
50680 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50681 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50683 +4 4 4 4 4 4
50684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50688 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50689 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50690 +5 5 5 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 4 4 4
50693 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
50694 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50695 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50696 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50697 +4 4 4 4 4 4
50698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50702 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50703 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50704 +0 0 0 3 3 3 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 4 4 4 4 4 4
50707 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
50708 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50709 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50710 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50711 +4 4 4 4 4 4
50712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50715 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50716 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50717 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50718 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 4 4 4 5 5 5 5 5 5
50721 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50722 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50723 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50724 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50725 +4 4 4 4 4 4
50726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50729 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50730 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50731 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50732 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50733 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50734 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50735 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50736 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50737 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50738 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50739 +4 4 4 4 4 4
50740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
50743 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50744 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50745 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50746 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50747 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50748 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50749 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50750 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50751 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50752 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50753 +4 4 4 4 4 4
50754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50756 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50757 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50758 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50759 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50760 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50761 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50762 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50763 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50764 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50765 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50766 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50767 +4 4 4 4 4 4
50768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50770 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50771 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50772 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50773 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50774 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50775 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50776 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50777 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50778 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50779 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50780 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50781 +4 4 4 4 4 4
50782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50784 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50785 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50786 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50787 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50788 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50789 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50790 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50791 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50792 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50793 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50794 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50795 +4 4 4 4 4 4
50796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50798 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50799 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50800 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50801 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50802 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50803 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50804 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50805 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50806 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50807 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50808 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50809 +4 4 4 4 4 4
50810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50811 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50812 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50813 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50814 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50815 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50816 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50817 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50818 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50819 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50820 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50821 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50822 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50823 +4 4 4 4 4 4
50824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50825 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50826 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50827 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50828 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50829 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50830 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50831 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50832 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50833 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50834 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50835 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50836 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50837 +0 0 0 4 4 4
50838 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50839 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50840 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50841 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50842 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50843 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50844 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50845 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50846 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50847 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50848 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50849 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50850 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50851 +2 0 0 0 0 0
50852 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50853 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50854 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50855 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50856 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50857 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50858 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50859 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50860 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50861 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50862 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50863 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50864 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50865 +37 38 37 0 0 0
50866 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50867 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50868 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50869 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50870 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50871 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50872 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50873 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50874 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50875 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50876 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50877 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50878 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50879 +85 115 134 4 0 0
50880 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50881 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50882 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50883 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50884 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50885 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50886 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50887 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50888 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50889 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50890 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50891 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50892 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50893 +60 73 81 4 0 0
50894 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50895 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50896 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50897 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50898 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50899 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50900 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50901 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50902 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50903 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50904 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50905 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50906 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50907 +16 19 21 4 0 0
50908 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50909 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50910 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50911 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50912 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50913 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50914 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50915 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50916 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50917 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50918 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50919 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50920 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50921 +4 0 0 4 3 3
50922 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50923 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50924 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50926 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50927 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50928 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50929 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50930 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50931 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50932 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50933 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50934 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50935 +3 2 2 4 4 4
50936 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50937 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50938 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50939 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50940 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50941 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50942 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50943 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50944 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50945 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50946 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50947 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50948 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50949 +4 4 4 4 4 4
50950 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50951 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50952 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50953 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50954 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50955 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50956 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50957 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50958 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50959 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50960 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50961 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50962 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50963 +4 4 4 4 4 4
50964 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50965 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50966 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50967 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50968 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50969 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50970 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50971 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50972 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50973 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50974 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50975 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50976 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50977 +5 5 5 5 5 5
50978 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50979 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50980 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50981 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50982 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50983 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50984 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50985 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50986 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50987 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50988 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50989 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50990 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50991 +5 5 5 4 4 4
50992 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50993 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50994 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50995 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50996 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50997 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50998 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50999 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
51000 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
51001 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
51002 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
51003 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51005 +4 4 4 4 4 4
51006 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
51007 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
51008 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
51009 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
51010 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
51011 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51012 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51013 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
51014 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
51015 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
51016 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
51017 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
51018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51019 +4 4 4 4 4 4
51020 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
51021 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
51022 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
51023 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51024 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51025 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51026 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51027 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51028 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51029 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51030 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
51031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51033 +4 4 4 4 4 4
51034 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51035 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
51036 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
51037 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
51038 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51039 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51040 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51041 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
51042 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
51043 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
51044 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
51045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51047 +4 4 4 4 4 4
51048 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
51049 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51050 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51051 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51052 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51053 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51054 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51055 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51056 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51057 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51058 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51061 +4 4 4 4 4 4
51062 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51063 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51064 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51065 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51066 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51067 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51068 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51069 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51070 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51071 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51072 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51075 +4 4 4 4 4 4
51076 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51077 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51078 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51079 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51080 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51081 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51082 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51083 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51084 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51085 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51086 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51089 +4 4 4 4 4 4
51090 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51091 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51092 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
51093 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51094 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
51095 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
51096 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
51097 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
51098 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
51099 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
51100 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51103 +4 4 4 4 4 4
51104 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51105 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51106 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51107 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51108 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51109 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51110 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51111 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51112 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51113 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51114 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51117 +4 4 4 4 4 4
51118 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51119 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51120 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51121 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51122 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51123 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51124 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51125 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51126 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51127 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51128 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51131 +4 4 4 4 4 4
51132 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51133 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51134 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51135 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51136 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51137 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51138 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51139 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51140 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51141 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51142 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51145 +4 4 4 4 4 4
51146 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51147 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51148 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51149 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51150 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51151 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51152 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51153 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51154 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51155 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51156 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51159 +4 4 4 4 4 4
51160 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51161 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51162 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51163 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51164 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51165 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51166 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51167 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51168 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51169 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51170 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51172 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51173 +4 4 4 4 4 4
51174 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51175 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51176 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51177 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51178 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51179 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51180 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51181 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51182 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51183 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51184 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51187 +4 4 4 4 4 4
51188 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51189 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51190 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51191 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51192 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51193 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51194 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51195 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51196 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51197 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51198 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51200 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51201 +4 4 4 4 4 4
51202 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51203 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51204 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51205 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51206 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51207 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51208 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51209 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51210 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51211 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51212 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51215 +4 4 4 4 4 4
51216 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51217 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51218 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51219 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51220 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51221 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51222 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51223 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51224 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51225 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51226 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51229 +4 4 4 4 4 4
51230 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51231 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51232 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51233 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51234 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51235 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51236 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51237 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51238 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51239 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51240 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51243 +4 4 4 4 4 4
51244 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51245 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51246 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51247 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51248 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51249 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51250 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51251 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51252 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51253 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51254 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51257 +4 4 4 4 4 4
51258 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51259 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51260 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51261 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51262 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51263 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51264 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51265 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51266 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51267 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51268 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51271 +4 4 4 4 4 4
51272 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51273 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51274 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51275 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51276 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51277 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51278 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51279 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51280 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51281 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51282 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51285 +4 4 4 4 4 4
51286 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51287 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51288 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51289 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51290 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51291 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51292 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51293 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51294 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51295 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51296 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51299 +4 4 4 4 4 4
51300 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51301 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51302 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51303 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51304 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51305 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51306 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51307 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51308 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51309 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51310 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51313 +4 4 4 4 4 4
51314 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51315 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51316 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51317 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51318 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51319 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51320 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51321 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51322 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51323 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51324 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51327 +4 4 4 4 4 4
51328 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51329 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51330 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51331 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51332 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51333 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51334 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51335 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51336 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51337 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51338 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51341 +4 4 4 4 4 4
51342 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51343 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51344 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51345 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51346 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51347 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51348 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51349 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51350 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51351 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51352 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51355 +4 4 4 4 4 4
51356 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51357 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51358 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51359 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51360 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51361 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51362 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51363 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51364 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51365 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51366 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51369 +4 4 4 4 4 4
51370 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51371 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51372 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51373 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51374 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51375 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51376 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51377 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51378 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51379 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51380 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51383 +4 4 4 4 4 4
51384 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51385 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51386 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51387 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51388 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51389 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51390 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51391 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51392 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51393 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51394 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51397 +4 4 4 4 4 4
51398 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51399 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51400 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51401 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51402 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51403 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51404 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51405 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51406 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51407 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51411 +4 4 4 4 4 4
51412 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51413 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51414 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51415 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51416 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51417 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51418 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51419 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51420 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51421 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51425 +4 4 4 4 4 4
51426 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51427 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51428 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51429 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51430 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51431 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51432 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51433 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51434 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51435 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51439 +4 4 4 4 4 4
51440 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51441 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51442 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51443 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51444 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51445 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51446 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51447 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51448 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51449 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51453 +4 4 4 4 4 4
51454 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51455 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51456 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51457 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51458 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51459 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51460 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51461 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51462 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51467 +4 4 4 4 4 4
51468 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51469 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51470 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51471 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51472 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51473 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51474 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51475 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51476 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51481 +4 4 4 4 4 4
51482 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51483 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51484 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51485 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51486 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51487 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51488 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51489 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51490 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51495 +4 4 4 4 4 4
51496 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51497 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51498 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51499 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51500 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51501 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51502 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51503 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51509 +4 4 4 4 4 4
51510 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51511 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51512 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51513 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51514 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51515 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51516 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51517 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51523 +4 4 4 4 4 4
51524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51525 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51526 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51527 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51528 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51529 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51530 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51531 +4 0 0 4 3 3 6 6 6 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 4 4 4
51533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51537 +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 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51540 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51541 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51542 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51543 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51544 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51545 +6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51551 +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 5 5 5 5 5 5 5 5 5
51554 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51555 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51556 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51557 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51558 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51559 +5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
51562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51565 +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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51569 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51570 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51571 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51572 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51573 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4
51576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51579 +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 5 5 5
51583 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51584 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51585 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51586 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
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 4 4 4
51590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51593 +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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51598 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51599 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51600 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51607 +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 5 5 5 4 3 3 5 5 5 6 6 6
51612 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51613 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51614 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51621 +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 5 5 5 4 3 3 5 5 5
51626 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51627 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51628 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4
51633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 5 5 5
51640 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51641 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51642 +6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4
51647 +4 4 4 4 4 4 4 4 4 4 4 4 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
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 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51655 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51656 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51663 +4 4 4 4 4 4
51664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51668 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51669 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51670 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51677 +4 4 4 4 4 4
51678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51682 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51683 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51691 +4 4 4 4 4 4
51692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51696 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51697 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51705 +4 4 4 4 4 4
51706 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51707 index fe92eed..106e085 100644
51708 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51709 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51710 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51711 struct mb862xxfb_par *par = info->par;
51712
51713 if (info->var.bits_per_pixel == 32) {
51714 - info->fbops->fb_fillrect = cfb_fillrect;
51715 - info->fbops->fb_copyarea = cfb_copyarea;
51716 - info->fbops->fb_imageblit = cfb_imageblit;
51717 + pax_open_kernel();
51718 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51719 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51720 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51721 + pax_close_kernel();
51722 } else {
51723 outreg(disp, GC_L0EM, 3);
51724 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51725 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51726 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51727 + pax_open_kernel();
51728 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51729 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51730 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51731 + pax_close_kernel();
51732 }
51733 outreg(draw, GDC_REG_DRAW_BASE, 0);
51734 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51735 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51736 index ff22871..b129bed 100644
51737 --- a/drivers/video/nvidia/nvidia.c
51738 +++ b/drivers/video/nvidia/nvidia.c
51739 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51740 info->fix.line_length = (info->var.xres_virtual *
51741 info->var.bits_per_pixel) >> 3;
51742 if (info->var.accel_flags) {
51743 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51744 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51745 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51746 - info->fbops->fb_sync = nvidiafb_sync;
51747 + pax_open_kernel();
51748 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51749 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51750 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51751 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51752 + pax_close_kernel();
51753 info->pixmap.scan_align = 4;
51754 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51755 info->flags |= FBINFO_READS_FAST;
51756 NVResetGraphics(info);
51757 } else {
51758 - info->fbops->fb_imageblit = cfb_imageblit;
51759 - info->fbops->fb_fillrect = cfb_fillrect;
51760 - info->fbops->fb_copyarea = cfb_copyarea;
51761 - info->fbops->fb_sync = NULL;
51762 + pax_open_kernel();
51763 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51764 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51765 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51766 + *(void **)&info->fbops->fb_sync = NULL;
51767 + pax_close_kernel();
51768 info->pixmap.scan_align = 1;
51769 info->flags |= FBINFO_HWACCEL_DISABLED;
51770 info->flags &= ~FBINFO_READS_FAST;
51771 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51772 info->pixmap.size = 8 * 1024;
51773 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51774
51775 - if (!hwcur)
51776 - info->fbops->fb_cursor = NULL;
51777 + if (!hwcur) {
51778 + pax_open_kernel();
51779 + *(void **)&info->fbops->fb_cursor = NULL;
51780 + pax_close_kernel();
51781 + }
51782
51783 info->var.accel_flags = (!noaccel);
51784
51785 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51786 index 05c2dc3..ea1f391 100644
51787 --- a/drivers/video/s1d13xxxfb.c
51788 +++ b/drivers/video/s1d13xxxfb.c
51789 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51790
51791 switch(prod_id) {
51792 case S1D13506_PROD_ID: /* activate acceleration */
51793 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51794 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51795 + pax_open_kernel();
51796 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51797 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51798 + pax_close_kernel();
51799 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51800 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51801 break;
51802 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51803 index e188ada..aac63c8 100644
51804 --- a/drivers/video/smscufx.c
51805 +++ b/drivers/video/smscufx.c
51806 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51807 fb_deferred_io_cleanup(info);
51808 kfree(info->fbdefio);
51809 info->fbdefio = NULL;
51810 - info->fbops->fb_mmap = ufx_ops_mmap;
51811 + pax_open_kernel();
51812 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51813 + pax_close_kernel();
51814 }
51815
51816 pr_debug("released /dev/fb%d user=%d count=%d",
51817 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51818 index d2e5bc3..4cb05d1 100644
51819 --- a/drivers/video/udlfb.c
51820 +++ b/drivers/video/udlfb.c
51821 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51822 dlfb_urb_completion(urb);
51823
51824 error:
51825 - atomic_add(bytes_sent, &dev->bytes_sent);
51826 - atomic_add(bytes_identical, &dev->bytes_identical);
51827 - atomic_add(width*height*2, &dev->bytes_rendered);
51828 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51829 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51830 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51831 end_cycles = get_cycles();
51832 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51833 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51834 >> 10)), /* Kcycles */
51835 &dev->cpu_kcycles_used);
51836
51837 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51838 dlfb_urb_completion(urb);
51839
51840 error:
51841 - atomic_add(bytes_sent, &dev->bytes_sent);
51842 - atomic_add(bytes_identical, &dev->bytes_identical);
51843 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51844 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51845 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51846 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51847 end_cycles = get_cycles();
51848 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51849 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51850 >> 10)), /* Kcycles */
51851 &dev->cpu_kcycles_used);
51852 }
51853 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51854 fb_deferred_io_cleanup(info);
51855 kfree(info->fbdefio);
51856 info->fbdefio = NULL;
51857 - info->fbops->fb_mmap = dlfb_ops_mmap;
51858 + pax_open_kernel();
51859 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51860 + pax_close_kernel();
51861 }
51862
51863 pr_warn("released /dev/fb%d user=%d count=%d\n",
51864 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51865 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51866 struct dlfb_data *dev = fb_info->par;
51867 return snprintf(buf, PAGE_SIZE, "%u\n",
51868 - atomic_read(&dev->bytes_rendered));
51869 + atomic_read_unchecked(&dev->bytes_rendered));
51870 }
51871
51872 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51873 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51874 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51875 struct dlfb_data *dev = fb_info->par;
51876 return snprintf(buf, PAGE_SIZE, "%u\n",
51877 - atomic_read(&dev->bytes_identical));
51878 + atomic_read_unchecked(&dev->bytes_identical));
51879 }
51880
51881 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51882 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51883 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51884 struct dlfb_data *dev = fb_info->par;
51885 return snprintf(buf, PAGE_SIZE, "%u\n",
51886 - atomic_read(&dev->bytes_sent));
51887 + atomic_read_unchecked(&dev->bytes_sent));
51888 }
51889
51890 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51891 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51892 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51893 struct dlfb_data *dev = fb_info->par;
51894 return snprintf(buf, PAGE_SIZE, "%u\n",
51895 - atomic_read(&dev->cpu_kcycles_used));
51896 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51897 }
51898
51899 static ssize_t edid_show(
51900 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51901 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51902 struct dlfb_data *dev = fb_info->par;
51903
51904 - atomic_set(&dev->bytes_rendered, 0);
51905 - atomic_set(&dev->bytes_identical, 0);
51906 - atomic_set(&dev->bytes_sent, 0);
51907 - atomic_set(&dev->cpu_kcycles_used, 0);
51908 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51909 + atomic_set_unchecked(&dev->bytes_identical, 0);
51910 + atomic_set_unchecked(&dev->bytes_sent, 0);
51911 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51912
51913 return count;
51914 }
51915 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51916 index 7aec6f3..e3b2d55 100644
51917 --- a/drivers/video/uvesafb.c
51918 +++ b/drivers/video/uvesafb.c
51919 @@ -19,6 +19,7 @@
51920 #include <linux/io.h>
51921 #include <linux/mutex.h>
51922 #include <linux/slab.h>
51923 +#include <linux/moduleloader.h>
51924 #include <video/edid.h>
51925 #include <video/uvesafb.h>
51926 #ifdef CONFIG_X86
51927 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51928 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51929 par->pmi_setpal = par->ypan = 0;
51930 } else {
51931 +
51932 +#ifdef CONFIG_PAX_KERNEXEC
51933 +#ifdef CONFIG_MODULES
51934 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51935 +#endif
51936 + if (!par->pmi_code) {
51937 + par->pmi_setpal = par->ypan = 0;
51938 + return 0;
51939 + }
51940 +#endif
51941 +
51942 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51943 + task->t.regs.edi);
51944 +
51945 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51946 + pax_open_kernel();
51947 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51948 + pax_close_kernel();
51949 +
51950 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51951 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51952 +#else
51953 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51954 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51955 +#endif
51956 +
51957 printk(KERN_INFO "uvesafb: protected mode interface info at "
51958 "%04x:%04x\n",
51959 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51960 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51961 par->ypan = ypan;
51962
51963 if (par->pmi_setpal || par->ypan) {
51964 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51965 if (__supported_pte_mask & _PAGE_NX) {
51966 par->pmi_setpal = par->ypan = 0;
51967 printk(KERN_WARNING "uvesafb: NX protection is active, "
51968 "better not use the PMI.\n");
51969 - } else {
51970 + } else
51971 +#endif
51972 uvesafb_vbe_getpmi(task, par);
51973 - }
51974 }
51975 #else
51976 /* The protected mode interface is not available on non-x86. */
51977 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51978 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51979
51980 /* Disable blanking if the user requested so. */
51981 - if (!blank)
51982 - info->fbops->fb_blank = NULL;
51983 + if (!blank) {
51984 + pax_open_kernel();
51985 + *(void **)&info->fbops->fb_blank = NULL;
51986 + pax_close_kernel();
51987 + }
51988
51989 /*
51990 * Find out how much IO memory is required for the mode with
51991 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51992 info->flags = FBINFO_FLAG_DEFAULT |
51993 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51994
51995 - if (!par->ypan)
51996 - info->fbops->fb_pan_display = NULL;
51997 + if (!par->ypan) {
51998 + pax_open_kernel();
51999 + *(void **)&info->fbops->fb_pan_display = NULL;
52000 + pax_close_kernel();
52001 + }
52002 }
52003
52004 static void uvesafb_init_mtrr(struct fb_info *info)
52005 @@ -1796,6 +1826,11 @@ out:
52006 if (par->vbe_modes)
52007 kfree(par->vbe_modes);
52008
52009 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52010 + if (par->pmi_code)
52011 + module_free_exec(NULL, par->pmi_code);
52012 +#endif
52013 +
52014 framebuffer_release(info);
52015 return err;
52016 }
52017 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
52018 kfree(par->vbe_state_orig);
52019 if (par->vbe_state_saved)
52020 kfree(par->vbe_state_saved);
52021 +
52022 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52023 + if (par->pmi_code)
52024 + module_free_exec(NULL, par->pmi_code);
52025 +#endif
52026 +
52027 }
52028
52029 framebuffer_release(info);
52030 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
52031 index 501b340..d80aa17 100644
52032 --- a/drivers/video/vesafb.c
52033 +++ b/drivers/video/vesafb.c
52034 @@ -9,6 +9,7 @@
52035 */
52036
52037 #include <linux/module.h>
52038 +#include <linux/moduleloader.h>
52039 #include <linux/kernel.h>
52040 #include <linux/errno.h>
52041 #include <linux/string.h>
52042 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
52043 static int vram_total __initdata; /* Set total amount of memory */
52044 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52045 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52046 -static void (*pmi_start)(void) __read_mostly;
52047 -static void (*pmi_pal) (void) __read_mostly;
52048 +static void (*pmi_start)(void) __read_only;
52049 +static void (*pmi_pal) (void) __read_only;
52050 static int depth __read_mostly;
52051 static int vga_compat __read_mostly;
52052 /* --------------------------------------------------------------------- */
52053 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
52054 unsigned int size_vmode;
52055 unsigned int size_remap;
52056 unsigned int size_total;
52057 + void *pmi_code = NULL;
52058
52059 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
52060 return -ENODEV;
52061 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
52062 size_remap = size_total;
52063 vesafb_fix.smem_len = size_remap;
52064
52065 -#ifndef __i386__
52066 - screen_info.vesapm_seg = 0;
52067 -#endif
52068 -
52069 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52070 printk(KERN_WARNING
52071 "vesafb: cannot reserve video memory at 0x%lx\n",
52072 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
52073 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52074 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52075
52076 +#ifdef __i386__
52077 +
52078 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52079 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52080 + if (!pmi_code)
52081 +#elif !defined(CONFIG_PAX_KERNEXEC)
52082 + if (0)
52083 +#endif
52084 +
52085 +#endif
52086 + screen_info.vesapm_seg = 0;
52087 +
52088 if (screen_info.vesapm_seg) {
52089 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52090 - screen_info.vesapm_seg,screen_info.vesapm_off);
52091 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52092 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52093 }
52094
52095 if (screen_info.vesapm_seg < 0xc000)
52096 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
52097
52098 if (ypan || pmi_setpal) {
52099 unsigned short *pmi_base;
52100 +
52101 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
52102 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
52103 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52104 +
52105 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52106 + pax_open_kernel();
52107 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52108 +#else
52109 + pmi_code = pmi_base;
52110 +#endif
52111 +
52112 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52113 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52114 +
52115 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52116 + pmi_start = ktva_ktla(pmi_start);
52117 + pmi_pal = ktva_ktla(pmi_pal);
52118 + pax_close_kernel();
52119 +#endif
52120 +
52121 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52122 if (pmi_base[3]) {
52123 printk(KERN_INFO "vesafb: pmi: ports = ");
52124 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52125 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52126 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52127
52128 - if (!ypan)
52129 - info->fbops->fb_pan_display = NULL;
52130 + if (!ypan) {
52131 + pax_open_kernel();
52132 + *(void **)&info->fbops->fb_pan_display = NULL;
52133 + pax_close_kernel();
52134 + }
52135
52136 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52137 err = -ENOMEM;
52138 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52139 info->node, info->fix.id);
52140 return 0;
52141 err:
52142 +
52143 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52144 + module_free_exec(NULL, pmi_code);
52145 +#endif
52146 +
52147 if (info->screen_base)
52148 iounmap(info->screen_base);
52149 framebuffer_release(info);
52150 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52151 index 88714ae..16c2e11 100644
52152 --- a/drivers/video/via/via_clock.h
52153 +++ b/drivers/video/via/via_clock.h
52154 @@ -56,7 +56,7 @@ struct via_clock {
52155
52156 void (*set_engine_pll_state)(u8 state);
52157 void (*set_engine_pll)(struct via_pll_config config);
52158 -};
52159 +} __no_const;
52160
52161
52162 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52163 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52164 index fef20db..d28b1ab 100644
52165 --- a/drivers/xen/xenfs/xenstored.c
52166 +++ b/drivers/xen/xenfs/xenstored.c
52167 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52168 static int xsd_kva_open(struct inode *inode, struct file *file)
52169 {
52170 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52171 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52172 + NULL);
52173 +#else
52174 xen_store_interface);
52175 +#endif
52176 +
52177 if (!file->private_data)
52178 return -ENOMEM;
52179 return 0;
52180 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52181 index 9ff073f..05cef23 100644
52182 --- a/fs/9p/vfs_addr.c
52183 +++ b/fs/9p/vfs_addr.c
52184 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52185
52186 retval = v9fs_file_write_internal(inode,
52187 v9inode->writeback_fid,
52188 - (__force const char __user *)buffer,
52189 + (const char __force_user *)buffer,
52190 len, &offset, 0);
52191 if (retval > 0)
52192 retval = 0;
52193 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52194 index 25b018e..b941525 100644
52195 --- a/fs/9p/vfs_inode.c
52196 +++ b/fs/9p/vfs_inode.c
52197 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52198 void
52199 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52200 {
52201 - char *s = nd_get_link(nd);
52202 + const char *s = nd_get_link(nd);
52203
52204 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52205 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52206 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52207 index 370b24c..ff0be7b 100644
52208 --- a/fs/Kconfig.binfmt
52209 +++ b/fs/Kconfig.binfmt
52210 @@ -103,7 +103,7 @@ config HAVE_AOUT
52211
52212 config BINFMT_AOUT
52213 tristate "Kernel support for a.out and ECOFF binaries"
52214 - depends on HAVE_AOUT
52215 + depends on HAVE_AOUT && BROKEN
52216 ---help---
52217 A.out (Assembler.OUTput) is a set of formats for libraries and
52218 executables used in the earliest versions of UNIX. Linux used
52219 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52220 index 789bc25..fafaeea 100644
52221 --- a/fs/afs/inode.c
52222 +++ b/fs/afs/inode.c
52223 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52224 struct afs_vnode *vnode;
52225 struct super_block *sb;
52226 struct inode *inode;
52227 - static atomic_t afs_autocell_ino;
52228 + static atomic_unchecked_t afs_autocell_ino;
52229
52230 _enter("{%x:%u},%*.*s,",
52231 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52232 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52233 data.fid.unique = 0;
52234 data.fid.vnode = 0;
52235
52236 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52237 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52238 afs_iget5_autocell_test, afs_iget5_set,
52239 &data);
52240 if (!inode) {
52241 diff --git a/fs/aio.c b/fs/aio.c
52242 index 9b5ca11..c530886 100644
52243 --- a/fs/aio.c
52244 +++ b/fs/aio.c
52245 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52246 size += sizeof(struct io_event) * nr_events;
52247 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52248
52249 - if (nr_pages < 0)
52250 + if (nr_pages <= 0)
52251 return -EINVAL;
52252
52253 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52254 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52255 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52256 {
52257 ssize_t ret;
52258 + struct iovec iovstack;
52259
52260 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52261
52262 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52263 if (compat)
52264 ret = compat_rw_copy_check_uvector(rw,
52265 (struct compat_iovec __user *)kiocb->ki_buf,
52266 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52267 + kiocb->ki_nr_segs, 1, &iovstack,
52268 &kiocb->ki_iovec);
52269 else
52270 #endif
52271 ret = rw_copy_check_uvector(rw,
52272 (struct iovec __user *)kiocb->ki_buf,
52273 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52274 + kiocb->ki_nr_segs, 1, &iovstack,
52275 &kiocb->ki_iovec);
52276 if (ret < 0)
52277 return ret;
52278
52279 + if (kiocb->ki_iovec == &iovstack) {
52280 + kiocb->ki_inline_vec = iovstack;
52281 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52282 + }
52283 +
52284 /* ki_nbytes now reflect bytes instead of segs */
52285 kiocb->ki_nbytes = ret;
52286 return 0;
52287 diff --git a/fs/attr.c b/fs/attr.c
52288 index 1449adb..a2038c2 100644
52289 --- a/fs/attr.c
52290 +++ b/fs/attr.c
52291 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52292 unsigned long limit;
52293
52294 limit = rlimit(RLIMIT_FSIZE);
52295 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52296 if (limit != RLIM_INFINITY && offset > limit)
52297 goto out_sig;
52298 if (offset > inode->i_sb->s_maxbytes)
52299 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52300 index 3db70da..7aeec5b 100644
52301 --- a/fs/autofs4/waitq.c
52302 +++ b/fs/autofs4/waitq.c
52303 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52304 {
52305 unsigned long sigpipe, flags;
52306 mm_segment_t fs;
52307 - const char *data = (const char *)addr;
52308 + const char __user *data = (const char __force_user *)addr;
52309 ssize_t wr = 0;
52310
52311 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52312 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52313 return 1;
52314 }
52315
52316 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52317 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52318 +#endif
52319 +
52320 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52321 enum autofs_notify notify)
52322 {
52323 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52324
52325 /* If this is a direct mount request create a dummy name */
52326 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52327 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52328 + /* this name does get written to userland via autofs4_write() */
52329 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52330 +#else
52331 qstr.len = sprintf(name, "%p", dentry);
52332 +#endif
52333 else {
52334 qstr.len = autofs4_getpath(sbi, dentry, &name);
52335 if (!qstr.len) {
52336 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52337 index 2722387..c8dd2a7 100644
52338 --- a/fs/befs/endian.h
52339 +++ b/fs/befs/endian.h
52340 @@ -11,7 +11,7 @@
52341
52342 #include <asm/byteorder.h>
52343
52344 -static inline u64
52345 +static inline u64 __intentional_overflow(-1)
52346 fs64_to_cpu(const struct super_block *sb, fs64 n)
52347 {
52348 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52349 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52350 return (__force fs64)cpu_to_be64(n);
52351 }
52352
52353 -static inline u32
52354 +static inline u32 __intentional_overflow(-1)
52355 fs32_to_cpu(const struct super_block *sb, fs32 n)
52356 {
52357 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52358 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52359 index e9c75e2..1baece1 100644
52360 --- a/fs/befs/linuxvfs.c
52361 +++ b/fs/befs/linuxvfs.c
52362 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52363 {
52364 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52365 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52366 - char *link = nd_get_link(nd);
52367 + const char *link = nd_get_link(nd);
52368 if (!IS_ERR(link))
52369 kfree(link);
52370 }
52371 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52372 index 89dec7f..361b0d75 100644
52373 --- a/fs/binfmt_aout.c
52374 +++ b/fs/binfmt_aout.c
52375 @@ -16,6 +16,7 @@
52376 #include <linux/string.h>
52377 #include <linux/fs.h>
52378 #include <linux/file.h>
52379 +#include <linux/security.h>
52380 #include <linux/stat.h>
52381 #include <linux/fcntl.h>
52382 #include <linux/ptrace.h>
52383 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52384 #endif
52385 # define START_STACK(u) ((void __user *)u.start_stack)
52386
52387 + memset(&dump, 0, sizeof(dump));
52388 +
52389 fs = get_fs();
52390 set_fs(KERNEL_DS);
52391 has_dumped = 1;
52392 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52393
52394 /* If the size of the dump file exceeds the rlimit, then see what would happen
52395 if we wrote the stack, but not the data area. */
52396 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52397 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52398 dump.u_dsize = 0;
52399
52400 /* Make sure we have enough room to write the stack and data areas. */
52401 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52402 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52403 dump.u_ssize = 0;
52404
52405 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52406 rlim = rlimit(RLIMIT_DATA);
52407 if (rlim >= RLIM_INFINITY)
52408 rlim = ~0;
52409 +
52410 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52411 if (ex.a_data + ex.a_bss > rlim)
52412 return -ENOMEM;
52413
52414 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52415
52416 install_exec_creds(bprm);
52417
52418 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52419 + current->mm->pax_flags = 0UL;
52420 +#endif
52421 +
52422 +#ifdef CONFIG_PAX_PAGEEXEC
52423 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52424 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52425 +
52426 +#ifdef CONFIG_PAX_EMUTRAMP
52427 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52428 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52429 +#endif
52430 +
52431 +#ifdef CONFIG_PAX_MPROTECT
52432 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52433 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52434 +#endif
52435 +
52436 + }
52437 +#endif
52438 +
52439 if (N_MAGIC(ex) == OMAGIC) {
52440 unsigned long text_addr, map_size;
52441 loff_t pos;
52442 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52443 }
52444
52445 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52446 - PROT_READ | PROT_WRITE | PROT_EXEC,
52447 + PROT_READ | PROT_WRITE,
52448 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52449 fd_offset + ex.a_text);
52450 if (error != N_DATADDR(ex)) {
52451 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52452 index 100edcc..ed95731 100644
52453 --- a/fs/binfmt_elf.c
52454 +++ b/fs/binfmt_elf.c
52455 @@ -34,6 +34,7 @@
52456 #include <linux/utsname.h>
52457 #include <linux/coredump.h>
52458 #include <linux/sched.h>
52459 +#include <linux/xattr.h>
52460 #include <asm/uaccess.h>
52461 #include <asm/param.h>
52462 #include <asm/page.h>
52463 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52464 #define elf_core_dump NULL
52465 #endif
52466
52467 +#ifdef CONFIG_PAX_MPROTECT
52468 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52469 +#endif
52470 +
52471 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52472 +static void elf_handle_mmap(struct file *file);
52473 +#endif
52474 +
52475 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52476 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52477 #else
52478 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52479 .load_binary = load_elf_binary,
52480 .load_shlib = load_elf_library,
52481 .core_dump = elf_core_dump,
52482 +
52483 +#ifdef CONFIG_PAX_MPROTECT
52484 + .handle_mprotect= elf_handle_mprotect,
52485 +#endif
52486 +
52487 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52488 + .handle_mmap = elf_handle_mmap,
52489 +#endif
52490 +
52491 .min_coredump = ELF_EXEC_PAGESIZE,
52492 };
52493
52494 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52495
52496 static int set_brk(unsigned long start, unsigned long end)
52497 {
52498 + unsigned long e = end;
52499 +
52500 start = ELF_PAGEALIGN(start);
52501 end = ELF_PAGEALIGN(end);
52502 if (end > start) {
52503 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52504 if (BAD_ADDR(addr))
52505 return addr;
52506 }
52507 - current->mm->start_brk = current->mm->brk = end;
52508 + current->mm->start_brk = current->mm->brk = e;
52509 return 0;
52510 }
52511
52512 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52513 elf_addr_t __user *u_rand_bytes;
52514 const char *k_platform = ELF_PLATFORM;
52515 const char *k_base_platform = ELF_BASE_PLATFORM;
52516 - unsigned char k_rand_bytes[16];
52517 + u32 k_rand_bytes[4];
52518 int items;
52519 elf_addr_t *elf_info;
52520 int ei_index = 0;
52521 const struct cred *cred = current_cred();
52522 struct vm_area_struct *vma;
52523 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52524
52525 /*
52526 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52527 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52528 * Generate 16 random bytes for userspace PRNG seeding.
52529 */
52530 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52531 - u_rand_bytes = (elf_addr_t __user *)
52532 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52533 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52534 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52535 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52536 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52537 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52538 + u_rand_bytes = (elf_addr_t __user *) p;
52539 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52540 return -EFAULT;
52541
52542 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52543 return -EFAULT;
52544 current->mm->env_end = p;
52545
52546 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52547 +
52548 /* Put the elf_info on the stack in the right place. */
52549 sp = (elf_addr_t __user *)envp + 1;
52550 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52551 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52552 return -EFAULT;
52553 return 0;
52554 }
52555 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52556 an ELF header */
52557
52558 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52559 - struct file *interpreter, unsigned long *interp_map_addr,
52560 - unsigned long no_base)
52561 + struct file *interpreter, unsigned long no_base)
52562 {
52563 struct elf_phdr *elf_phdata;
52564 struct elf_phdr *eppnt;
52565 - unsigned long load_addr = 0;
52566 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52567 int load_addr_set = 0;
52568 unsigned long last_bss = 0, elf_bss = 0;
52569 - unsigned long error = ~0UL;
52570 + unsigned long error = -EINVAL;
52571 unsigned long total_size;
52572 int retval, i, size;
52573
52574 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52575 goto out_close;
52576 }
52577
52578 +#ifdef CONFIG_PAX_SEGMEXEC
52579 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52580 + pax_task_size = SEGMEXEC_TASK_SIZE;
52581 +#endif
52582 +
52583 eppnt = elf_phdata;
52584 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52585 if (eppnt->p_type == PT_LOAD) {
52586 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52587 map_addr = elf_map(interpreter, load_addr + vaddr,
52588 eppnt, elf_prot, elf_type, total_size);
52589 total_size = 0;
52590 - if (!*interp_map_addr)
52591 - *interp_map_addr = map_addr;
52592 error = map_addr;
52593 if (BAD_ADDR(map_addr))
52594 goto out_close;
52595 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52596 k = load_addr + eppnt->p_vaddr;
52597 if (BAD_ADDR(k) ||
52598 eppnt->p_filesz > eppnt->p_memsz ||
52599 - eppnt->p_memsz > TASK_SIZE ||
52600 - TASK_SIZE - eppnt->p_memsz < k) {
52601 + eppnt->p_memsz > pax_task_size ||
52602 + pax_task_size - eppnt->p_memsz < k) {
52603 error = -ENOMEM;
52604 goto out_close;
52605 }
52606 @@ -538,6 +567,315 @@ out:
52607 return error;
52608 }
52609
52610 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52611 +#ifdef CONFIG_PAX_SOFTMODE
52612 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52613 +{
52614 + unsigned long pax_flags = 0UL;
52615 +
52616 +#ifdef CONFIG_PAX_PAGEEXEC
52617 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52618 + pax_flags |= MF_PAX_PAGEEXEC;
52619 +#endif
52620 +
52621 +#ifdef CONFIG_PAX_SEGMEXEC
52622 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52623 + pax_flags |= MF_PAX_SEGMEXEC;
52624 +#endif
52625 +
52626 +#ifdef CONFIG_PAX_EMUTRAMP
52627 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52628 + pax_flags |= MF_PAX_EMUTRAMP;
52629 +#endif
52630 +
52631 +#ifdef CONFIG_PAX_MPROTECT
52632 + if (elf_phdata->p_flags & PF_MPROTECT)
52633 + pax_flags |= MF_PAX_MPROTECT;
52634 +#endif
52635 +
52636 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52637 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52638 + pax_flags |= MF_PAX_RANDMMAP;
52639 +#endif
52640 +
52641 + return pax_flags;
52642 +}
52643 +#endif
52644 +
52645 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52646 +{
52647 + unsigned long pax_flags = 0UL;
52648 +
52649 +#ifdef CONFIG_PAX_PAGEEXEC
52650 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52651 + pax_flags |= MF_PAX_PAGEEXEC;
52652 +#endif
52653 +
52654 +#ifdef CONFIG_PAX_SEGMEXEC
52655 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52656 + pax_flags |= MF_PAX_SEGMEXEC;
52657 +#endif
52658 +
52659 +#ifdef CONFIG_PAX_EMUTRAMP
52660 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52661 + pax_flags |= MF_PAX_EMUTRAMP;
52662 +#endif
52663 +
52664 +#ifdef CONFIG_PAX_MPROTECT
52665 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52666 + pax_flags |= MF_PAX_MPROTECT;
52667 +#endif
52668 +
52669 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52670 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52671 + pax_flags |= MF_PAX_RANDMMAP;
52672 +#endif
52673 +
52674 + return pax_flags;
52675 +}
52676 +#endif
52677 +
52678 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52679 +#ifdef CONFIG_PAX_SOFTMODE
52680 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52681 +{
52682 + unsigned long pax_flags = 0UL;
52683 +
52684 +#ifdef CONFIG_PAX_PAGEEXEC
52685 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52686 + pax_flags |= MF_PAX_PAGEEXEC;
52687 +#endif
52688 +
52689 +#ifdef CONFIG_PAX_SEGMEXEC
52690 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52691 + pax_flags |= MF_PAX_SEGMEXEC;
52692 +#endif
52693 +
52694 +#ifdef CONFIG_PAX_EMUTRAMP
52695 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52696 + pax_flags |= MF_PAX_EMUTRAMP;
52697 +#endif
52698 +
52699 +#ifdef CONFIG_PAX_MPROTECT
52700 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52701 + pax_flags |= MF_PAX_MPROTECT;
52702 +#endif
52703 +
52704 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52705 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52706 + pax_flags |= MF_PAX_RANDMMAP;
52707 +#endif
52708 +
52709 + return pax_flags;
52710 +}
52711 +#endif
52712 +
52713 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52714 +{
52715 + unsigned long pax_flags = 0UL;
52716 +
52717 +#ifdef CONFIG_PAX_PAGEEXEC
52718 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52719 + pax_flags |= MF_PAX_PAGEEXEC;
52720 +#endif
52721 +
52722 +#ifdef CONFIG_PAX_SEGMEXEC
52723 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52724 + pax_flags |= MF_PAX_SEGMEXEC;
52725 +#endif
52726 +
52727 +#ifdef CONFIG_PAX_EMUTRAMP
52728 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52729 + pax_flags |= MF_PAX_EMUTRAMP;
52730 +#endif
52731 +
52732 +#ifdef CONFIG_PAX_MPROTECT
52733 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52734 + pax_flags |= MF_PAX_MPROTECT;
52735 +#endif
52736 +
52737 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52738 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52739 + pax_flags |= MF_PAX_RANDMMAP;
52740 +#endif
52741 +
52742 + return pax_flags;
52743 +}
52744 +#endif
52745 +
52746 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52747 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52748 +{
52749 + unsigned long pax_flags = 0UL;
52750 +
52751 +#ifdef CONFIG_PAX_EI_PAX
52752 +
52753 +#ifdef CONFIG_PAX_PAGEEXEC
52754 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52755 + pax_flags |= MF_PAX_PAGEEXEC;
52756 +#endif
52757 +
52758 +#ifdef CONFIG_PAX_SEGMEXEC
52759 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52760 + pax_flags |= MF_PAX_SEGMEXEC;
52761 +#endif
52762 +
52763 +#ifdef CONFIG_PAX_EMUTRAMP
52764 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52765 + pax_flags |= MF_PAX_EMUTRAMP;
52766 +#endif
52767 +
52768 +#ifdef CONFIG_PAX_MPROTECT
52769 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52770 + pax_flags |= MF_PAX_MPROTECT;
52771 +#endif
52772 +
52773 +#ifdef CONFIG_PAX_ASLR
52774 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52775 + pax_flags |= MF_PAX_RANDMMAP;
52776 +#endif
52777 +
52778 +#else
52779 +
52780 +#ifdef CONFIG_PAX_PAGEEXEC
52781 + pax_flags |= MF_PAX_PAGEEXEC;
52782 +#endif
52783 +
52784 +#ifdef CONFIG_PAX_SEGMEXEC
52785 + pax_flags |= MF_PAX_SEGMEXEC;
52786 +#endif
52787 +
52788 +#ifdef CONFIG_PAX_MPROTECT
52789 + pax_flags |= MF_PAX_MPROTECT;
52790 +#endif
52791 +
52792 +#ifdef CONFIG_PAX_RANDMMAP
52793 + if (randomize_va_space)
52794 + pax_flags |= MF_PAX_RANDMMAP;
52795 +#endif
52796 +
52797 +#endif
52798 +
52799 + return pax_flags;
52800 +}
52801 +
52802 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52803 +{
52804 +
52805 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52806 + unsigned long i;
52807 +
52808 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52809 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52810 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52811 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52812 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52813 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52814 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52815 + return ~0UL;
52816 +
52817 +#ifdef CONFIG_PAX_SOFTMODE
52818 + if (pax_softmode)
52819 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52820 + else
52821 +#endif
52822 +
52823 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52824 + break;
52825 + }
52826 +#endif
52827 +
52828 + return ~0UL;
52829 +}
52830 +
52831 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52832 +{
52833 +
52834 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52835 + ssize_t xattr_size, i;
52836 + unsigned char xattr_value[sizeof("pemrs") - 1];
52837 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52838 +
52839 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52840 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52841 + return ~0UL;
52842 +
52843 + for (i = 0; i < xattr_size; i++)
52844 + switch (xattr_value[i]) {
52845 + default:
52846 + return ~0UL;
52847 +
52848 +#define parse_flag(option1, option2, flag) \
52849 + case option1: \
52850 + if (pax_flags_hardmode & MF_PAX_##flag) \
52851 + return ~0UL; \
52852 + pax_flags_hardmode |= MF_PAX_##flag; \
52853 + break; \
52854 + case option2: \
52855 + if (pax_flags_softmode & MF_PAX_##flag) \
52856 + return ~0UL; \
52857 + pax_flags_softmode |= MF_PAX_##flag; \
52858 + break;
52859 +
52860 + parse_flag('p', 'P', PAGEEXEC);
52861 + parse_flag('e', 'E', EMUTRAMP);
52862 + parse_flag('m', 'M', MPROTECT);
52863 + parse_flag('r', 'R', RANDMMAP);
52864 + parse_flag('s', 'S', SEGMEXEC);
52865 +
52866 +#undef parse_flag
52867 + }
52868 +
52869 + if (pax_flags_hardmode & pax_flags_softmode)
52870 + return ~0UL;
52871 +
52872 +#ifdef CONFIG_PAX_SOFTMODE
52873 + if (pax_softmode)
52874 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52875 + else
52876 +#endif
52877 +
52878 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52879 +#else
52880 + return ~0UL;
52881 +#endif
52882 +
52883 +}
52884 +
52885 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52886 +{
52887 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52888 +
52889 + pax_flags = pax_parse_ei_pax(elf_ex);
52890 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52891 + xattr_pax_flags = pax_parse_xattr_pax(file);
52892 +
52893 + if (pt_pax_flags == ~0UL)
52894 + pt_pax_flags = xattr_pax_flags;
52895 + else if (xattr_pax_flags == ~0UL)
52896 + xattr_pax_flags = pt_pax_flags;
52897 + if (pt_pax_flags != xattr_pax_flags)
52898 + return -EINVAL;
52899 + if (pt_pax_flags != ~0UL)
52900 + pax_flags = pt_pax_flags;
52901 +
52902 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52903 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52904 + if ((__supported_pte_mask & _PAGE_NX))
52905 + pax_flags &= ~MF_PAX_SEGMEXEC;
52906 + else
52907 + pax_flags &= ~MF_PAX_PAGEEXEC;
52908 + }
52909 +#endif
52910 +
52911 + if (0 > pax_check_flags(&pax_flags))
52912 + return -EINVAL;
52913 +
52914 + current->mm->pax_flags = pax_flags;
52915 + return 0;
52916 +}
52917 +#endif
52918 +
52919 /*
52920 * These are the functions used to load ELF style executables and shared
52921 * libraries. There is no binary dependent code anywhere else.
52922 @@ -554,6 +892,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52923 {
52924 unsigned int random_variable = 0;
52925
52926 +#ifdef CONFIG_PAX_RANDUSTACK
52927 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52928 + return stack_top - current->mm->delta_stack;
52929 +#endif
52930 +
52931 if ((current->flags & PF_RANDOMIZE) &&
52932 !(current->personality & ADDR_NO_RANDOMIZE)) {
52933 random_variable = get_random_int() & STACK_RND_MASK;
52934 @@ -572,7 +915,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52935 unsigned long load_addr = 0, load_bias = 0;
52936 int load_addr_set = 0;
52937 char * elf_interpreter = NULL;
52938 - unsigned long error;
52939 + unsigned long error = 0;
52940 struct elf_phdr *elf_ppnt, *elf_phdata;
52941 unsigned long elf_bss, elf_brk;
52942 int retval, i;
52943 @@ -582,12 +925,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52944 unsigned long start_code, end_code, start_data, end_data;
52945 unsigned long reloc_func_desc __maybe_unused = 0;
52946 int executable_stack = EXSTACK_DEFAULT;
52947 - unsigned long def_flags = 0;
52948 struct pt_regs *regs = current_pt_regs();
52949 struct {
52950 struct elfhdr elf_ex;
52951 struct elfhdr interp_elf_ex;
52952 } *loc;
52953 + unsigned long pax_task_size = TASK_SIZE;
52954
52955 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52956 if (!loc) {
52957 @@ -723,11 +1066,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52958 goto out_free_dentry;
52959
52960 /* OK, This is the point of no return */
52961 - current->mm->def_flags = def_flags;
52962 +
52963 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52964 + current->mm->pax_flags = 0UL;
52965 +#endif
52966 +
52967 +#ifdef CONFIG_PAX_DLRESOLVE
52968 + current->mm->call_dl_resolve = 0UL;
52969 +#endif
52970 +
52971 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52972 + current->mm->call_syscall = 0UL;
52973 +#endif
52974 +
52975 +#ifdef CONFIG_PAX_ASLR
52976 + current->mm->delta_mmap = 0UL;
52977 + current->mm->delta_stack = 0UL;
52978 +#endif
52979 +
52980 + current->mm->def_flags = 0;
52981 +
52982 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52983 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52984 + send_sig(SIGKILL, current, 0);
52985 + goto out_free_dentry;
52986 + }
52987 +#endif
52988 +
52989 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52990 + pax_set_initial_flags(bprm);
52991 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52992 + if (pax_set_initial_flags_func)
52993 + (pax_set_initial_flags_func)(bprm);
52994 +#endif
52995 +
52996 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52997 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52998 + current->mm->context.user_cs_limit = PAGE_SIZE;
52999 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
53000 + }
53001 +#endif
53002 +
53003 +#ifdef CONFIG_PAX_SEGMEXEC
53004 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
53005 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
53006 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
53007 + pax_task_size = SEGMEXEC_TASK_SIZE;
53008 + current->mm->def_flags |= VM_NOHUGEPAGE;
53009 + }
53010 +#endif
53011 +
53012 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
53013 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53014 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
53015 + put_cpu();
53016 + }
53017 +#endif
53018
53019 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53020 may depend on the personality. */
53021 SET_PERSONALITY(loc->elf_ex);
53022 +
53023 +#ifdef CONFIG_PAX_ASLR
53024 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53025 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
53026 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
53027 + }
53028 +#endif
53029 +
53030 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53031 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53032 + executable_stack = EXSTACK_DISABLE_X;
53033 + current->personality &= ~READ_IMPLIES_EXEC;
53034 + } else
53035 +#endif
53036 +
53037 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53038 current->personality |= READ_IMPLIES_EXEC;
53039
53040 @@ -817,6 +1230,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53041 #else
53042 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53043 #endif
53044 +
53045 +#ifdef CONFIG_PAX_RANDMMAP
53046 + /* PaX: randomize base address at the default exe base if requested */
53047 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53048 +#ifdef CONFIG_SPARC64
53049 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53050 +#else
53051 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53052 +#endif
53053 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53054 + elf_flags |= MAP_FIXED;
53055 + }
53056 +#endif
53057 +
53058 }
53059
53060 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53061 @@ -849,9 +1276,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53062 * allowed task size. Note that p_filesz must always be
53063 * <= p_memsz so it is only necessary to check p_memsz.
53064 */
53065 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53066 - elf_ppnt->p_memsz > TASK_SIZE ||
53067 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53068 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53069 + elf_ppnt->p_memsz > pax_task_size ||
53070 + pax_task_size - elf_ppnt->p_memsz < k) {
53071 /* set_brk can never work. Avoid overflows. */
53072 send_sig(SIGKILL, current, 0);
53073 retval = -EINVAL;
53074 @@ -890,17 +1317,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53075 goto out_free_dentry;
53076 }
53077 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53078 - send_sig(SIGSEGV, current, 0);
53079 - retval = -EFAULT; /* Nobody gets to see this, but.. */
53080 - goto out_free_dentry;
53081 + /*
53082 + * This bss-zeroing can fail if the ELF
53083 + * file specifies odd protections. So
53084 + * we don't check the return value
53085 + */
53086 }
53087
53088 +#ifdef CONFIG_PAX_RANDMMAP
53089 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53090 + unsigned long start, size, flags;
53091 + vm_flags_t vm_flags;
53092 +
53093 + start = ELF_PAGEALIGN(elf_brk);
53094 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53095 + flags = MAP_FIXED | MAP_PRIVATE;
53096 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53097 +
53098 + down_write(&current->mm->mmap_sem);
53099 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53100 + retval = -ENOMEM;
53101 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53102 +// if (current->personality & ADDR_NO_RANDOMIZE)
53103 +// vm_flags |= VM_READ | VM_MAYREAD;
53104 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53105 + retval = IS_ERR_VALUE(start) ? start : 0;
53106 + }
53107 + up_write(&current->mm->mmap_sem);
53108 + if (retval == 0)
53109 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53110 + if (retval < 0) {
53111 + send_sig(SIGKILL, current, 0);
53112 + goto out_free_dentry;
53113 + }
53114 + }
53115 +#endif
53116 +
53117 if (elf_interpreter) {
53118 - unsigned long interp_map_addr = 0;
53119 -
53120 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53121 interpreter,
53122 - &interp_map_addr,
53123 load_bias);
53124 if (!IS_ERR((void *)elf_entry)) {
53125 /*
53126 @@ -1122,7 +1577,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53127 * Decide what to dump of a segment, part, all or none.
53128 */
53129 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53130 - unsigned long mm_flags)
53131 + unsigned long mm_flags, long signr)
53132 {
53133 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53134
53135 @@ -1160,7 +1615,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53136 if (vma->vm_file == NULL)
53137 return 0;
53138
53139 - if (FILTER(MAPPED_PRIVATE))
53140 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53141 goto whole;
53142
53143 /*
53144 @@ -1385,9 +1840,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53145 {
53146 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53147 int i = 0;
53148 - do
53149 + do {
53150 i += 2;
53151 - while (auxv[i - 2] != AT_NULL);
53152 + } while (auxv[i - 2] != AT_NULL);
53153 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53154 }
53155
53156 @@ -1396,7 +1851,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53157 {
53158 mm_segment_t old_fs = get_fs();
53159 set_fs(KERNEL_DS);
53160 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53161 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53162 set_fs(old_fs);
53163 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53164 }
53165 @@ -2017,14 +2472,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53166 }
53167
53168 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53169 - unsigned long mm_flags)
53170 + struct coredump_params *cprm)
53171 {
53172 struct vm_area_struct *vma;
53173 size_t size = 0;
53174
53175 for (vma = first_vma(current, gate_vma); vma != NULL;
53176 vma = next_vma(vma, gate_vma))
53177 - size += vma_dump_size(vma, mm_flags);
53178 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53179 return size;
53180 }
53181
53182 @@ -2117,7 +2572,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53183
53184 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53185
53186 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53187 + offset += elf_core_vma_data_size(gate_vma, cprm);
53188 offset += elf_core_extra_data_size();
53189 e_shoff = offset;
53190
53191 @@ -2131,10 +2586,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53192 offset = dataoff;
53193
53194 size += sizeof(*elf);
53195 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53196 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53197 goto end_coredump;
53198
53199 size += sizeof(*phdr4note);
53200 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53201 if (size > cprm->limit
53202 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53203 goto end_coredump;
53204 @@ -2148,7 +2605,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53205 phdr.p_offset = offset;
53206 phdr.p_vaddr = vma->vm_start;
53207 phdr.p_paddr = 0;
53208 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53209 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53210 phdr.p_memsz = vma->vm_end - vma->vm_start;
53211 offset += phdr.p_filesz;
53212 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53213 @@ -2159,6 +2616,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53214 phdr.p_align = ELF_EXEC_PAGESIZE;
53215
53216 size += sizeof(phdr);
53217 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53218 if (size > cprm->limit
53219 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53220 goto end_coredump;
53221 @@ -2183,7 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53222 unsigned long addr;
53223 unsigned long end;
53224
53225 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53226 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53227
53228 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53229 struct page *page;
53230 @@ -2192,6 +2650,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53231 page = get_dump_page(addr);
53232 if (page) {
53233 void *kaddr = kmap(page);
53234 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53235 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53236 !dump_write(cprm->file, kaddr,
53237 PAGE_SIZE);
53238 @@ -2209,6 +2668,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53239
53240 if (e_phnum == PN_XNUM) {
53241 size += sizeof(*shdr4extnum);
53242 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53243 if (size > cprm->limit
53244 || !dump_write(cprm->file, shdr4extnum,
53245 sizeof(*shdr4extnum)))
53246 @@ -2229,6 +2689,167 @@ out:
53247
53248 #endif /* CONFIG_ELF_CORE */
53249
53250 +#ifdef CONFIG_PAX_MPROTECT
53251 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53252 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53253 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53254 + *
53255 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53256 + * basis because we want to allow the common case and not the special ones.
53257 + */
53258 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53259 +{
53260 + struct elfhdr elf_h;
53261 + struct elf_phdr elf_p;
53262 + unsigned long i;
53263 + unsigned long oldflags;
53264 + bool is_textrel_rw, is_textrel_rx, is_relro;
53265 +
53266 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53267 + return;
53268 +
53269 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53270 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53271 +
53272 +#ifdef CONFIG_PAX_ELFRELOCS
53273 + /* possible TEXTREL */
53274 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53275 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53276 +#else
53277 + is_textrel_rw = false;
53278 + is_textrel_rx = false;
53279 +#endif
53280 +
53281 + /* possible RELRO */
53282 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53283 +
53284 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53285 + return;
53286 +
53287 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53288 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53289 +
53290 +#ifdef CONFIG_PAX_ETEXECRELOCS
53291 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53292 +#else
53293 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53294 +#endif
53295 +
53296 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53297 + !elf_check_arch(&elf_h) ||
53298 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53299 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53300 + return;
53301 +
53302 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53303 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53304 + return;
53305 + switch (elf_p.p_type) {
53306 + case PT_DYNAMIC:
53307 + if (!is_textrel_rw && !is_textrel_rx)
53308 + continue;
53309 + i = 0UL;
53310 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53311 + elf_dyn dyn;
53312 +
53313 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53314 + break;
53315 + if (dyn.d_tag == DT_NULL)
53316 + break;
53317 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53318 + gr_log_textrel(vma);
53319 + if (is_textrel_rw)
53320 + vma->vm_flags |= VM_MAYWRITE;
53321 + else
53322 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53323 + vma->vm_flags &= ~VM_MAYWRITE;
53324 + break;
53325 + }
53326 + i++;
53327 + }
53328 + is_textrel_rw = false;
53329 + is_textrel_rx = false;
53330 + continue;
53331 +
53332 + case PT_GNU_RELRO:
53333 + if (!is_relro)
53334 + continue;
53335 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53336 + vma->vm_flags &= ~VM_MAYWRITE;
53337 + is_relro = false;
53338 + continue;
53339 +
53340 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53341 + case PT_PAX_FLAGS: {
53342 + const char *msg_mprotect = "", *msg_emutramp = "";
53343 + char *buffer_lib, *buffer_exe;
53344 +
53345 + if (elf_p.p_flags & PF_NOMPROTECT)
53346 + msg_mprotect = "MPROTECT disabled";
53347 +
53348 +#ifdef CONFIG_PAX_EMUTRAMP
53349 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53350 + msg_emutramp = "EMUTRAMP enabled";
53351 +#endif
53352 +
53353 + if (!msg_mprotect[0] && !msg_emutramp[0])
53354 + continue;
53355 +
53356 + if (!printk_ratelimit())
53357 + continue;
53358 +
53359 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53360 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53361 + if (buffer_lib && buffer_exe) {
53362 + char *path_lib, *path_exe;
53363 +
53364 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53365 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53366 +
53367 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53368 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53369 +
53370 + }
53371 + free_page((unsigned long)buffer_exe);
53372 + free_page((unsigned long)buffer_lib);
53373 + continue;
53374 + }
53375 +#endif
53376 +
53377 + }
53378 + }
53379 +}
53380 +#endif
53381 +
53382 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53383 +
53384 +extern int grsec_enable_log_rwxmaps;
53385 +
53386 +static void elf_handle_mmap(struct file *file)
53387 +{
53388 + struct elfhdr elf_h;
53389 + struct elf_phdr elf_p;
53390 + unsigned long i;
53391 +
53392 + if (!grsec_enable_log_rwxmaps)
53393 + return;
53394 +
53395 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53396 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53397 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53398 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53399 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53400 + return;
53401 +
53402 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53403 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53404 + return;
53405 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53406 + gr_log_ptgnustack(file);
53407 + }
53408 +}
53409 +#endif
53410 +
53411 static int __init init_elf_binfmt(void)
53412 {
53413 register_binfmt(&elf_format);
53414 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53415 index d50bbe5..af3b649 100644
53416 --- a/fs/binfmt_flat.c
53417 +++ b/fs/binfmt_flat.c
53418 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53419 realdatastart = (unsigned long) -ENOMEM;
53420 printk("Unable to allocate RAM for process data, errno %d\n",
53421 (int)-realdatastart);
53422 + down_write(&current->mm->mmap_sem);
53423 vm_munmap(textpos, text_len);
53424 + up_write(&current->mm->mmap_sem);
53425 ret = realdatastart;
53426 goto err;
53427 }
53428 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53429 }
53430 if (IS_ERR_VALUE(result)) {
53431 printk("Unable to read data+bss, errno %d\n", (int)-result);
53432 + down_write(&current->mm->mmap_sem);
53433 vm_munmap(textpos, text_len);
53434 vm_munmap(realdatastart, len);
53435 + up_write(&current->mm->mmap_sem);
53436 ret = result;
53437 goto err;
53438 }
53439 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53440 }
53441 if (IS_ERR_VALUE(result)) {
53442 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53443 + down_write(&current->mm->mmap_sem);
53444 vm_munmap(textpos, text_len + data_len + extra +
53445 MAX_SHARED_LIBS * sizeof(unsigned long));
53446 + up_write(&current->mm->mmap_sem);
53447 ret = result;
53448 goto err;
53449 }
53450 diff --git a/fs/bio.c b/fs/bio.c
53451 index c5eae72..599e3cf 100644
53452 --- a/fs/bio.c
53453 +++ b/fs/bio.c
53454 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53455 /*
53456 * Overflow, abort
53457 */
53458 - if (end < start)
53459 + if (end < start || end - start > INT_MAX - nr_pages)
53460 return ERR_PTR(-EINVAL);
53461
53462 nr_pages += end - start;
53463 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53464 /*
53465 * Overflow, abort
53466 */
53467 - if (end < start)
53468 + if (end < start || end - start > INT_MAX - nr_pages)
53469 return ERR_PTR(-EINVAL);
53470
53471 nr_pages += end - start;
53472 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53473 const int read = bio_data_dir(bio) == READ;
53474 struct bio_map_data *bmd = bio->bi_private;
53475 int i;
53476 - char *p = bmd->sgvecs[0].iov_base;
53477 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53478
53479 bio_for_each_segment_all(bvec, bio, i) {
53480 char *addr = page_address(bvec->bv_page);
53481 diff --git a/fs/block_dev.c b/fs/block_dev.c
53482 index c7bda5c..2121e94 100644
53483 --- a/fs/block_dev.c
53484 +++ b/fs/block_dev.c
53485 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53486 else if (bdev->bd_contains == bdev)
53487 return true; /* is a whole device which isn't held */
53488
53489 - else if (whole->bd_holder == bd_may_claim)
53490 + else if (whole->bd_holder == (void *)bd_may_claim)
53491 return true; /* is a partition of a device that is being partitioned */
53492 else if (whole->bd_holder != NULL)
53493 return false; /* is a partition of a held device */
53494 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53495 index ed50460..fe84385 100644
53496 --- a/fs/btrfs/ctree.c
53497 +++ b/fs/btrfs/ctree.c
53498 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53499 free_extent_buffer(buf);
53500 add_root_to_dirty_list(root);
53501 } else {
53502 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53503 - parent_start = parent->start;
53504 - else
53505 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53506 + if (parent)
53507 + parent_start = parent->start;
53508 + else
53509 + parent_start = 0;
53510 + } else
53511 parent_start = 0;
53512
53513 WARN_ON(trans->transid != btrfs_header_generation(parent));
53514 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53515 index 3755109..e3d457f 100644
53516 --- a/fs/btrfs/delayed-inode.c
53517 +++ b/fs/btrfs/delayed-inode.c
53518 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53519
53520 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53521 {
53522 - int seq = atomic_inc_return(&delayed_root->items_seq);
53523 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53524 if ((atomic_dec_return(&delayed_root->items) <
53525 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53526 waitqueue_active(&delayed_root->wait))
53527 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53528 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53529 int seq, int count)
53530 {
53531 - int val = atomic_read(&delayed_root->items_seq);
53532 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53533
53534 if (val < seq || val >= seq + count)
53535 return 1;
53536 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53537 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53538 return;
53539
53540 - seq = atomic_read(&delayed_root->items_seq);
53541 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53542
53543 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53544 int ret;
53545 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53546 index a4b38f9..f86a509 100644
53547 --- a/fs/btrfs/delayed-inode.h
53548 +++ b/fs/btrfs/delayed-inode.h
53549 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53550 */
53551 struct list_head prepare_list;
53552 atomic_t items; /* for delayed items */
53553 - atomic_t items_seq; /* for delayed items */
53554 + atomic_unchecked_t items_seq; /* for delayed items */
53555 int nodes; /* for delayed nodes */
53556 wait_queue_head_t wait;
53557 };
53558 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53559 struct btrfs_delayed_root *delayed_root)
53560 {
53561 atomic_set(&delayed_root->items, 0);
53562 - atomic_set(&delayed_root->items_seq, 0);
53563 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53564 delayed_root->nodes = 0;
53565 spin_lock_init(&delayed_root->lock);
53566 init_waitqueue_head(&delayed_root->wait);
53567 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53568 index 238a055..1e33cd5 100644
53569 --- a/fs/btrfs/ioctl.c
53570 +++ b/fs/btrfs/ioctl.c
53571 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53572 for (i = 0; i < num_types; i++) {
53573 struct btrfs_space_info *tmp;
53574
53575 + /* Don't copy in more than we allocated */
53576 if (!slot_count)
53577 break;
53578
53579 + slot_count--;
53580 +
53581 info = NULL;
53582 rcu_read_lock();
53583 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53584 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53585 memcpy(dest, &space, sizeof(space));
53586 dest++;
53587 space_args.total_spaces++;
53588 - slot_count--;
53589 }
53590 - if (!slot_count)
53591 - break;
53592 }
53593 up_read(&info->groups_sem);
53594 }
53595 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53596 index 8eb6191..eda91e2 100644
53597 --- a/fs/btrfs/super.c
53598 +++ b/fs/btrfs/super.c
53599 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53600 function, line, errstr);
53601 return;
53602 }
53603 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53604 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53605 /* Wake up anybody who may be waiting on this transaction */
53606 wake_up(&root->fs_info->transaction_wait);
53607 wake_up(&root->fs_info->transaction_blocked_wait);
53608 diff --git a/fs/buffer.c b/fs/buffer.c
53609 index 4d74335..b0df7f9 100644
53610 --- a/fs/buffer.c
53611 +++ b/fs/buffer.c
53612 @@ -3416,7 +3416,7 @@ void __init buffer_init(void)
53613 bh_cachep = kmem_cache_create("buffer_head",
53614 sizeof(struct buffer_head), 0,
53615 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53616 - SLAB_MEM_SPREAD),
53617 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53618 NULL);
53619
53620 /*
53621 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53622 index 622f469..e8d2d55 100644
53623 --- a/fs/cachefiles/bind.c
53624 +++ b/fs/cachefiles/bind.c
53625 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53626 args);
53627
53628 /* start by checking things over */
53629 - ASSERT(cache->fstop_percent >= 0 &&
53630 - cache->fstop_percent < cache->fcull_percent &&
53631 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53632 cache->fcull_percent < cache->frun_percent &&
53633 cache->frun_percent < 100);
53634
53635 - ASSERT(cache->bstop_percent >= 0 &&
53636 - cache->bstop_percent < cache->bcull_percent &&
53637 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53638 cache->bcull_percent < cache->brun_percent &&
53639 cache->brun_percent < 100);
53640
53641 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53642 index 0a1467b..6a53245 100644
53643 --- a/fs/cachefiles/daemon.c
53644 +++ b/fs/cachefiles/daemon.c
53645 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53646 if (n > buflen)
53647 return -EMSGSIZE;
53648
53649 - if (copy_to_user(_buffer, buffer, n) != 0)
53650 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53651 return -EFAULT;
53652
53653 return n;
53654 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53655 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53656 return -EIO;
53657
53658 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53659 + if (datalen > PAGE_SIZE - 1)
53660 return -EOPNOTSUPP;
53661
53662 /* drag the command string into the kernel so we can parse it */
53663 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53664 if (args[0] != '%' || args[1] != '\0')
53665 return -EINVAL;
53666
53667 - if (fstop < 0 || fstop >= cache->fcull_percent)
53668 + if (fstop >= cache->fcull_percent)
53669 return cachefiles_daemon_range_error(cache, args);
53670
53671 cache->fstop_percent = fstop;
53672 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53673 if (args[0] != '%' || args[1] != '\0')
53674 return -EINVAL;
53675
53676 - if (bstop < 0 || bstop >= cache->bcull_percent)
53677 + if (bstop >= cache->bcull_percent)
53678 return cachefiles_daemon_range_error(cache, args);
53679
53680 cache->bstop_percent = bstop;
53681 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53682 index 4938251..7e01445 100644
53683 --- a/fs/cachefiles/internal.h
53684 +++ b/fs/cachefiles/internal.h
53685 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53686 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53687 struct rb_root active_nodes; /* active nodes (can't be culled) */
53688 rwlock_t active_lock; /* lock for active_nodes */
53689 - atomic_t gravecounter; /* graveyard uniquifier */
53690 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53691 unsigned frun_percent; /* when to stop culling (% files) */
53692 unsigned fcull_percent; /* when to start culling (% files) */
53693 unsigned fstop_percent; /* when to stop allocating (% files) */
53694 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53695 * proc.c
53696 */
53697 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53698 -extern atomic_t cachefiles_lookup_histogram[HZ];
53699 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53700 -extern atomic_t cachefiles_create_histogram[HZ];
53701 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53702 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53703 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53704
53705 extern int __init cachefiles_proc_init(void);
53706 extern void cachefiles_proc_cleanup(void);
53707 static inline
53708 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53709 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53710 {
53711 unsigned long jif = jiffies - start_jif;
53712 if (jif >= HZ)
53713 jif = HZ - 1;
53714 - atomic_inc(&histogram[jif]);
53715 + atomic_inc_unchecked(&histogram[jif]);
53716 }
53717
53718 #else
53719 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53720 index 25badd1..d70d918 100644
53721 --- a/fs/cachefiles/namei.c
53722 +++ b/fs/cachefiles/namei.c
53723 @@ -317,7 +317,7 @@ try_again:
53724 /* first step is to make up a grave dentry in the graveyard */
53725 sprintf(nbuffer, "%08x%08x",
53726 (uint32_t) get_seconds(),
53727 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53728 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53729
53730 /* do the multiway lock magic */
53731 trap = lock_rename(cache->graveyard, dir);
53732 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53733 index eccd339..4c1d995 100644
53734 --- a/fs/cachefiles/proc.c
53735 +++ b/fs/cachefiles/proc.c
53736 @@ -14,9 +14,9 @@
53737 #include <linux/seq_file.h>
53738 #include "internal.h"
53739
53740 -atomic_t cachefiles_lookup_histogram[HZ];
53741 -atomic_t cachefiles_mkdir_histogram[HZ];
53742 -atomic_t cachefiles_create_histogram[HZ];
53743 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53744 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53745 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53746
53747 /*
53748 * display the latency histogram
53749 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53750 return 0;
53751 default:
53752 index = (unsigned long) v - 3;
53753 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53754 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53755 - z = atomic_read(&cachefiles_create_histogram[index]);
53756 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53757 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53758 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53759 if (x == 0 && y == 0 && z == 0)
53760 return 0;
53761
53762 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53763 index ebaff36..7e3ea26 100644
53764 --- a/fs/cachefiles/rdwr.c
53765 +++ b/fs/cachefiles/rdwr.c
53766 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53767 old_fs = get_fs();
53768 set_fs(KERNEL_DS);
53769 ret = file->f_op->write(
53770 - file, (const void __user *) data, len, &pos);
53771 + file, (const void __force_user *) data, len, &pos);
53772 set_fs(old_fs);
53773 kunmap(page);
53774 file_end_write(file);
53775 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53776 index a40ceda..f43d17c 100644
53777 --- a/fs/ceph/dir.c
53778 +++ b/fs/ceph/dir.c
53779 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53780 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53781 struct ceph_mds_client *mdsc = fsc->mdsc;
53782 unsigned frag = fpos_frag(ctx->pos);
53783 - int off = fpos_off(ctx->pos);
53784 + unsigned int off = fpos_off(ctx->pos);
53785 int err;
53786 u32 ftype;
53787 struct ceph_mds_reply_info_parsed *rinfo;
53788 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53789 index 6627b26..634ec4b 100644
53790 --- a/fs/ceph/super.c
53791 +++ b/fs/ceph/super.c
53792 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53793 /*
53794 * construct our own bdi so we can control readahead, etc.
53795 */
53796 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53797 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53798
53799 static int ceph_register_bdi(struct super_block *sb,
53800 struct ceph_fs_client *fsc)
53801 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53802 default_backing_dev_info.ra_pages;
53803
53804 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53805 - atomic_long_inc_return(&bdi_seq));
53806 + atomic_long_inc_return_unchecked(&bdi_seq));
53807 if (!err)
53808 sb->s_bdi = &fsc->backing_dev_info;
53809 return err;
53810 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53811 index f3ac415..3d2420c 100644
53812 --- a/fs/cifs/cifs_debug.c
53813 +++ b/fs/cifs/cifs_debug.c
53814 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53815
53816 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53817 #ifdef CONFIG_CIFS_STATS2
53818 - atomic_set(&totBufAllocCount, 0);
53819 - atomic_set(&totSmBufAllocCount, 0);
53820 + atomic_set_unchecked(&totBufAllocCount, 0);
53821 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53822 #endif /* CONFIG_CIFS_STATS2 */
53823 spin_lock(&cifs_tcp_ses_lock);
53824 list_for_each(tmp1, &cifs_tcp_ses_list) {
53825 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53826 tcon = list_entry(tmp3,
53827 struct cifs_tcon,
53828 tcon_list);
53829 - atomic_set(&tcon->num_smbs_sent, 0);
53830 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53831 if (server->ops->clear_stats)
53832 server->ops->clear_stats(tcon);
53833 }
53834 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53835 smBufAllocCount.counter, cifs_min_small);
53836 #ifdef CONFIG_CIFS_STATS2
53837 seq_printf(m, "Total Large %d Small %d Allocations\n",
53838 - atomic_read(&totBufAllocCount),
53839 - atomic_read(&totSmBufAllocCount));
53840 + atomic_read_unchecked(&totBufAllocCount),
53841 + atomic_read_unchecked(&totSmBufAllocCount));
53842 #endif /* CONFIG_CIFS_STATS2 */
53843
53844 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53845 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53846 if (tcon->need_reconnect)
53847 seq_puts(m, "\tDISCONNECTED ");
53848 seq_printf(m, "\nSMBs: %d",
53849 - atomic_read(&tcon->num_smbs_sent));
53850 + atomic_read_unchecked(&tcon->num_smbs_sent));
53851 if (server->ops->print_stats)
53852 server->ops->print_stats(m, tcon);
53853 }
53854 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53855 index 85ea98d..b3ed4d6 100644
53856 --- a/fs/cifs/cifsfs.c
53857 +++ b/fs/cifs/cifsfs.c
53858 @@ -1037,7 +1037,7 @@ cifs_init_request_bufs(void)
53859 */
53860 cifs_req_cachep = kmem_cache_create("cifs_request",
53861 CIFSMaxBufSize + max_hdr_size, 0,
53862 - SLAB_HWCACHE_ALIGN, NULL);
53863 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53864 if (cifs_req_cachep == NULL)
53865 return -ENOMEM;
53866
53867 @@ -1064,7 +1064,7 @@ cifs_init_request_bufs(void)
53868 efficient to alloc 1 per page off the slab compared to 17K (5page)
53869 alloc of large cifs buffers even when page debugging is on */
53870 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53871 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53872 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53873 NULL);
53874 if (cifs_sm_req_cachep == NULL) {
53875 mempool_destroy(cifs_req_poolp);
53876 @@ -1149,8 +1149,8 @@ init_cifs(void)
53877 atomic_set(&bufAllocCount, 0);
53878 atomic_set(&smBufAllocCount, 0);
53879 #ifdef CONFIG_CIFS_STATS2
53880 - atomic_set(&totBufAllocCount, 0);
53881 - atomic_set(&totSmBufAllocCount, 0);
53882 + atomic_set_unchecked(&totBufAllocCount, 0);
53883 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53884 #endif /* CONFIG_CIFS_STATS2 */
53885
53886 atomic_set(&midCount, 0);
53887 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53888 index 52ca861..47f309c 100644
53889 --- a/fs/cifs/cifsglob.h
53890 +++ b/fs/cifs/cifsglob.h
53891 @@ -756,35 +756,35 @@ struct cifs_tcon {
53892 __u16 Flags; /* optional support bits */
53893 enum statusEnum tidStatus;
53894 #ifdef CONFIG_CIFS_STATS
53895 - atomic_t num_smbs_sent;
53896 + atomic_unchecked_t num_smbs_sent;
53897 union {
53898 struct {
53899 - atomic_t num_writes;
53900 - atomic_t num_reads;
53901 - atomic_t num_flushes;
53902 - atomic_t num_oplock_brks;
53903 - atomic_t num_opens;
53904 - atomic_t num_closes;
53905 - atomic_t num_deletes;
53906 - atomic_t num_mkdirs;
53907 - atomic_t num_posixopens;
53908 - atomic_t num_posixmkdirs;
53909 - atomic_t num_rmdirs;
53910 - atomic_t num_renames;
53911 - atomic_t num_t2renames;
53912 - atomic_t num_ffirst;
53913 - atomic_t num_fnext;
53914 - atomic_t num_fclose;
53915 - atomic_t num_hardlinks;
53916 - atomic_t num_symlinks;
53917 - atomic_t num_locks;
53918 - atomic_t num_acl_get;
53919 - atomic_t num_acl_set;
53920 + atomic_unchecked_t num_writes;
53921 + atomic_unchecked_t num_reads;
53922 + atomic_unchecked_t num_flushes;
53923 + atomic_unchecked_t num_oplock_brks;
53924 + atomic_unchecked_t num_opens;
53925 + atomic_unchecked_t num_closes;
53926 + atomic_unchecked_t num_deletes;
53927 + atomic_unchecked_t num_mkdirs;
53928 + atomic_unchecked_t num_posixopens;
53929 + atomic_unchecked_t num_posixmkdirs;
53930 + atomic_unchecked_t num_rmdirs;
53931 + atomic_unchecked_t num_renames;
53932 + atomic_unchecked_t num_t2renames;
53933 + atomic_unchecked_t num_ffirst;
53934 + atomic_unchecked_t num_fnext;
53935 + atomic_unchecked_t num_fclose;
53936 + atomic_unchecked_t num_hardlinks;
53937 + atomic_unchecked_t num_symlinks;
53938 + atomic_unchecked_t num_locks;
53939 + atomic_unchecked_t num_acl_get;
53940 + atomic_unchecked_t num_acl_set;
53941 } cifs_stats;
53942 #ifdef CONFIG_CIFS_SMB2
53943 struct {
53944 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53945 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53946 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53947 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53948 } smb2_stats;
53949 #endif /* CONFIG_CIFS_SMB2 */
53950 } stats;
53951 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53952 }
53953
53954 #ifdef CONFIG_CIFS_STATS
53955 -#define cifs_stats_inc atomic_inc
53956 +#define cifs_stats_inc atomic_inc_unchecked
53957
53958 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53959 unsigned int bytes)
53960 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53961 /* Various Debug counters */
53962 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53963 #ifdef CONFIG_CIFS_STATS2
53964 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53965 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53966 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53967 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53968 #endif
53969 GLOBAL_EXTERN atomic_t smBufAllocCount;
53970 GLOBAL_EXTERN atomic_t midCount;
53971 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53972 index 562044f..4af6a17 100644
53973 --- a/fs/cifs/link.c
53974 +++ b/fs/cifs/link.c
53975 @@ -638,7 +638,7 @@ symlink_exit:
53976
53977 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53978 {
53979 - char *p = nd_get_link(nd);
53980 + const char *p = nd_get_link(nd);
53981 if (!IS_ERR(p))
53982 kfree(p);
53983 }
53984 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53985 index f7d4b22..1254377 100644
53986 --- a/fs/cifs/misc.c
53987 +++ b/fs/cifs/misc.c
53988 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53989 memset(ret_buf, 0, buf_size + 3);
53990 atomic_inc(&bufAllocCount);
53991 #ifdef CONFIG_CIFS_STATS2
53992 - atomic_inc(&totBufAllocCount);
53993 + atomic_inc_unchecked(&totBufAllocCount);
53994 #endif /* CONFIG_CIFS_STATS2 */
53995 }
53996
53997 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53998 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53999 atomic_inc(&smBufAllocCount);
54000 #ifdef CONFIG_CIFS_STATS2
54001 - atomic_inc(&totSmBufAllocCount);
54002 + atomic_inc_unchecked(&totSmBufAllocCount);
54003 #endif /* CONFIG_CIFS_STATS2 */
54004
54005 }
54006 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
54007 index 6094397..51e576f 100644
54008 --- a/fs/cifs/smb1ops.c
54009 +++ b/fs/cifs/smb1ops.c
54010 @@ -590,27 +590,27 @@ static void
54011 cifs_clear_stats(struct cifs_tcon *tcon)
54012 {
54013 #ifdef CONFIG_CIFS_STATS
54014 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
54015 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
54016 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
54017 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54018 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
54019 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
54020 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54021 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
54022 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
54023 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
54024 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54025 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54026 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54027 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54028 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54029 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54030 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54031 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54032 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54033 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54034 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54035 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54036 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54037 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54038 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54039 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54040 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54041 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54042 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54043 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54044 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54045 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54046 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54047 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54048 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54049 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54050 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54051 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54052 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54053 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54054 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54055 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54056 #endif
54057 }
54058
54059 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54060 {
54061 #ifdef CONFIG_CIFS_STATS
54062 seq_printf(m, " Oplocks breaks: %d",
54063 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54064 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54065 seq_printf(m, "\nReads: %d Bytes: %llu",
54066 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54067 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54068 (long long)(tcon->bytes_read));
54069 seq_printf(m, "\nWrites: %d Bytes: %llu",
54070 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54071 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54072 (long long)(tcon->bytes_written));
54073 seq_printf(m, "\nFlushes: %d",
54074 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54075 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54076 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54077 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54078 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54079 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54080 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54081 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54082 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54083 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54084 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54085 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54086 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54087 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54088 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54089 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54090 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54091 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54092 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54093 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54094 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54095 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54096 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54097 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54098 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54099 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54100 seq_printf(m, "\nRenames: %d T2 Renames %d",
54101 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54102 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54103 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54104 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54105 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54106 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54107 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54108 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54109 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54110 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54111 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54112 #endif
54113 }
54114
54115 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54116 index f259e6c..ca948ff 100644
54117 --- a/fs/cifs/smb2ops.c
54118 +++ b/fs/cifs/smb2ops.c
54119 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54120 #ifdef CONFIG_CIFS_STATS
54121 int i;
54122 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54123 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54124 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54125 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54126 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54127 }
54128 #endif
54129 }
54130 @@ -310,65 +310,65 @@ static void
54131 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54132 {
54133 #ifdef CONFIG_CIFS_STATS
54134 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54135 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54136 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54137 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54138 seq_printf(m, "\nNegotiates: %d sent %d failed",
54139 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54140 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54141 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54142 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54143 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54144 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54145 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54146 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54147 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54148 seq_printf(m, "\nLogoffs: %d sent %d failed",
54149 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54150 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54151 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54152 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54153 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54154 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54155 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54156 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54157 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54158 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54159 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54160 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54161 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54162 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54163 seq_printf(m, "\nCreates: %d sent %d failed",
54164 - atomic_read(&sent[SMB2_CREATE_HE]),
54165 - atomic_read(&failed[SMB2_CREATE_HE]));
54166 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54167 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54168 seq_printf(m, "\nCloses: %d sent %d failed",
54169 - atomic_read(&sent[SMB2_CLOSE_HE]),
54170 - atomic_read(&failed[SMB2_CLOSE_HE]));
54171 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54172 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54173 seq_printf(m, "\nFlushes: %d sent %d failed",
54174 - atomic_read(&sent[SMB2_FLUSH_HE]),
54175 - atomic_read(&failed[SMB2_FLUSH_HE]));
54176 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54177 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54178 seq_printf(m, "\nReads: %d sent %d failed",
54179 - atomic_read(&sent[SMB2_READ_HE]),
54180 - atomic_read(&failed[SMB2_READ_HE]));
54181 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54182 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54183 seq_printf(m, "\nWrites: %d sent %d failed",
54184 - atomic_read(&sent[SMB2_WRITE_HE]),
54185 - atomic_read(&failed[SMB2_WRITE_HE]));
54186 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54187 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54188 seq_printf(m, "\nLocks: %d sent %d failed",
54189 - atomic_read(&sent[SMB2_LOCK_HE]),
54190 - atomic_read(&failed[SMB2_LOCK_HE]));
54191 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54192 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54193 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54194 - atomic_read(&sent[SMB2_IOCTL_HE]),
54195 - atomic_read(&failed[SMB2_IOCTL_HE]));
54196 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54197 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54198 seq_printf(m, "\nCancels: %d sent %d failed",
54199 - atomic_read(&sent[SMB2_CANCEL_HE]),
54200 - atomic_read(&failed[SMB2_CANCEL_HE]));
54201 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54202 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54203 seq_printf(m, "\nEchos: %d sent %d failed",
54204 - atomic_read(&sent[SMB2_ECHO_HE]),
54205 - atomic_read(&failed[SMB2_ECHO_HE]));
54206 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54207 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54208 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54209 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54210 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54211 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54212 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54213 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54214 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54215 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54216 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54217 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54218 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54219 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54220 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54221 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54222 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54223 seq_printf(m, "\nSetInfos: %d sent %d failed",
54224 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54225 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54226 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54227 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54228 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54229 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54230 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54231 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54232 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54233 #endif
54234 }
54235
54236 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54237 index abc9c28..3fdae28 100644
54238 --- a/fs/cifs/smb2pdu.c
54239 +++ b/fs/cifs/smb2pdu.c
54240 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54241 default:
54242 cifs_dbg(VFS, "info level %u isn't supported\n",
54243 srch_inf->info_level);
54244 - rc = -EINVAL;
54245 - goto qdir_exit;
54246 + return -EINVAL;
54247 }
54248
54249 req->FileIndex = cpu_to_le32(index);
54250 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54251 index 1da168c..8bc7ff6 100644
54252 --- a/fs/coda/cache.c
54253 +++ b/fs/coda/cache.c
54254 @@ -24,7 +24,7 @@
54255 #include "coda_linux.h"
54256 #include "coda_cache.h"
54257
54258 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54259 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54260
54261 /* replace or extend an acl cache hit */
54262 void coda_cache_enter(struct inode *inode, int mask)
54263 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54264 struct coda_inode_info *cii = ITOC(inode);
54265
54266 spin_lock(&cii->c_lock);
54267 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54268 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54269 if (!uid_eq(cii->c_uid, current_fsuid())) {
54270 cii->c_uid = current_fsuid();
54271 cii->c_cached_perm = mask;
54272 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54273 {
54274 struct coda_inode_info *cii = ITOC(inode);
54275 spin_lock(&cii->c_lock);
54276 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54277 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54278 spin_unlock(&cii->c_lock);
54279 }
54280
54281 /* remove all acl caches */
54282 void coda_cache_clear_all(struct super_block *sb)
54283 {
54284 - atomic_inc(&permission_epoch);
54285 + atomic_inc_unchecked(&permission_epoch);
54286 }
54287
54288
54289 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54290 spin_lock(&cii->c_lock);
54291 hit = (mask & cii->c_cached_perm) == mask &&
54292 uid_eq(cii->c_uid, current_fsuid()) &&
54293 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54294 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54295 spin_unlock(&cii->c_lock);
54296
54297 return hit;
54298 diff --git a/fs/compat.c b/fs/compat.c
54299 index 6af20de..fec3fbb 100644
54300 --- a/fs/compat.c
54301 +++ b/fs/compat.c
54302 @@ -54,7 +54,7 @@
54303 #include <asm/ioctls.h>
54304 #include "internal.h"
54305
54306 -int compat_log = 1;
54307 +int compat_log = 0;
54308
54309 int compat_printk(const char *fmt, ...)
54310 {
54311 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54312
54313 set_fs(KERNEL_DS);
54314 /* The __user pointer cast is valid because of the set_fs() */
54315 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54316 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54317 set_fs(oldfs);
54318 /* truncating is ok because it's a user address */
54319 if (!ret)
54320 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54321 goto out;
54322
54323 ret = -EINVAL;
54324 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54325 + if (nr_segs > UIO_MAXIOV)
54326 goto out;
54327 if (nr_segs > fast_segs) {
54328 ret = -ENOMEM;
54329 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54330 struct compat_readdir_callback {
54331 struct dir_context ctx;
54332 struct compat_old_linux_dirent __user *dirent;
54333 + struct file * file;
54334 int result;
54335 };
54336
54337 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54338 buf->result = -EOVERFLOW;
54339 return -EOVERFLOW;
54340 }
54341 +
54342 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54343 + return 0;
54344 +
54345 buf->result++;
54346 dirent = buf->dirent;
54347 if (!access_ok(VERIFY_WRITE, dirent,
54348 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54349 if (!f.file)
54350 return -EBADF;
54351
54352 + buf.file = f.file;
54353 error = iterate_dir(f.file, &buf.ctx);
54354 if (buf.result)
54355 error = buf.result;
54356 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54357 struct dir_context ctx;
54358 struct compat_linux_dirent __user *current_dir;
54359 struct compat_linux_dirent __user *previous;
54360 + struct file * file;
54361 int count;
54362 int error;
54363 };
54364 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54365 buf->error = -EOVERFLOW;
54366 return -EOVERFLOW;
54367 }
54368 +
54369 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54370 + return 0;
54371 +
54372 dirent = buf->previous;
54373 if (dirent) {
54374 if (__put_user(offset, &dirent->d_off))
54375 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54376 if (!f.file)
54377 return -EBADF;
54378
54379 + buf.file = f.file;
54380 error = iterate_dir(f.file, &buf.ctx);
54381 if (error >= 0)
54382 error = buf.error;
54383 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54384 struct dir_context ctx;
54385 struct linux_dirent64 __user *current_dir;
54386 struct linux_dirent64 __user *previous;
54387 + struct file * file;
54388 int count;
54389 int error;
54390 };
54391 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54392 buf->error = -EINVAL; /* only used if we fail.. */
54393 if (reclen > buf->count)
54394 return -EINVAL;
54395 +
54396 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54397 + return 0;
54398 +
54399 dirent = buf->previous;
54400
54401 if (dirent) {
54402 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54403 if (!f.file)
54404 return -EBADF;
54405
54406 + buf.file = f.file;
54407 error = iterate_dir(f.file, &buf.ctx);
54408 if (error >= 0)
54409 error = buf.error;
54410 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54411 index a81147e..20bf2b5 100644
54412 --- a/fs/compat_binfmt_elf.c
54413 +++ b/fs/compat_binfmt_elf.c
54414 @@ -30,11 +30,13 @@
54415 #undef elf_phdr
54416 #undef elf_shdr
54417 #undef elf_note
54418 +#undef elf_dyn
54419 #undef elf_addr_t
54420 #define elfhdr elf32_hdr
54421 #define elf_phdr elf32_phdr
54422 #define elf_shdr elf32_shdr
54423 #define elf_note elf32_note
54424 +#define elf_dyn Elf32_Dyn
54425 #define elf_addr_t Elf32_Addr
54426
54427 /*
54428 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54429 index 5d19acf..9ab093b 100644
54430 --- a/fs/compat_ioctl.c
54431 +++ b/fs/compat_ioctl.c
54432 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54433 return -EFAULT;
54434 if (__get_user(udata, &ss32->iomem_base))
54435 return -EFAULT;
54436 - ss.iomem_base = compat_ptr(udata);
54437 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54438 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54439 __get_user(ss.port_high, &ss32->port_high))
54440 return -EFAULT;
54441 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54442 for (i = 0; i < nmsgs; i++) {
54443 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54444 return -EFAULT;
54445 - if (get_user(datap, &umsgs[i].buf) ||
54446 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54447 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54448 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54449 return -EFAULT;
54450 }
54451 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54452 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54453 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54454 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54455 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54456 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54457 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54458 return -EFAULT;
54459
54460 return ioctl_preallocate(file, p);
54461 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54462 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54463 {
54464 unsigned int a, b;
54465 - a = *(unsigned int *)p;
54466 - b = *(unsigned int *)q;
54467 + a = *(const unsigned int *)p;
54468 + b = *(const unsigned int *)q;
54469 if (a > b)
54470 return 1;
54471 if (a < b)
54472 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54473 index 277bd1b..f312c9e 100644
54474 --- a/fs/configfs/dir.c
54475 +++ b/fs/configfs/dir.c
54476 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54477 }
54478 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54479 struct configfs_dirent *next;
54480 - const char *name;
54481 + const unsigned char * name;
54482 + char d_name[sizeof(next->s_dentry->d_iname)];
54483 int len;
54484 struct inode *inode = NULL;
54485
54486 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54487 continue;
54488
54489 name = configfs_get_name(next);
54490 - len = strlen(name);
54491 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54492 + len = next->s_dentry->d_name.len;
54493 + memcpy(d_name, name, len);
54494 + name = d_name;
54495 + } else
54496 + len = strlen(name);
54497
54498 /*
54499 * We'll have a dentry and an inode for
54500 diff --git a/fs/coredump.c b/fs/coredump.c
54501 index 72f816d..1ba8eff 100644
54502 --- a/fs/coredump.c
54503 +++ b/fs/coredump.c
54504 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54505 struct pipe_inode_info *pipe = file->private_data;
54506
54507 pipe_lock(pipe);
54508 - pipe->readers++;
54509 - pipe->writers--;
54510 + atomic_inc(&pipe->readers);
54511 + atomic_dec(&pipe->writers);
54512 wake_up_interruptible_sync(&pipe->wait);
54513 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54514 pipe_unlock(pipe);
54515 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54516 * We actually want wait_event_freezable() but then we need
54517 * to clear TIF_SIGPENDING and improve dump_interrupted().
54518 */
54519 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54520 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54521
54522 pipe_lock(pipe);
54523 - pipe->readers--;
54524 - pipe->writers++;
54525 + atomic_dec(&pipe->readers);
54526 + atomic_inc(&pipe->writers);
54527 pipe_unlock(pipe);
54528 }
54529
54530 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54531 struct files_struct *displaced;
54532 bool need_nonrelative = false;
54533 bool core_dumped = false;
54534 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54535 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54536 + long signr = siginfo->si_signo;
54537 struct coredump_params cprm = {
54538 .siginfo = siginfo,
54539 .regs = signal_pt_regs(),
54540 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54541 .mm_flags = mm->flags,
54542 };
54543
54544 - audit_core_dumps(siginfo->si_signo);
54545 + audit_core_dumps(signr);
54546 +
54547 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54548 + gr_handle_brute_attach(cprm.mm_flags);
54549
54550 binfmt = mm->binfmt;
54551 if (!binfmt || !binfmt->core_dump)
54552 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54553 need_nonrelative = true;
54554 }
54555
54556 - retval = coredump_wait(siginfo->si_signo, &core_state);
54557 + retval = coredump_wait(signr, &core_state);
54558 if (retval < 0)
54559 goto fail_creds;
54560
54561 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54562 }
54563 cprm.limit = RLIM_INFINITY;
54564
54565 - dump_count = atomic_inc_return(&core_dump_count);
54566 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54567 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54568 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54569 task_tgid_vnr(current), current->comm);
54570 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54571 } else {
54572 struct inode *inode;
54573
54574 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54575 +
54576 if (cprm.limit < binfmt->min_coredump)
54577 goto fail_unlock;
54578
54579 @@ -664,7 +670,7 @@ close_fail:
54580 filp_close(cprm.file, NULL);
54581 fail_dropcount:
54582 if (ispipe)
54583 - atomic_dec(&core_dump_count);
54584 + atomic_dec_unchecked(&core_dump_count);
54585 fail_unlock:
54586 kfree(cn.corename);
54587 coredump_finish(mm, core_dumped);
54588 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54589 {
54590 return !dump_interrupted() &&
54591 access_ok(VERIFY_READ, addr, nr) &&
54592 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54593 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54594 }
54595 EXPORT_SYMBOL(dump_write);
54596
54597 diff --git a/fs/dcache.c b/fs/dcache.c
54598 index b949af8..5978926 100644
54599 --- a/fs/dcache.c
54600 +++ b/fs/dcache.c
54601 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54602 mempages -= reserve;
54603
54604 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54605 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54606 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54607 + SLAB_NO_SANITIZE, NULL);
54608
54609 dcache_init();
54610 inode_init();
54611 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54612 index c7c83ff..bda9461 100644
54613 --- a/fs/debugfs/inode.c
54614 +++ b/fs/debugfs/inode.c
54615 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54616 */
54617 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54618 {
54619 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54620 + return __create_file(name, S_IFDIR | S_IRWXU,
54621 +#else
54622 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54623 +#endif
54624 parent, NULL, NULL);
54625 }
54626 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54627 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54628 index 67e9b63..a9adb68 100644
54629 --- a/fs/ecryptfs/inode.c
54630 +++ b/fs/ecryptfs/inode.c
54631 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54632 old_fs = get_fs();
54633 set_fs(get_ds());
54634 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54635 - (char __user *)lower_buf,
54636 + (char __force_user *)lower_buf,
54637 PATH_MAX);
54638 set_fs(old_fs);
54639 if (rc < 0)
54640 @@ -706,7 +706,7 @@ out:
54641 static void
54642 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54643 {
54644 - char *buf = nd_get_link(nd);
54645 + const char *buf = nd_get_link(nd);
54646 if (!IS_ERR(buf)) {
54647 /* Free the char* */
54648 kfree(buf);
54649 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54650 index e4141f2..d8263e8 100644
54651 --- a/fs/ecryptfs/miscdev.c
54652 +++ b/fs/ecryptfs/miscdev.c
54653 @@ -304,7 +304,7 @@ check_list:
54654 goto out_unlock_msg_ctx;
54655 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54656 if (msg_ctx->msg) {
54657 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54658 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54659 goto out_unlock_msg_ctx;
54660 i += packet_length_size;
54661 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54662 diff --git a/fs/exec.c b/fs/exec.c
54663 index fd774c7..1c6a7bf 100644
54664 --- a/fs/exec.c
54665 +++ b/fs/exec.c
54666 @@ -55,8 +55,20 @@
54667 #include <linux/pipe_fs_i.h>
54668 #include <linux/oom.h>
54669 #include <linux/compat.h>
54670 +#include <linux/random.h>
54671 +#include <linux/seq_file.h>
54672 +#include <linux/coredump.h>
54673 +#include <linux/mman.h>
54674 +
54675 +#ifdef CONFIG_PAX_REFCOUNT
54676 +#include <linux/kallsyms.h>
54677 +#include <linux/kdebug.h>
54678 +#endif
54679 +
54680 +#include <trace/events/fs.h>
54681
54682 #include <asm/uaccess.h>
54683 +#include <asm/sections.h>
54684 #include <asm/mmu_context.h>
54685 #include <asm/tlb.h>
54686
54687 @@ -66,17 +78,32 @@
54688
54689 #include <trace/events/sched.h>
54690
54691 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54692 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54693 +{
54694 + 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");
54695 +}
54696 +#endif
54697 +
54698 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54699 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54700 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54701 +#endif
54702 +
54703 int suid_dumpable = 0;
54704
54705 static LIST_HEAD(formats);
54706 static DEFINE_RWLOCK(binfmt_lock);
54707
54708 +extern int gr_process_kernel_exec_ban(void);
54709 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54710 +
54711 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54712 {
54713 BUG_ON(!fmt);
54714 write_lock(&binfmt_lock);
54715 - insert ? list_add(&fmt->lh, &formats) :
54716 - list_add_tail(&fmt->lh, &formats);
54717 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54718 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54719 write_unlock(&binfmt_lock);
54720 }
54721
54722 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54723 void unregister_binfmt(struct linux_binfmt * fmt)
54724 {
54725 write_lock(&binfmt_lock);
54726 - list_del(&fmt->lh);
54727 + pax_list_del((struct list_head *)&fmt->lh);
54728 write_unlock(&binfmt_lock);
54729 }
54730
54731 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54732 int write)
54733 {
54734 struct page *page;
54735 - int ret;
54736
54737 -#ifdef CONFIG_STACK_GROWSUP
54738 - if (write) {
54739 - ret = expand_downwards(bprm->vma, pos);
54740 - if (ret < 0)
54741 - return NULL;
54742 - }
54743 -#endif
54744 - ret = get_user_pages(current, bprm->mm, pos,
54745 - 1, write, 1, &page, NULL);
54746 - if (ret <= 0)
54747 + if (0 > expand_downwards(bprm->vma, pos))
54748 + return NULL;
54749 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54750 return NULL;
54751
54752 if (write) {
54753 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54754 if (size <= ARG_MAX)
54755 return page;
54756
54757 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54758 + // only allow 512KB for argv+env on suid/sgid binaries
54759 + // to prevent easy ASLR exhaustion
54760 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54761 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54762 + (size > (512 * 1024))) {
54763 + put_page(page);
54764 + return NULL;
54765 + }
54766 +#endif
54767 +
54768 /*
54769 * Limit to 1/4-th the stack size for the argv+env strings.
54770 * This ensures that:
54771 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54772 vma->vm_end = STACK_TOP_MAX;
54773 vma->vm_start = vma->vm_end - PAGE_SIZE;
54774 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54775 +
54776 +#ifdef CONFIG_PAX_SEGMEXEC
54777 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54778 +#endif
54779 +
54780 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54781 INIT_LIST_HEAD(&vma->anon_vma_chain);
54782
54783 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54784 mm->stack_vm = mm->total_vm = 1;
54785 up_write(&mm->mmap_sem);
54786 bprm->p = vma->vm_end - sizeof(void *);
54787 +
54788 +#ifdef CONFIG_PAX_RANDUSTACK
54789 + if (randomize_va_space)
54790 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54791 +#endif
54792 +
54793 return 0;
54794 err:
54795 up_write(&mm->mmap_sem);
54796 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54797 } ptr;
54798 };
54799
54800 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54801 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54802 {
54803 const char __user *native;
54804
54805 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54806 compat_uptr_t compat;
54807
54808 if (get_user(compat, argv.ptr.compat + nr))
54809 - return ERR_PTR(-EFAULT);
54810 + return (const char __force_user *)ERR_PTR(-EFAULT);
54811
54812 return compat_ptr(compat);
54813 }
54814 #endif
54815
54816 if (get_user(native, argv.ptr.native + nr))
54817 - return ERR_PTR(-EFAULT);
54818 + return (const char __force_user *)ERR_PTR(-EFAULT);
54819
54820 return native;
54821 }
54822 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54823 if (!p)
54824 break;
54825
54826 - if (IS_ERR(p))
54827 + if (IS_ERR((const char __force_kernel *)p))
54828 return -EFAULT;
54829
54830 if (i >= max)
54831 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54832
54833 ret = -EFAULT;
54834 str = get_user_arg_ptr(argv, argc);
54835 - if (IS_ERR(str))
54836 + if (IS_ERR((const char __force_kernel *)str))
54837 goto out;
54838
54839 len = strnlen_user(str, MAX_ARG_STRLEN);
54840 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54841 int r;
54842 mm_segment_t oldfs = get_fs();
54843 struct user_arg_ptr argv = {
54844 - .ptr.native = (const char __user *const __user *)__argv,
54845 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54846 };
54847
54848 set_fs(KERNEL_DS);
54849 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54850 unsigned long new_end = old_end - shift;
54851 struct mmu_gather tlb;
54852
54853 - BUG_ON(new_start > new_end);
54854 + if (new_start >= new_end || new_start < mmap_min_addr)
54855 + return -ENOMEM;
54856
54857 /*
54858 * ensure there are no vmas between where we want to go
54859 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54860 if (vma != find_vma(mm, new_start))
54861 return -EFAULT;
54862
54863 +#ifdef CONFIG_PAX_SEGMEXEC
54864 + BUG_ON(pax_find_mirror_vma(vma));
54865 +#endif
54866 +
54867 /*
54868 * cover the whole range: [new_start, old_end)
54869 */
54870 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54871 stack_top = arch_align_stack(stack_top);
54872 stack_top = PAGE_ALIGN(stack_top);
54873
54874 - if (unlikely(stack_top < mmap_min_addr) ||
54875 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54876 - return -ENOMEM;
54877 -
54878 stack_shift = vma->vm_end - stack_top;
54879
54880 bprm->p -= stack_shift;
54881 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54882 bprm->exec -= stack_shift;
54883
54884 down_write(&mm->mmap_sem);
54885 +
54886 + /* Move stack pages down in memory. */
54887 + if (stack_shift) {
54888 + ret = shift_arg_pages(vma, stack_shift);
54889 + if (ret)
54890 + goto out_unlock;
54891 + }
54892 +
54893 vm_flags = VM_STACK_FLAGS;
54894
54895 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54896 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54897 + vm_flags &= ~VM_EXEC;
54898 +
54899 +#ifdef CONFIG_PAX_MPROTECT
54900 + if (mm->pax_flags & MF_PAX_MPROTECT)
54901 + vm_flags &= ~VM_MAYEXEC;
54902 +#endif
54903 +
54904 + }
54905 +#endif
54906 +
54907 /*
54908 * Adjust stack execute permissions; explicitly enable for
54909 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54910 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54911 goto out_unlock;
54912 BUG_ON(prev != vma);
54913
54914 - /* Move stack pages down in memory. */
54915 - if (stack_shift) {
54916 - ret = shift_arg_pages(vma, stack_shift);
54917 - if (ret)
54918 - goto out_unlock;
54919 - }
54920 -
54921 /* mprotect_fixup is overkill to remove the temporary stack flags */
54922 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54923
54924 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54925 #endif
54926 current->mm->start_stack = bprm->p;
54927 ret = expand_stack(vma, stack_base);
54928 +
54929 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54930 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54931 + unsigned long size;
54932 + vm_flags_t vm_flags;
54933 +
54934 + size = STACK_TOP - vma->vm_end;
54935 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54936 +
54937 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54938 +
54939 +#ifdef CONFIG_X86
54940 + if (!ret) {
54941 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54942 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54943 + }
54944 +#endif
54945 +
54946 + }
54947 +#endif
54948 +
54949 if (ret)
54950 ret = -EFAULT;
54951
54952 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54953
54954 fsnotify_open(file);
54955
54956 + trace_open_exec(name);
54957 +
54958 err = deny_write_access(file);
54959 if (err)
54960 goto exit;
54961 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54962 old_fs = get_fs();
54963 set_fs(get_ds());
54964 /* The cast to a user pointer is valid due to the set_fs() */
54965 - result = vfs_read(file, (void __user *)addr, count, &pos);
54966 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54967 set_fs(old_fs);
54968 return result;
54969 }
54970 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54971 }
54972 rcu_read_unlock();
54973
54974 - if (p->fs->users > n_fs) {
54975 + if (atomic_read(&p->fs->users) > n_fs) {
54976 bprm->unsafe |= LSM_UNSAFE_SHARE;
54977 } else {
54978 res = -EAGAIN;
54979 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54980
54981 EXPORT_SYMBOL(search_binary_handler);
54982
54983 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54984 +static DEFINE_PER_CPU(u64, exec_counter);
54985 +static int __init init_exec_counters(void)
54986 +{
54987 + unsigned int cpu;
54988 +
54989 + for_each_possible_cpu(cpu) {
54990 + per_cpu(exec_counter, cpu) = (u64)cpu;
54991 + }
54992 +
54993 + return 0;
54994 +}
54995 +early_initcall(init_exec_counters);
54996 +static inline void increment_exec_counter(void)
54997 +{
54998 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
54999 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55000 +}
55001 +#else
55002 +static inline void increment_exec_counter(void) {}
55003 +#endif
55004 +
55005 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55006 + struct user_arg_ptr argv);
55007 +
55008 /*
55009 * sys_execve() executes a new program.
55010 */
55011 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
55012 struct user_arg_ptr argv,
55013 struct user_arg_ptr envp)
55014 {
55015 +#ifdef CONFIG_GRKERNSEC
55016 + struct file *old_exec_file;
55017 + struct acl_subject_label *old_acl;
55018 + struct rlimit old_rlim[RLIM_NLIMITS];
55019 +#endif
55020 struct linux_binprm *bprm;
55021 struct file *file;
55022 struct files_struct *displaced;
55023 bool clear_in_exec;
55024 int retval;
55025
55026 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
55027 +
55028 /*
55029 * We move the actual failure in case of RLIMIT_NPROC excess from
55030 * set*uid() to execve() because too many poorly written programs
55031 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
55032 if (IS_ERR(file))
55033 goto out_unmark;
55034
55035 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55036 + retval = -EPERM;
55037 + goto out_file;
55038 + }
55039 +
55040 sched_exec();
55041
55042 bprm->file = file;
55043 bprm->filename = filename;
55044 bprm->interp = filename;
55045
55046 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55047 + retval = -EACCES;
55048 + goto out_file;
55049 + }
55050 +
55051 retval = bprm_mm_init(bprm);
55052 if (retval)
55053 goto out_file;
55054 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
55055 if (retval < 0)
55056 goto out;
55057
55058 +#ifdef CONFIG_GRKERNSEC
55059 + old_acl = current->acl;
55060 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55061 + old_exec_file = current->exec_file;
55062 + get_file(file);
55063 + current->exec_file = file;
55064 +#endif
55065 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55066 + /* limit suid stack to 8MB
55067 + * we saved the old limits above and will restore them if this exec fails
55068 + */
55069 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55070 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55071 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55072 +#endif
55073 +
55074 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55075 + retval = -EPERM;
55076 + goto out_fail;
55077 + }
55078 +
55079 + if (!gr_tpe_allow(file)) {
55080 + retval = -EACCES;
55081 + goto out_fail;
55082 + }
55083 +
55084 + if (gr_check_crash_exec(file)) {
55085 + retval = -EACCES;
55086 + goto out_fail;
55087 + }
55088 +
55089 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55090 + bprm->unsafe);
55091 + if (retval < 0)
55092 + goto out_fail;
55093 +
55094 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55095 if (retval < 0)
55096 - goto out;
55097 + goto out_fail;
55098
55099 bprm->exec = bprm->p;
55100 retval = copy_strings(bprm->envc, envp, bprm);
55101 if (retval < 0)
55102 - goto out;
55103 + goto out_fail;
55104
55105 retval = copy_strings(bprm->argc, argv, bprm);
55106 if (retval < 0)
55107 - goto out;
55108 + goto out_fail;
55109 +
55110 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55111 +
55112 + gr_handle_exec_args(bprm, argv);
55113
55114 retval = search_binary_handler(bprm);
55115 if (retval < 0)
55116 - goto out;
55117 + goto out_fail;
55118 +#ifdef CONFIG_GRKERNSEC
55119 + if (old_exec_file)
55120 + fput(old_exec_file);
55121 +#endif
55122
55123 /* execve succeeded */
55124 +
55125 + increment_exec_counter();
55126 current->fs->in_exec = 0;
55127 current->in_execve = 0;
55128 acct_update_integrals(current);
55129 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
55130 put_files_struct(displaced);
55131 return retval;
55132
55133 +out_fail:
55134 +#ifdef CONFIG_GRKERNSEC
55135 + current->acl = old_acl;
55136 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55137 + fput(current->exec_file);
55138 + current->exec_file = old_exec_file;
55139 +#endif
55140 +
55141 out:
55142 if (bprm->mm) {
55143 acct_arg_size(bprm, 0);
55144 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55145 return error;
55146 }
55147 #endif
55148 +
55149 +int pax_check_flags(unsigned long *flags)
55150 +{
55151 + int retval = 0;
55152 +
55153 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55154 + if (*flags & MF_PAX_SEGMEXEC)
55155 + {
55156 + *flags &= ~MF_PAX_SEGMEXEC;
55157 + retval = -EINVAL;
55158 + }
55159 +#endif
55160 +
55161 + if ((*flags & MF_PAX_PAGEEXEC)
55162 +
55163 +#ifdef CONFIG_PAX_PAGEEXEC
55164 + && (*flags & MF_PAX_SEGMEXEC)
55165 +#endif
55166 +
55167 + )
55168 + {
55169 + *flags &= ~MF_PAX_PAGEEXEC;
55170 + retval = -EINVAL;
55171 + }
55172 +
55173 + if ((*flags & MF_PAX_MPROTECT)
55174 +
55175 +#ifdef CONFIG_PAX_MPROTECT
55176 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55177 +#endif
55178 +
55179 + )
55180 + {
55181 + *flags &= ~MF_PAX_MPROTECT;
55182 + retval = -EINVAL;
55183 + }
55184 +
55185 + if ((*flags & MF_PAX_EMUTRAMP)
55186 +
55187 +#ifdef CONFIG_PAX_EMUTRAMP
55188 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55189 +#endif
55190 +
55191 + )
55192 + {
55193 + *flags &= ~MF_PAX_EMUTRAMP;
55194 + retval = -EINVAL;
55195 + }
55196 +
55197 + return retval;
55198 +}
55199 +
55200 +EXPORT_SYMBOL(pax_check_flags);
55201 +
55202 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55203 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55204 +{
55205 + char *pathname = d_path(path, buf, buflen);
55206 +
55207 + if (IS_ERR(pathname))
55208 + goto toolong;
55209 +
55210 + pathname = mangle_path(buf, pathname, "\t\n\\");
55211 + if (!pathname)
55212 + goto toolong;
55213 +
55214 + *pathname = 0;
55215 + return buf;
55216 +
55217 +toolong:
55218 + return "<path too long>";
55219 +}
55220 +EXPORT_SYMBOL(pax_get_path);
55221 +
55222 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55223 +{
55224 + struct task_struct *tsk = current;
55225 + struct mm_struct *mm = current->mm;
55226 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55227 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55228 + char *path_exec = NULL;
55229 + char *path_fault = NULL;
55230 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55231 + siginfo_t info = { };
55232 +
55233 + if (buffer_exec && buffer_fault) {
55234 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55235 +
55236 + down_read(&mm->mmap_sem);
55237 + vma = mm->mmap;
55238 + while (vma && (!vma_exec || !vma_fault)) {
55239 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55240 + vma_exec = vma;
55241 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55242 + vma_fault = vma;
55243 + vma = vma->vm_next;
55244 + }
55245 + if (vma_exec)
55246 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55247 + if (vma_fault) {
55248 + start = vma_fault->vm_start;
55249 + end = vma_fault->vm_end;
55250 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55251 + if (vma_fault->vm_file)
55252 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55253 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55254 + path_fault = "<heap>";
55255 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55256 + path_fault = "<stack>";
55257 + else
55258 + path_fault = "<anonymous mapping>";
55259 + }
55260 + up_read(&mm->mmap_sem);
55261 + }
55262 + if (tsk->signal->curr_ip)
55263 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55264 + else
55265 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55266 + 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),
55267 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55268 + free_page((unsigned long)buffer_exec);
55269 + free_page((unsigned long)buffer_fault);
55270 + pax_report_insns(regs, pc, sp);
55271 + info.si_signo = SIGKILL;
55272 + info.si_errno = 0;
55273 + info.si_code = SI_KERNEL;
55274 + info.si_pid = 0;
55275 + info.si_uid = 0;
55276 + do_coredump(&info);
55277 +}
55278 +#endif
55279 +
55280 +#ifdef CONFIG_PAX_REFCOUNT
55281 +void pax_report_refcount_overflow(struct pt_regs *regs)
55282 +{
55283 + if (current->signal->curr_ip)
55284 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55285 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55286 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55287 + else
55288 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55289 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55290 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55291 + preempt_disable();
55292 + show_regs(regs);
55293 + preempt_enable();
55294 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55295 +}
55296 +#endif
55297 +
55298 +#ifdef CONFIG_PAX_USERCOPY
55299 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55300 +static noinline int check_stack_object(const void *obj, unsigned long len)
55301 +{
55302 + const void * const stack = task_stack_page(current);
55303 + const void * const stackend = stack + THREAD_SIZE;
55304 +
55305 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55306 + const void *frame = NULL;
55307 + const void *oldframe;
55308 +#endif
55309 +
55310 + if (obj + len < obj)
55311 + return -1;
55312 +
55313 + if (obj + len <= stack || stackend <= obj)
55314 + return 0;
55315 +
55316 + if (obj < stack || stackend < obj + len)
55317 + return -1;
55318 +
55319 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55320 + oldframe = __builtin_frame_address(1);
55321 + if (oldframe)
55322 + frame = __builtin_frame_address(2);
55323 + /*
55324 + low ----------------------------------------------> high
55325 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55326 + ^----------------^
55327 + allow copies only within here
55328 + */
55329 + while (stack <= frame && frame < stackend) {
55330 + /* if obj + len extends past the last frame, this
55331 + check won't pass and the next frame will be 0,
55332 + causing us to bail out and correctly report
55333 + the copy as invalid
55334 + */
55335 + if (obj + len <= frame)
55336 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55337 + oldframe = frame;
55338 + frame = *(const void * const *)frame;
55339 + }
55340 + return -1;
55341 +#else
55342 + return 1;
55343 +#endif
55344 +}
55345 +
55346 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55347 +{
55348 + if (current->signal->curr_ip)
55349 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55350 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55351 + else
55352 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55353 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55354 + dump_stack();
55355 + gr_handle_kernel_exploit();
55356 + do_group_exit(SIGKILL);
55357 +}
55358 +#endif
55359 +
55360 +#ifdef CONFIG_PAX_USERCOPY
55361 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55362 +{
55363 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55364 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55365 +#ifdef CONFIG_MODULES
55366 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55367 +#else
55368 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55369 +#endif
55370 +
55371 +#else
55372 + unsigned long textlow = (unsigned long)_stext;
55373 + unsigned long texthigh = (unsigned long)_etext;
55374 +#endif
55375 +
55376 + if (high <= textlow || low > texthigh)
55377 + return false;
55378 + else
55379 + return true;
55380 +}
55381 +#endif
55382 +
55383 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55384 +{
55385 +
55386 +#ifdef CONFIG_PAX_USERCOPY
55387 + const char *type;
55388 +
55389 + if (!n)
55390 + return;
55391 +
55392 + type = check_heap_object(ptr, n);
55393 + if (!type) {
55394 + int ret = check_stack_object(ptr, n);
55395 + if (ret == 1 || ret == 2)
55396 + return;
55397 + if (ret == 0) {
55398 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55399 + type = "<kernel text>";
55400 + else
55401 + return;
55402 + } else
55403 + type = "<process stack>";
55404 + }
55405 +
55406 + pax_report_usercopy(ptr, n, to_user, type);
55407 +#endif
55408 +
55409 +}
55410 +EXPORT_SYMBOL(__check_object_size);
55411 +
55412 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55413 +void pax_track_stack(void)
55414 +{
55415 + unsigned long sp = (unsigned long)&sp;
55416 + if (sp < current_thread_info()->lowest_stack &&
55417 + sp > (unsigned long)task_stack_page(current))
55418 + current_thread_info()->lowest_stack = sp;
55419 +}
55420 +EXPORT_SYMBOL(pax_track_stack);
55421 +#endif
55422 +
55423 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55424 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55425 +{
55426 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55427 + dump_stack();
55428 + do_group_exit(SIGKILL);
55429 +}
55430 +EXPORT_SYMBOL(report_size_overflow);
55431 +#endif
55432 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55433 index 9f9992b..8b59411 100644
55434 --- a/fs/ext2/balloc.c
55435 +++ b/fs/ext2/balloc.c
55436 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55437
55438 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55439 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55440 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55441 + if (free_blocks < root_blocks + 1 &&
55442 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55443 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55444 - !in_group_p (sbi->s_resgid))) {
55445 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55446 return 0;
55447 }
55448 return 1;
55449 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55450 index 22548f5..41521d8 100644
55451 --- a/fs/ext3/balloc.c
55452 +++ b/fs/ext3/balloc.c
55453 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55454
55455 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55456 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55457 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55458 + if (free_blocks < root_blocks + 1 &&
55459 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55460 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55461 - !in_group_p (sbi->s_resgid))) {
55462 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55463 return 0;
55464 }
55465 return 1;
55466 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55467 index ddd715e..c772f88 100644
55468 --- a/fs/ext4/balloc.c
55469 +++ b/fs/ext4/balloc.c
55470 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55471 /* Hm, nope. Are (enough) root reserved clusters available? */
55472 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55473 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55474 - capable(CAP_SYS_RESOURCE) ||
55475 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55476 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55477 + capable_nolog(CAP_SYS_RESOURCE)) {
55478
55479 if (free_clusters >= (nclusters + dirty_clusters +
55480 resv_clusters))
55481 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55482 index 0ab26fb..b6ecb39 100644
55483 --- a/fs/ext4/ext4.h
55484 +++ b/fs/ext4/ext4.h
55485 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55486 unsigned long s_mb_last_start;
55487
55488 /* stats for buddy allocator */
55489 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55490 - atomic_t s_bal_success; /* we found long enough chunks */
55491 - atomic_t s_bal_allocated; /* in blocks */
55492 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55493 - atomic_t s_bal_goals; /* goal hits */
55494 - atomic_t s_bal_breaks; /* too long searches */
55495 - atomic_t s_bal_2orders; /* 2^order hits */
55496 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55497 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55498 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55499 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55500 + atomic_unchecked_t s_bal_goals; /* goal hits */
55501 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55502 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55503 spinlock_t s_bal_lock;
55504 unsigned long s_mb_buddies_generated;
55505 unsigned long long s_mb_generation_time;
55506 - atomic_t s_mb_lost_chunks;
55507 - atomic_t s_mb_preallocated;
55508 - atomic_t s_mb_discarded;
55509 + atomic_unchecked_t s_mb_lost_chunks;
55510 + atomic_unchecked_t s_mb_preallocated;
55511 + atomic_unchecked_t s_mb_discarded;
55512 atomic_t s_lock_busy;
55513
55514 /* locality groups */
55515 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55516 index 4bbbf13b..dcceaeb 100644
55517 --- a/fs/ext4/mballoc.c
55518 +++ b/fs/ext4/mballoc.c
55519 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55520 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55521
55522 if (EXT4_SB(sb)->s_mb_stats)
55523 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55524 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55525
55526 break;
55527 }
55528 @@ -2171,7 +2171,7 @@ repeat:
55529 ac->ac_status = AC_STATUS_CONTINUE;
55530 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55531 cr = 3;
55532 - atomic_inc(&sbi->s_mb_lost_chunks);
55533 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55534 goto repeat;
55535 }
55536 }
55537 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55538 if (sbi->s_mb_stats) {
55539 ext4_msg(sb, KERN_INFO,
55540 "mballoc: %u blocks %u reqs (%u success)",
55541 - atomic_read(&sbi->s_bal_allocated),
55542 - atomic_read(&sbi->s_bal_reqs),
55543 - atomic_read(&sbi->s_bal_success));
55544 + atomic_read_unchecked(&sbi->s_bal_allocated),
55545 + atomic_read_unchecked(&sbi->s_bal_reqs),
55546 + atomic_read_unchecked(&sbi->s_bal_success));
55547 ext4_msg(sb, KERN_INFO,
55548 "mballoc: %u extents scanned, %u goal hits, "
55549 "%u 2^N hits, %u breaks, %u lost",
55550 - atomic_read(&sbi->s_bal_ex_scanned),
55551 - atomic_read(&sbi->s_bal_goals),
55552 - atomic_read(&sbi->s_bal_2orders),
55553 - atomic_read(&sbi->s_bal_breaks),
55554 - atomic_read(&sbi->s_mb_lost_chunks));
55555 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55556 + atomic_read_unchecked(&sbi->s_bal_goals),
55557 + atomic_read_unchecked(&sbi->s_bal_2orders),
55558 + atomic_read_unchecked(&sbi->s_bal_breaks),
55559 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55560 ext4_msg(sb, KERN_INFO,
55561 "mballoc: %lu generated and it took %Lu",
55562 sbi->s_mb_buddies_generated,
55563 sbi->s_mb_generation_time);
55564 ext4_msg(sb, KERN_INFO,
55565 "mballoc: %u preallocated, %u discarded",
55566 - atomic_read(&sbi->s_mb_preallocated),
55567 - atomic_read(&sbi->s_mb_discarded));
55568 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55569 + atomic_read_unchecked(&sbi->s_mb_discarded));
55570 }
55571
55572 free_percpu(sbi->s_locality_groups);
55573 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55574 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55575
55576 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55577 - atomic_inc(&sbi->s_bal_reqs);
55578 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55579 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55580 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55581 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55582 - atomic_inc(&sbi->s_bal_success);
55583 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55584 + atomic_inc_unchecked(&sbi->s_bal_success);
55585 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55586 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55587 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55588 - atomic_inc(&sbi->s_bal_goals);
55589 + atomic_inc_unchecked(&sbi->s_bal_goals);
55590 if (ac->ac_found > sbi->s_mb_max_to_scan)
55591 - atomic_inc(&sbi->s_bal_breaks);
55592 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55593 }
55594
55595 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55596 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55597 trace_ext4_mb_new_inode_pa(ac, pa);
55598
55599 ext4_mb_use_inode_pa(ac, pa);
55600 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55601 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55602
55603 ei = EXT4_I(ac->ac_inode);
55604 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55605 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55606 trace_ext4_mb_new_group_pa(ac, pa);
55607
55608 ext4_mb_use_group_pa(ac, pa);
55609 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55610 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55611
55612 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55613 lg = ac->ac_lg;
55614 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55615 * from the bitmap and continue.
55616 */
55617 }
55618 - atomic_add(free, &sbi->s_mb_discarded);
55619 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55620
55621 return err;
55622 }
55623 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55624 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55625 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55626 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55627 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55628 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55629 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55630
55631 return 0;
55632 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55633 index 214461e..3614c89 100644
55634 --- a/fs/ext4/mmp.c
55635 +++ b/fs/ext4/mmp.c
55636 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55637 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55638 const char *function, unsigned int line, const char *msg)
55639 {
55640 - __ext4_warning(sb, function, line, msg);
55641 + __ext4_warning(sb, function, line, "%s", msg);
55642 __ext4_warning(sb, function, line,
55643 "MMP failure info: last update time: %llu, last update "
55644 "node: %s, last update device: %s\n",
55645 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55646 index b59373b..f41c2b5 100644
55647 --- a/fs/ext4/super.c
55648 +++ b/fs/ext4/super.c
55649 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55650 }
55651
55652 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55653 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55654 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55655 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55656
55657 #ifdef CONFIG_QUOTA
55658 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55659 int offset;
55660 int deprecated_val;
55661 } u;
55662 -};
55663 +} __do_const;
55664
55665 static int parse_strtoull(const char *buf,
55666 unsigned long long max, unsigned long long *value)
55667 diff --git a/fs/fcntl.c b/fs/fcntl.c
55668 index 65343c3..9969dcf 100644
55669 --- a/fs/fcntl.c
55670 +++ b/fs/fcntl.c
55671 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55672 if (err)
55673 return err;
55674
55675 + if (gr_handle_chroot_fowner(pid, type))
55676 + return -ENOENT;
55677 + if (gr_check_protected_task_fowner(pid, type))
55678 + return -EACCES;
55679 +
55680 f_modown(filp, pid, type, force);
55681 return 0;
55682 }
55683 diff --git a/fs/fhandle.c b/fs/fhandle.c
55684 index 999ff5c..41f4109 100644
55685 --- a/fs/fhandle.c
55686 +++ b/fs/fhandle.c
55687 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55688 } else
55689 retval = 0;
55690 /* copy the mount id */
55691 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55692 - sizeof(*mnt_id)) ||
55693 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55694 copy_to_user(ufh, handle,
55695 sizeof(struct file_handle) + handle_bytes))
55696 retval = -EFAULT;
55697 diff --git a/fs/file.c b/fs/file.c
55698 index 4a78f98..9447397 100644
55699 --- a/fs/file.c
55700 +++ b/fs/file.c
55701 @@ -16,6 +16,7 @@
55702 #include <linux/slab.h>
55703 #include <linux/vmalloc.h>
55704 #include <linux/file.h>
55705 +#include <linux/security.h>
55706 #include <linux/fdtable.h>
55707 #include <linux/bitops.h>
55708 #include <linux/interrupt.h>
55709 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55710 if (!file)
55711 return __close_fd(files, fd);
55712
55713 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55714 if (fd >= rlimit(RLIMIT_NOFILE))
55715 return -EBADF;
55716
55717 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55718 if (unlikely(oldfd == newfd))
55719 return -EINVAL;
55720
55721 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55722 if (newfd >= rlimit(RLIMIT_NOFILE))
55723 return -EBADF;
55724
55725 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55726 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55727 {
55728 int err;
55729 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55730 if (from >= rlimit(RLIMIT_NOFILE))
55731 return -EINVAL;
55732 err = alloc_fd(from, flags);
55733 diff --git a/fs/filesystems.c b/fs/filesystems.c
55734 index 92567d9..fcd8cbf 100644
55735 --- a/fs/filesystems.c
55736 +++ b/fs/filesystems.c
55737 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55738 int len = dot ? dot - name : strlen(name);
55739
55740 fs = __get_fs_type(name, len);
55741 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55742 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55743 +#else
55744 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55745 +#endif
55746 fs = __get_fs_type(name, len);
55747
55748 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55749 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55750 index d8ac61d..79a36f0 100644
55751 --- a/fs/fs_struct.c
55752 +++ b/fs/fs_struct.c
55753 @@ -4,6 +4,7 @@
55754 #include <linux/path.h>
55755 #include <linux/slab.h>
55756 #include <linux/fs_struct.h>
55757 +#include <linux/grsecurity.h>
55758 #include "internal.h"
55759
55760 /*
55761 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55762 write_seqcount_begin(&fs->seq);
55763 old_root = fs->root;
55764 fs->root = *path;
55765 + gr_set_chroot_entries(current, path);
55766 write_seqcount_end(&fs->seq);
55767 spin_unlock(&fs->lock);
55768 if (old_root.dentry)
55769 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55770 int hits = 0;
55771 spin_lock(&fs->lock);
55772 write_seqcount_begin(&fs->seq);
55773 + /* this root replacement is only done by pivot_root,
55774 + leave grsec's chroot tagging alone for this task
55775 + so that a pivoted root isn't treated as a chroot
55776 + */
55777 hits += replace_path(&fs->root, old_root, new_root);
55778 hits += replace_path(&fs->pwd, old_root, new_root);
55779 write_seqcount_end(&fs->seq);
55780 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55781 task_lock(tsk);
55782 spin_lock(&fs->lock);
55783 tsk->fs = NULL;
55784 - kill = !--fs->users;
55785 + gr_clear_chroot_entries(tsk);
55786 + kill = !atomic_dec_return(&fs->users);
55787 spin_unlock(&fs->lock);
55788 task_unlock(tsk);
55789 if (kill)
55790 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55791 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55792 /* We don't need to lock fs - think why ;-) */
55793 if (fs) {
55794 - fs->users = 1;
55795 + atomic_set(&fs->users, 1);
55796 fs->in_exec = 0;
55797 spin_lock_init(&fs->lock);
55798 seqcount_init(&fs->seq);
55799 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55800 spin_lock(&old->lock);
55801 fs->root = old->root;
55802 path_get(&fs->root);
55803 + /* instead of calling gr_set_chroot_entries here,
55804 + we call it from every caller of this function
55805 + */
55806 fs->pwd = old->pwd;
55807 path_get(&fs->pwd);
55808 spin_unlock(&old->lock);
55809 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55810
55811 task_lock(current);
55812 spin_lock(&fs->lock);
55813 - kill = !--fs->users;
55814 + kill = !atomic_dec_return(&fs->users);
55815 current->fs = new_fs;
55816 + gr_set_chroot_entries(current, &new_fs->root);
55817 spin_unlock(&fs->lock);
55818 task_unlock(current);
55819
55820 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55821
55822 int current_umask(void)
55823 {
55824 - return current->fs->umask;
55825 + return current->fs->umask | gr_acl_umask();
55826 }
55827 EXPORT_SYMBOL(current_umask);
55828
55829 /* to be mentioned only in INIT_TASK */
55830 struct fs_struct init_fs = {
55831 - .users = 1,
55832 + .users = ATOMIC_INIT(1),
55833 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55834 .seq = SEQCNT_ZERO,
55835 .umask = 0022,
55836 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55837 index 0e91a3c..6c6d2e0 100644
55838 --- a/fs/fscache/cookie.c
55839 +++ b/fs/fscache/cookie.c
55840 @@ -19,7 +19,7 @@
55841
55842 struct kmem_cache *fscache_cookie_jar;
55843
55844 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55845 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55846
55847 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55848 static int fscache_alloc_object(struct fscache_cache *cache,
55849 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55850 parent ? (char *) parent->def->name : "<no-parent>",
55851 def->name, netfs_data);
55852
55853 - fscache_stat(&fscache_n_acquires);
55854 + fscache_stat_unchecked(&fscache_n_acquires);
55855
55856 /* if there's no parent cookie, then we don't create one here either */
55857 if (!parent) {
55858 - fscache_stat(&fscache_n_acquires_null);
55859 + fscache_stat_unchecked(&fscache_n_acquires_null);
55860 _leave(" [no parent]");
55861 return NULL;
55862 }
55863 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55864 /* allocate and initialise a cookie */
55865 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55866 if (!cookie) {
55867 - fscache_stat(&fscache_n_acquires_oom);
55868 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55869 _leave(" [ENOMEM]");
55870 return NULL;
55871 }
55872 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55873
55874 switch (cookie->def->type) {
55875 case FSCACHE_COOKIE_TYPE_INDEX:
55876 - fscache_stat(&fscache_n_cookie_index);
55877 + fscache_stat_unchecked(&fscache_n_cookie_index);
55878 break;
55879 case FSCACHE_COOKIE_TYPE_DATAFILE:
55880 - fscache_stat(&fscache_n_cookie_data);
55881 + fscache_stat_unchecked(&fscache_n_cookie_data);
55882 break;
55883 default:
55884 - fscache_stat(&fscache_n_cookie_special);
55885 + fscache_stat_unchecked(&fscache_n_cookie_special);
55886 break;
55887 }
55888
55889 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55890 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55891 atomic_dec(&parent->n_children);
55892 __fscache_cookie_put(cookie);
55893 - fscache_stat(&fscache_n_acquires_nobufs);
55894 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55895 _leave(" = NULL");
55896 return NULL;
55897 }
55898 }
55899
55900 - fscache_stat(&fscache_n_acquires_ok);
55901 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55902 _leave(" = %p", cookie);
55903 return cookie;
55904 }
55905 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55906 cache = fscache_select_cache_for_object(cookie->parent);
55907 if (!cache) {
55908 up_read(&fscache_addremove_sem);
55909 - fscache_stat(&fscache_n_acquires_no_cache);
55910 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55911 _leave(" = -ENOMEDIUM [no cache]");
55912 return -ENOMEDIUM;
55913 }
55914 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55915 object = cache->ops->alloc_object(cache, cookie);
55916 fscache_stat_d(&fscache_n_cop_alloc_object);
55917 if (IS_ERR(object)) {
55918 - fscache_stat(&fscache_n_object_no_alloc);
55919 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55920 ret = PTR_ERR(object);
55921 goto error;
55922 }
55923
55924 - fscache_stat(&fscache_n_object_alloc);
55925 + fscache_stat_unchecked(&fscache_n_object_alloc);
55926
55927 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55928 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55929
55930 _debug("ALLOC OBJ%x: %s {%lx}",
55931 object->debug_id, cookie->def->name, object->events);
55932 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55933
55934 _enter("{%s}", cookie->def->name);
55935
55936 - fscache_stat(&fscache_n_invalidates);
55937 + fscache_stat_unchecked(&fscache_n_invalidates);
55938
55939 /* Only permit invalidation of data files. Invalidating an index will
55940 * require the caller to release all its attachments to the tree rooted
55941 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
55942 {
55943 struct fscache_object *object;
55944
55945 - fscache_stat(&fscache_n_updates);
55946 + fscache_stat_unchecked(&fscache_n_updates);
55947
55948 if (!cookie) {
55949 - fscache_stat(&fscache_n_updates_null);
55950 + fscache_stat_unchecked(&fscache_n_updates_null);
55951 _leave(" [no cookie]");
55952 return;
55953 }
55954 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
55955 {
55956 struct fscache_object *object;
55957
55958 - fscache_stat(&fscache_n_relinquishes);
55959 + fscache_stat_unchecked(&fscache_n_relinquishes);
55960 if (retire)
55961 - fscache_stat(&fscache_n_relinquishes_retire);
55962 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
55963
55964 if (!cookie) {
55965 - fscache_stat(&fscache_n_relinquishes_null);
55966 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
55967 _leave(" [no cookie]");
55968 return;
55969 }
55970 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
55971 index 12d505b..86473a3 100644
55972 --- a/fs/fscache/internal.h
55973 +++ b/fs/fscache/internal.h
55974 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
55975 * stats.c
55976 */
55977 #ifdef CONFIG_FSCACHE_STATS
55978 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55979 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55980 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55981 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55982
55983 -extern atomic_t fscache_n_op_pend;
55984 -extern atomic_t fscache_n_op_run;
55985 -extern atomic_t fscache_n_op_enqueue;
55986 -extern atomic_t fscache_n_op_deferred_release;
55987 -extern atomic_t fscache_n_op_release;
55988 -extern atomic_t fscache_n_op_gc;
55989 -extern atomic_t fscache_n_op_cancelled;
55990 -extern atomic_t fscache_n_op_rejected;
55991 +extern atomic_unchecked_t fscache_n_op_pend;
55992 +extern atomic_unchecked_t fscache_n_op_run;
55993 +extern atomic_unchecked_t fscache_n_op_enqueue;
55994 +extern atomic_unchecked_t fscache_n_op_deferred_release;
55995 +extern atomic_unchecked_t fscache_n_op_release;
55996 +extern atomic_unchecked_t fscache_n_op_gc;
55997 +extern atomic_unchecked_t fscache_n_op_cancelled;
55998 +extern atomic_unchecked_t fscache_n_op_rejected;
55999
56000 -extern atomic_t fscache_n_attr_changed;
56001 -extern atomic_t fscache_n_attr_changed_ok;
56002 -extern atomic_t fscache_n_attr_changed_nobufs;
56003 -extern atomic_t fscache_n_attr_changed_nomem;
56004 -extern atomic_t fscache_n_attr_changed_calls;
56005 +extern atomic_unchecked_t fscache_n_attr_changed;
56006 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
56007 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
56008 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
56009 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
56010
56011 -extern atomic_t fscache_n_allocs;
56012 -extern atomic_t fscache_n_allocs_ok;
56013 -extern atomic_t fscache_n_allocs_wait;
56014 -extern atomic_t fscache_n_allocs_nobufs;
56015 -extern atomic_t fscache_n_allocs_intr;
56016 -extern atomic_t fscache_n_allocs_object_dead;
56017 -extern atomic_t fscache_n_alloc_ops;
56018 -extern atomic_t fscache_n_alloc_op_waits;
56019 +extern atomic_unchecked_t fscache_n_allocs;
56020 +extern atomic_unchecked_t fscache_n_allocs_ok;
56021 +extern atomic_unchecked_t fscache_n_allocs_wait;
56022 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
56023 +extern atomic_unchecked_t fscache_n_allocs_intr;
56024 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
56025 +extern atomic_unchecked_t fscache_n_alloc_ops;
56026 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
56027
56028 -extern atomic_t fscache_n_retrievals;
56029 -extern atomic_t fscache_n_retrievals_ok;
56030 -extern atomic_t fscache_n_retrievals_wait;
56031 -extern atomic_t fscache_n_retrievals_nodata;
56032 -extern atomic_t fscache_n_retrievals_nobufs;
56033 -extern atomic_t fscache_n_retrievals_intr;
56034 -extern atomic_t fscache_n_retrievals_nomem;
56035 -extern atomic_t fscache_n_retrievals_object_dead;
56036 -extern atomic_t fscache_n_retrieval_ops;
56037 -extern atomic_t fscache_n_retrieval_op_waits;
56038 +extern atomic_unchecked_t fscache_n_retrievals;
56039 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56040 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56041 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56042 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56043 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56044 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56045 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56046 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56047 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56048
56049 -extern atomic_t fscache_n_stores;
56050 -extern atomic_t fscache_n_stores_ok;
56051 -extern atomic_t fscache_n_stores_again;
56052 -extern atomic_t fscache_n_stores_nobufs;
56053 -extern atomic_t fscache_n_stores_oom;
56054 -extern atomic_t fscache_n_store_ops;
56055 -extern atomic_t fscache_n_store_calls;
56056 -extern atomic_t fscache_n_store_pages;
56057 -extern atomic_t fscache_n_store_radix_deletes;
56058 -extern atomic_t fscache_n_store_pages_over_limit;
56059 +extern atomic_unchecked_t fscache_n_stores;
56060 +extern atomic_unchecked_t fscache_n_stores_ok;
56061 +extern atomic_unchecked_t fscache_n_stores_again;
56062 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56063 +extern atomic_unchecked_t fscache_n_stores_oom;
56064 +extern atomic_unchecked_t fscache_n_store_ops;
56065 +extern atomic_unchecked_t fscache_n_store_calls;
56066 +extern atomic_unchecked_t fscache_n_store_pages;
56067 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56068 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56069
56070 -extern atomic_t fscache_n_store_vmscan_not_storing;
56071 -extern atomic_t fscache_n_store_vmscan_gone;
56072 -extern atomic_t fscache_n_store_vmscan_busy;
56073 -extern atomic_t fscache_n_store_vmscan_cancelled;
56074 -extern atomic_t fscache_n_store_vmscan_wait;
56075 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56076 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56077 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56078 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56079 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56080
56081 -extern atomic_t fscache_n_marks;
56082 -extern atomic_t fscache_n_uncaches;
56083 +extern atomic_unchecked_t fscache_n_marks;
56084 +extern atomic_unchecked_t fscache_n_uncaches;
56085
56086 -extern atomic_t fscache_n_acquires;
56087 -extern atomic_t fscache_n_acquires_null;
56088 -extern atomic_t fscache_n_acquires_no_cache;
56089 -extern atomic_t fscache_n_acquires_ok;
56090 -extern atomic_t fscache_n_acquires_nobufs;
56091 -extern atomic_t fscache_n_acquires_oom;
56092 +extern atomic_unchecked_t fscache_n_acquires;
56093 +extern atomic_unchecked_t fscache_n_acquires_null;
56094 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56095 +extern atomic_unchecked_t fscache_n_acquires_ok;
56096 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56097 +extern atomic_unchecked_t fscache_n_acquires_oom;
56098
56099 -extern atomic_t fscache_n_invalidates;
56100 -extern atomic_t fscache_n_invalidates_run;
56101 +extern atomic_unchecked_t fscache_n_invalidates;
56102 +extern atomic_unchecked_t fscache_n_invalidates_run;
56103
56104 -extern atomic_t fscache_n_updates;
56105 -extern atomic_t fscache_n_updates_null;
56106 -extern atomic_t fscache_n_updates_run;
56107 +extern atomic_unchecked_t fscache_n_updates;
56108 +extern atomic_unchecked_t fscache_n_updates_null;
56109 +extern atomic_unchecked_t fscache_n_updates_run;
56110
56111 -extern atomic_t fscache_n_relinquishes;
56112 -extern atomic_t fscache_n_relinquishes_null;
56113 -extern atomic_t fscache_n_relinquishes_waitcrt;
56114 -extern atomic_t fscache_n_relinquishes_retire;
56115 +extern atomic_unchecked_t fscache_n_relinquishes;
56116 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56117 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56118 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56119
56120 -extern atomic_t fscache_n_cookie_index;
56121 -extern atomic_t fscache_n_cookie_data;
56122 -extern atomic_t fscache_n_cookie_special;
56123 +extern atomic_unchecked_t fscache_n_cookie_index;
56124 +extern atomic_unchecked_t fscache_n_cookie_data;
56125 +extern atomic_unchecked_t fscache_n_cookie_special;
56126
56127 -extern atomic_t fscache_n_object_alloc;
56128 -extern atomic_t fscache_n_object_no_alloc;
56129 -extern atomic_t fscache_n_object_lookups;
56130 -extern atomic_t fscache_n_object_lookups_negative;
56131 -extern atomic_t fscache_n_object_lookups_positive;
56132 -extern atomic_t fscache_n_object_lookups_timed_out;
56133 -extern atomic_t fscache_n_object_created;
56134 -extern atomic_t fscache_n_object_avail;
56135 -extern atomic_t fscache_n_object_dead;
56136 +extern atomic_unchecked_t fscache_n_object_alloc;
56137 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56138 +extern atomic_unchecked_t fscache_n_object_lookups;
56139 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56140 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56141 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56142 +extern atomic_unchecked_t fscache_n_object_created;
56143 +extern atomic_unchecked_t fscache_n_object_avail;
56144 +extern atomic_unchecked_t fscache_n_object_dead;
56145
56146 -extern atomic_t fscache_n_checkaux_none;
56147 -extern atomic_t fscache_n_checkaux_okay;
56148 -extern atomic_t fscache_n_checkaux_update;
56149 -extern atomic_t fscache_n_checkaux_obsolete;
56150 +extern atomic_unchecked_t fscache_n_checkaux_none;
56151 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56152 +extern atomic_unchecked_t fscache_n_checkaux_update;
56153 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56154
56155 extern atomic_t fscache_n_cop_alloc_object;
56156 extern atomic_t fscache_n_cop_lookup_object;
56157 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
56158 atomic_inc(stat);
56159 }
56160
56161 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56162 +{
56163 + atomic_inc_unchecked(stat);
56164 +}
56165 +
56166 static inline void fscache_stat_d(atomic_t *stat)
56167 {
56168 atomic_dec(stat);
56169 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
56170
56171 #define __fscache_stat(stat) (NULL)
56172 #define fscache_stat(stat) do {} while (0)
56173 +#define fscache_stat_unchecked(stat) do {} while (0)
56174 #define fscache_stat_d(stat) do {} while (0)
56175 #endif
56176
56177 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56178 index 86d75a6..5f3d7a0 100644
56179 --- a/fs/fscache/object.c
56180 +++ b/fs/fscache/object.c
56181 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56182 _debug("LOOKUP \"%s\" in \"%s\"",
56183 cookie->def->name, object->cache->tag->name);
56184
56185 - fscache_stat(&fscache_n_object_lookups);
56186 + fscache_stat_unchecked(&fscache_n_object_lookups);
56187 fscache_stat(&fscache_n_cop_lookup_object);
56188 ret = object->cache->ops->lookup_object(object);
56189 fscache_stat_d(&fscache_n_cop_lookup_object);
56190 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56191 if (ret == -ETIMEDOUT) {
56192 /* probably stuck behind another object, so move this one to
56193 * the back of the queue */
56194 - fscache_stat(&fscache_n_object_lookups_timed_out);
56195 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56196 _leave(" [timeout]");
56197 return NO_TRANSIT;
56198 }
56199 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56200 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56201
56202 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56203 - fscache_stat(&fscache_n_object_lookups_negative);
56204 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56205
56206 /* Allow write requests to begin stacking up and read requests to begin
56207 * returning ENODATA.
56208 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56209 /* if we were still looking up, then we must have a positive lookup
56210 * result, in which case there may be data available */
56211 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56212 - fscache_stat(&fscache_n_object_lookups_positive);
56213 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56214
56215 /* We do (presumably) have data */
56216 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56217 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56218 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56219 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56220 } else {
56221 - fscache_stat(&fscache_n_object_created);
56222 + fscache_stat_unchecked(&fscache_n_object_created);
56223 }
56224
56225 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56226 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56227 fscache_stat_d(&fscache_n_cop_lookup_complete);
56228
56229 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56230 - fscache_stat(&fscache_n_object_avail);
56231 + fscache_stat_unchecked(&fscache_n_object_avail);
56232
56233 _leave("");
56234 return transit_to(JUMPSTART_DEPS);
56235 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56236
56237 /* this just shifts the object release to the work processor */
56238 fscache_put_object(object);
56239 - fscache_stat(&fscache_n_object_dead);
56240 + fscache_stat_unchecked(&fscache_n_object_dead);
56241
56242 _leave("");
56243 return transit_to(OBJECT_DEAD);
56244 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56245 enum fscache_checkaux result;
56246
56247 if (!object->cookie->def->check_aux) {
56248 - fscache_stat(&fscache_n_checkaux_none);
56249 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56250 return FSCACHE_CHECKAUX_OKAY;
56251 }
56252
56253 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56254 switch (result) {
56255 /* entry okay as is */
56256 case FSCACHE_CHECKAUX_OKAY:
56257 - fscache_stat(&fscache_n_checkaux_okay);
56258 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56259 break;
56260
56261 /* entry requires update */
56262 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56263 - fscache_stat(&fscache_n_checkaux_update);
56264 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56265 break;
56266
56267 /* entry requires deletion */
56268 case FSCACHE_CHECKAUX_OBSOLETE:
56269 - fscache_stat(&fscache_n_checkaux_obsolete);
56270 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56271 break;
56272
56273 default:
56274 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56275 {
56276 const struct fscache_state *s;
56277
56278 - fscache_stat(&fscache_n_invalidates_run);
56279 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56280 fscache_stat(&fscache_n_cop_invalidate_object);
56281 s = _fscache_invalidate_object(object, event);
56282 fscache_stat_d(&fscache_n_cop_invalidate_object);
56283 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56284 {
56285 _enter("{OBJ%x},%d", object->debug_id, event);
56286
56287 - fscache_stat(&fscache_n_updates_run);
56288 + fscache_stat_unchecked(&fscache_n_updates_run);
56289 fscache_stat(&fscache_n_cop_update_object);
56290 object->cache->ops->update_object(object);
56291 fscache_stat_d(&fscache_n_cop_update_object);
56292 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56293 index 318071a..379938b 100644
56294 --- a/fs/fscache/operation.c
56295 +++ b/fs/fscache/operation.c
56296 @@ -17,7 +17,7 @@
56297 #include <linux/slab.h>
56298 #include "internal.h"
56299
56300 -atomic_t fscache_op_debug_id;
56301 +atomic_unchecked_t fscache_op_debug_id;
56302 EXPORT_SYMBOL(fscache_op_debug_id);
56303
56304 /**
56305 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56306 ASSERTCMP(atomic_read(&op->usage), >, 0);
56307 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56308
56309 - fscache_stat(&fscache_n_op_enqueue);
56310 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56311 switch (op->flags & FSCACHE_OP_TYPE) {
56312 case FSCACHE_OP_ASYNC:
56313 _debug("queue async");
56314 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56315 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56316 if (op->processor)
56317 fscache_enqueue_operation(op);
56318 - fscache_stat(&fscache_n_op_run);
56319 + fscache_stat_unchecked(&fscache_n_op_run);
56320 }
56321
56322 /*
56323 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56324 if (object->n_in_progress > 0) {
56325 atomic_inc(&op->usage);
56326 list_add_tail(&op->pend_link, &object->pending_ops);
56327 - fscache_stat(&fscache_n_op_pend);
56328 + fscache_stat_unchecked(&fscache_n_op_pend);
56329 } else if (!list_empty(&object->pending_ops)) {
56330 atomic_inc(&op->usage);
56331 list_add_tail(&op->pend_link, &object->pending_ops);
56332 - fscache_stat(&fscache_n_op_pend);
56333 + fscache_stat_unchecked(&fscache_n_op_pend);
56334 fscache_start_operations(object);
56335 } else {
56336 ASSERTCMP(object->n_in_progress, ==, 0);
56337 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56338 object->n_exclusive++; /* reads and writes must wait */
56339 atomic_inc(&op->usage);
56340 list_add_tail(&op->pend_link, &object->pending_ops);
56341 - fscache_stat(&fscache_n_op_pend);
56342 + fscache_stat_unchecked(&fscache_n_op_pend);
56343 ret = 0;
56344 } else {
56345 /* If we're in any other state, there must have been an I/O
56346 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56347 if (object->n_exclusive > 0) {
56348 atomic_inc(&op->usage);
56349 list_add_tail(&op->pend_link, &object->pending_ops);
56350 - fscache_stat(&fscache_n_op_pend);
56351 + fscache_stat_unchecked(&fscache_n_op_pend);
56352 } else if (!list_empty(&object->pending_ops)) {
56353 atomic_inc(&op->usage);
56354 list_add_tail(&op->pend_link, &object->pending_ops);
56355 - fscache_stat(&fscache_n_op_pend);
56356 + fscache_stat_unchecked(&fscache_n_op_pend);
56357 fscache_start_operations(object);
56358 } else {
56359 ASSERTCMP(object->n_exclusive, ==, 0);
56360 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56361 object->n_ops++;
56362 atomic_inc(&op->usage);
56363 list_add_tail(&op->pend_link, &object->pending_ops);
56364 - fscache_stat(&fscache_n_op_pend);
56365 + fscache_stat_unchecked(&fscache_n_op_pend);
56366 ret = 0;
56367 } else if (fscache_object_is_dying(object)) {
56368 - fscache_stat(&fscache_n_op_rejected);
56369 + fscache_stat_unchecked(&fscache_n_op_rejected);
56370 op->state = FSCACHE_OP_ST_CANCELLED;
56371 ret = -ENOBUFS;
56372 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56373 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56374 ret = -EBUSY;
56375 if (op->state == FSCACHE_OP_ST_PENDING) {
56376 ASSERT(!list_empty(&op->pend_link));
56377 - fscache_stat(&fscache_n_op_cancelled);
56378 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56379 list_del_init(&op->pend_link);
56380 if (do_cancel)
56381 do_cancel(op);
56382 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56383 while (!list_empty(&object->pending_ops)) {
56384 op = list_entry(object->pending_ops.next,
56385 struct fscache_operation, pend_link);
56386 - fscache_stat(&fscache_n_op_cancelled);
56387 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56388 list_del_init(&op->pend_link);
56389
56390 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56391 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56392 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56393 op->state = FSCACHE_OP_ST_DEAD;
56394
56395 - fscache_stat(&fscache_n_op_release);
56396 + fscache_stat_unchecked(&fscache_n_op_release);
56397
56398 if (op->release) {
56399 op->release(op);
56400 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56401 * lock, and defer it otherwise */
56402 if (!spin_trylock(&object->lock)) {
56403 _debug("defer put");
56404 - fscache_stat(&fscache_n_op_deferred_release);
56405 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56406
56407 cache = object->cache;
56408 spin_lock(&cache->op_gc_list_lock);
56409 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56410
56411 _debug("GC DEFERRED REL OBJ%x OP%x",
56412 object->debug_id, op->debug_id);
56413 - fscache_stat(&fscache_n_op_gc);
56414 + fscache_stat_unchecked(&fscache_n_op_gc);
56415
56416 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56417 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56418 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56419 index d479ab3..727a7f2 100644
56420 --- a/fs/fscache/page.c
56421 +++ b/fs/fscache/page.c
56422 @@ -61,7 +61,7 @@ try_again:
56423 val = radix_tree_lookup(&cookie->stores, page->index);
56424 if (!val) {
56425 rcu_read_unlock();
56426 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56427 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56428 __fscache_uncache_page(cookie, page);
56429 return true;
56430 }
56431 @@ -91,11 +91,11 @@ try_again:
56432 spin_unlock(&cookie->stores_lock);
56433
56434 if (xpage) {
56435 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56436 - fscache_stat(&fscache_n_store_radix_deletes);
56437 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56438 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56439 ASSERTCMP(xpage, ==, page);
56440 } else {
56441 - fscache_stat(&fscache_n_store_vmscan_gone);
56442 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56443 }
56444
56445 wake_up_bit(&cookie->flags, 0);
56446 @@ -110,11 +110,11 @@ page_busy:
56447 * sleeping on memory allocation, so we may need to impose a timeout
56448 * too. */
56449 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56450 - fscache_stat(&fscache_n_store_vmscan_busy);
56451 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56452 return false;
56453 }
56454
56455 - fscache_stat(&fscache_n_store_vmscan_wait);
56456 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56457 __fscache_wait_on_page_write(cookie, page);
56458 gfp &= ~__GFP_WAIT;
56459 goto try_again;
56460 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56461 FSCACHE_COOKIE_STORING_TAG);
56462 if (!radix_tree_tag_get(&cookie->stores, page->index,
56463 FSCACHE_COOKIE_PENDING_TAG)) {
56464 - fscache_stat(&fscache_n_store_radix_deletes);
56465 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56466 xpage = radix_tree_delete(&cookie->stores, page->index);
56467 }
56468 spin_unlock(&cookie->stores_lock);
56469 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56470
56471 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56472
56473 - fscache_stat(&fscache_n_attr_changed_calls);
56474 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56475
56476 if (fscache_object_is_active(object) &&
56477 fscache_use_cookie(object)) {
56478 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56479
56480 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56481
56482 - fscache_stat(&fscache_n_attr_changed);
56483 + fscache_stat_unchecked(&fscache_n_attr_changed);
56484
56485 op = kzalloc(sizeof(*op), GFP_KERNEL);
56486 if (!op) {
56487 - fscache_stat(&fscache_n_attr_changed_nomem);
56488 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56489 _leave(" = -ENOMEM");
56490 return -ENOMEM;
56491 }
56492 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56493 if (fscache_submit_exclusive_op(object, op) < 0)
56494 goto nobufs;
56495 spin_unlock(&cookie->lock);
56496 - fscache_stat(&fscache_n_attr_changed_ok);
56497 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56498 fscache_put_operation(op);
56499 _leave(" = 0");
56500 return 0;
56501 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56502 nobufs:
56503 spin_unlock(&cookie->lock);
56504 kfree(op);
56505 - fscache_stat(&fscache_n_attr_changed_nobufs);
56506 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56507 _leave(" = %d", -ENOBUFS);
56508 return -ENOBUFS;
56509 }
56510 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56511 /* allocate a retrieval operation and attempt to submit it */
56512 op = kzalloc(sizeof(*op), GFP_NOIO);
56513 if (!op) {
56514 - fscache_stat(&fscache_n_retrievals_nomem);
56515 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56516 return NULL;
56517 }
56518
56519 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56520 return 0;
56521 }
56522
56523 - fscache_stat(&fscache_n_retrievals_wait);
56524 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56525
56526 jif = jiffies;
56527 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56528 fscache_wait_bit_interruptible,
56529 TASK_INTERRUPTIBLE) != 0) {
56530 - fscache_stat(&fscache_n_retrievals_intr);
56531 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56532 _leave(" = -ERESTARTSYS");
56533 return -ERESTARTSYS;
56534 }
56535 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56536 */
56537 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56538 struct fscache_retrieval *op,
56539 - atomic_t *stat_op_waits,
56540 - atomic_t *stat_object_dead)
56541 + atomic_unchecked_t *stat_op_waits,
56542 + atomic_unchecked_t *stat_object_dead)
56543 {
56544 int ret;
56545
56546 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56547 goto check_if_dead;
56548
56549 _debug(">>> WT");
56550 - fscache_stat(stat_op_waits);
56551 + fscache_stat_unchecked(stat_op_waits);
56552 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56553 fscache_wait_bit_interruptible,
56554 TASK_INTERRUPTIBLE) != 0) {
56555 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56556
56557 check_if_dead:
56558 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56559 - fscache_stat(stat_object_dead);
56560 + fscache_stat_unchecked(stat_object_dead);
56561 _leave(" = -ENOBUFS [cancelled]");
56562 return -ENOBUFS;
56563 }
56564 if (unlikely(fscache_object_is_dead(object))) {
56565 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56566 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56567 - fscache_stat(stat_object_dead);
56568 + fscache_stat_unchecked(stat_object_dead);
56569 return -ENOBUFS;
56570 }
56571 return 0;
56572 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56573
56574 _enter("%p,%p,,,", cookie, page);
56575
56576 - fscache_stat(&fscache_n_retrievals);
56577 + fscache_stat_unchecked(&fscache_n_retrievals);
56578
56579 if (hlist_empty(&cookie->backing_objects))
56580 goto nobufs;
56581 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56582 goto nobufs_unlock_dec;
56583 spin_unlock(&cookie->lock);
56584
56585 - fscache_stat(&fscache_n_retrieval_ops);
56586 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56587
56588 /* pin the netfs read context in case we need to do the actual netfs
56589 * read because we've encountered a cache read failure */
56590 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56591
56592 error:
56593 if (ret == -ENOMEM)
56594 - fscache_stat(&fscache_n_retrievals_nomem);
56595 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56596 else if (ret == -ERESTARTSYS)
56597 - fscache_stat(&fscache_n_retrievals_intr);
56598 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56599 else if (ret == -ENODATA)
56600 - fscache_stat(&fscache_n_retrievals_nodata);
56601 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56602 else if (ret < 0)
56603 - fscache_stat(&fscache_n_retrievals_nobufs);
56604 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56605 else
56606 - fscache_stat(&fscache_n_retrievals_ok);
56607 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56608
56609 fscache_put_retrieval(op);
56610 _leave(" = %d", ret);
56611 @@ -475,7 +475,7 @@ nobufs_unlock:
56612 atomic_dec(&cookie->n_active);
56613 kfree(op);
56614 nobufs:
56615 - fscache_stat(&fscache_n_retrievals_nobufs);
56616 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56617 _leave(" = -ENOBUFS");
56618 return -ENOBUFS;
56619 }
56620 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56621
56622 _enter("%p,,%d,,,", cookie, *nr_pages);
56623
56624 - fscache_stat(&fscache_n_retrievals);
56625 + fscache_stat_unchecked(&fscache_n_retrievals);
56626
56627 if (hlist_empty(&cookie->backing_objects))
56628 goto nobufs;
56629 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56630 goto nobufs_unlock_dec;
56631 spin_unlock(&cookie->lock);
56632
56633 - fscache_stat(&fscache_n_retrieval_ops);
56634 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56635
56636 /* pin the netfs read context in case we need to do the actual netfs
56637 * read because we've encountered a cache read failure */
56638 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56639
56640 error:
56641 if (ret == -ENOMEM)
56642 - fscache_stat(&fscache_n_retrievals_nomem);
56643 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56644 else if (ret == -ERESTARTSYS)
56645 - fscache_stat(&fscache_n_retrievals_intr);
56646 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56647 else if (ret == -ENODATA)
56648 - fscache_stat(&fscache_n_retrievals_nodata);
56649 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56650 else if (ret < 0)
56651 - fscache_stat(&fscache_n_retrievals_nobufs);
56652 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56653 else
56654 - fscache_stat(&fscache_n_retrievals_ok);
56655 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56656
56657 fscache_put_retrieval(op);
56658 _leave(" = %d", ret);
56659 @@ -600,7 +600,7 @@ nobufs_unlock:
56660 atomic_dec(&cookie->n_active);
56661 kfree(op);
56662 nobufs:
56663 - fscache_stat(&fscache_n_retrievals_nobufs);
56664 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56665 _leave(" = -ENOBUFS");
56666 return -ENOBUFS;
56667 }
56668 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56669
56670 _enter("%p,%p,,,", cookie, page);
56671
56672 - fscache_stat(&fscache_n_allocs);
56673 + fscache_stat_unchecked(&fscache_n_allocs);
56674
56675 if (hlist_empty(&cookie->backing_objects))
56676 goto nobufs;
56677 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56678 goto nobufs_unlock;
56679 spin_unlock(&cookie->lock);
56680
56681 - fscache_stat(&fscache_n_alloc_ops);
56682 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56683
56684 ret = fscache_wait_for_retrieval_activation(
56685 object, op,
56686 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56687
56688 error:
56689 if (ret == -ERESTARTSYS)
56690 - fscache_stat(&fscache_n_allocs_intr);
56691 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56692 else if (ret < 0)
56693 - fscache_stat(&fscache_n_allocs_nobufs);
56694 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56695 else
56696 - fscache_stat(&fscache_n_allocs_ok);
56697 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56698
56699 fscache_put_retrieval(op);
56700 _leave(" = %d", ret);
56701 @@ -687,7 +687,7 @@ nobufs_unlock:
56702 atomic_dec(&cookie->n_active);
56703 kfree(op);
56704 nobufs:
56705 - fscache_stat(&fscache_n_allocs_nobufs);
56706 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56707 _leave(" = -ENOBUFS");
56708 return -ENOBUFS;
56709 }
56710 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56711
56712 spin_lock(&cookie->stores_lock);
56713
56714 - fscache_stat(&fscache_n_store_calls);
56715 + fscache_stat_unchecked(&fscache_n_store_calls);
56716
56717 /* find a page to store */
56718 page = NULL;
56719 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56720 page = results[0];
56721 _debug("gang %d [%lx]", n, page->index);
56722 if (page->index > op->store_limit) {
56723 - fscache_stat(&fscache_n_store_pages_over_limit);
56724 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56725 goto superseded;
56726 }
56727
56728 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56729 spin_unlock(&cookie->stores_lock);
56730 spin_unlock(&object->lock);
56731
56732 - fscache_stat(&fscache_n_store_pages);
56733 + fscache_stat_unchecked(&fscache_n_store_pages);
56734 fscache_stat(&fscache_n_cop_write_page);
56735 ret = object->cache->ops->write_page(op, page);
56736 fscache_stat_d(&fscache_n_cop_write_page);
56737 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56738 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56739 ASSERT(PageFsCache(page));
56740
56741 - fscache_stat(&fscache_n_stores);
56742 + fscache_stat_unchecked(&fscache_n_stores);
56743
56744 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56745 _leave(" = -ENOBUFS [invalidating]");
56746 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56747 spin_unlock(&cookie->stores_lock);
56748 spin_unlock(&object->lock);
56749
56750 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56751 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56752 op->store_limit = object->store_limit;
56753
56754 atomic_inc(&cookie->n_active);
56755 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56756
56757 spin_unlock(&cookie->lock);
56758 radix_tree_preload_end();
56759 - fscache_stat(&fscache_n_store_ops);
56760 - fscache_stat(&fscache_n_stores_ok);
56761 + fscache_stat_unchecked(&fscache_n_store_ops);
56762 + fscache_stat_unchecked(&fscache_n_stores_ok);
56763
56764 /* the work queue now carries its own ref on the object */
56765 fscache_put_operation(&op->op);
56766 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56767 return 0;
56768
56769 already_queued:
56770 - fscache_stat(&fscache_n_stores_again);
56771 + fscache_stat_unchecked(&fscache_n_stores_again);
56772 already_pending:
56773 spin_unlock(&cookie->stores_lock);
56774 spin_unlock(&object->lock);
56775 spin_unlock(&cookie->lock);
56776 radix_tree_preload_end();
56777 kfree(op);
56778 - fscache_stat(&fscache_n_stores_ok);
56779 + fscache_stat_unchecked(&fscache_n_stores_ok);
56780 _leave(" = 0");
56781 return 0;
56782
56783 @@ -976,14 +976,14 @@ nobufs:
56784 spin_unlock(&cookie->lock);
56785 radix_tree_preload_end();
56786 kfree(op);
56787 - fscache_stat(&fscache_n_stores_nobufs);
56788 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56789 _leave(" = -ENOBUFS");
56790 return -ENOBUFS;
56791
56792 nomem_free:
56793 kfree(op);
56794 nomem:
56795 - fscache_stat(&fscache_n_stores_oom);
56796 + fscache_stat_unchecked(&fscache_n_stores_oom);
56797 _leave(" = -ENOMEM");
56798 return -ENOMEM;
56799 }
56800 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56801 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56802 ASSERTCMP(page, !=, NULL);
56803
56804 - fscache_stat(&fscache_n_uncaches);
56805 + fscache_stat_unchecked(&fscache_n_uncaches);
56806
56807 /* cache withdrawal may beat us to it */
56808 if (!PageFsCache(page))
56809 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56810 struct fscache_cookie *cookie = op->op.object->cookie;
56811
56812 #ifdef CONFIG_FSCACHE_STATS
56813 - atomic_inc(&fscache_n_marks);
56814 + atomic_inc_unchecked(&fscache_n_marks);
56815 #endif
56816
56817 _debug("- mark %p{%lx}", page, page->index);
56818 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56819 index 40d13c7..ddf52b9 100644
56820 --- a/fs/fscache/stats.c
56821 +++ b/fs/fscache/stats.c
56822 @@ -18,99 +18,99 @@
56823 /*
56824 * operation counters
56825 */
56826 -atomic_t fscache_n_op_pend;
56827 -atomic_t fscache_n_op_run;
56828 -atomic_t fscache_n_op_enqueue;
56829 -atomic_t fscache_n_op_requeue;
56830 -atomic_t fscache_n_op_deferred_release;
56831 -atomic_t fscache_n_op_release;
56832 -atomic_t fscache_n_op_gc;
56833 -atomic_t fscache_n_op_cancelled;
56834 -atomic_t fscache_n_op_rejected;
56835 +atomic_unchecked_t fscache_n_op_pend;
56836 +atomic_unchecked_t fscache_n_op_run;
56837 +atomic_unchecked_t fscache_n_op_enqueue;
56838 +atomic_unchecked_t fscache_n_op_requeue;
56839 +atomic_unchecked_t fscache_n_op_deferred_release;
56840 +atomic_unchecked_t fscache_n_op_release;
56841 +atomic_unchecked_t fscache_n_op_gc;
56842 +atomic_unchecked_t fscache_n_op_cancelled;
56843 +atomic_unchecked_t fscache_n_op_rejected;
56844
56845 -atomic_t fscache_n_attr_changed;
56846 -atomic_t fscache_n_attr_changed_ok;
56847 -atomic_t fscache_n_attr_changed_nobufs;
56848 -atomic_t fscache_n_attr_changed_nomem;
56849 -atomic_t fscache_n_attr_changed_calls;
56850 +atomic_unchecked_t fscache_n_attr_changed;
56851 +atomic_unchecked_t fscache_n_attr_changed_ok;
56852 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56853 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56854 +atomic_unchecked_t fscache_n_attr_changed_calls;
56855
56856 -atomic_t fscache_n_allocs;
56857 -atomic_t fscache_n_allocs_ok;
56858 -atomic_t fscache_n_allocs_wait;
56859 -atomic_t fscache_n_allocs_nobufs;
56860 -atomic_t fscache_n_allocs_intr;
56861 -atomic_t fscache_n_allocs_object_dead;
56862 -atomic_t fscache_n_alloc_ops;
56863 -atomic_t fscache_n_alloc_op_waits;
56864 +atomic_unchecked_t fscache_n_allocs;
56865 +atomic_unchecked_t fscache_n_allocs_ok;
56866 +atomic_unchecked_t fscache_n_allocs_wait;
56867 +atomic_unchecked_t fscache_n_allocs_nobufs;
56868 +atomic_unchecked_t fscache_n_allocs_intr;
56869 +atomic_unchecked_t fscache_n_allocs_object_dead;
56870 +atomic_unchecked_t fscache_n_alloc_ops;
56871 +atomic_unchecked_t fscache_n_alloc_op_waits;
56872
56873 -atomic_t fscache_n_retrievals;
56874 -atomic_t fscache_n_retrievals_ok;
56875 -atomic_t fscache_n_retrievals_wait;
56876 -atomic_t fscache_n_retrievals_nodata;
56877 -atomic_t fscache_n_retrievals_nobufs;
56878 -atomic_t fscache_n_retrievals_intr;
56879 -atomic_t fscache_n_retrievals_nomem;
56880 -atomic_t fscache_n_retrievals_object_dead;
56881 -atomic_t fscache_n_retrieval_ops;
56882 -atomic_t fscache_n_retrieval_op_waits;
56883 +atomic_unchecked_t fscache_n_retrievals;
56884 +atomic_unchecked_t fscache_n_retrievals_ok;
56885 +atomic_unchecked_t fscache_n_retrievals_wait;
56886 +atomic_unchecked_t fscache_n_retrievals_nodata;
56887 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56888 +atomic_unchecked_t fscache_n_retrievals_intr;
56889 +atomic_unchecked_t fscache_n_retrievals_nomem;
56890 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56891 +atomic_unchecked_t fscache_n_retrieval_ops;
56892 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56893
56894 -atomic_t fscache_n_stores;
56895 -atomic_t fscache_n_stores_ok;
56896 -atomic_t fscache_n_stores_again;
56897 -atomic_t fscache_n_stores_nobufs;
56898 -atomic_t fscache_n_stores_oom;
56899 -atomic_t fscache_n_store_ops;
56900 -atomic_t fscache_n_store_calls;
56901 -atomic_t fscache_n_store_pages;
56902 -atomic_t fscache_n_store_radix_deletes;
56903 -atomic_t fscache_n_store_pages_over_limit;
56904 +atomic_unchecked_t fscache_n_stores;
56905 +atomic_unchecked_t fscache_n_stores_ok;
56906 +atomic_unchecked_t fscache_n_stores_again;
56907 +atomic_unchecked_t fscache_n_stores_nobufs;
56908 +atomic_unchecked_t fscache_n_stores_oom;
56909 +atomic_unchecked_t fscache_n_store_ops;
56910 +atomic_unchecked_t fscache_n_store_calls;
56911 +atomic_unchecked_t fscache_n_store_pages;
56912 +atomic_unchecked_t fscache_n_store_radix_deletes;
56913 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56914
56915 -atomic_t fscache_n_store_vmscan_not_storing;
56916 -atomic_t fscache_n_store_vmscan_gone;
56917 -atomic_t fscache_n_store_vmscan_busy;
56918 -atomic_t fscache_n_store_vmscan_cancelled;
56919 -atomic_t fscache_n_store_vmscan_wait;
56920 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56921 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56922 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56923 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56924 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56925
56926 -atomic_t fscache_n_marks;
56927 -atomic_t fscache_n_uncaches;
56928 +atomic_unchecked_t fscache_n_marks;
56929 +atomic_unchecked_t fscache_n_uncaches;
56930
56931 -atomic_t fscache_n_acquires;
56932 -atomic_t fscache_n_acquires_null;
56933 -atomic_t fscache_n_acquires_no_cache;
56934 -atomic_t fscache_n_acquires_ok;
56935 -atomic_t fscache_n_acquires_nobufs;
56936 -atomic_t fscache_n_acquires_oom;
56937 +atomic_unchecked_t fscache_n_acquires;
56938 +atomic_unchecked_t fscache_n_acquires_null;
56939 +atomic_unchecked_t fscache_n_acquires_no_cache;
56940 +atomic_unchecked_t fscache_n_acquires_ok;
56941 +atomic_unchecked_t fscache_n_acquires_nobufs;
56942 +atomic_unchecked_t fscache_n_acquires_oom;
56943
56944 -atomic_t fscache_n_invalidates;
56945 -atomic_t fscache_n_invalidates_run;
56946 +atomic_unchecked_t fscache_n_invalidates;
56947 +atomic_unchecked_t fscache_n_invalidates_run;
56948
56949 -atomic_t fscache_n_updates;
56950 -atomic_t fscache_n_updates_null;
56951 -atomic_t fscache_n_updates_run;
56952 +atomic_unchecked_t fscache_n_updates;
56953 +atomic_unchecked_t fscache_n_updates_null;
56954 +atomic_unchecked_t fscache_n_updates_run;
56955
56956 -atomic_t fscache_n_relinquishes;
56957 -atomic_t fscache_n_relinquishes_null;
56958 -atomic_t fscache_n_relinquishes_waitcrt;
56959 -atomic_t fscache_n_relinquishes_retire;
56960 +atomic_unchecked_t fscache_n_relinquishes;
56961 +atomic_unchecked_t fscache_n_relinquishes_null;
56962 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56963 +atomic_unchecked_t fscache_n_relinquishes_retire;
56964
56965 -atomic_t fscache_n_cookie_index;
56966 -atomic_t fscache_n_cookie_data;
56967 -atomic_t fscache_n_cookie_special;
56968 +atomic_unchecked_t fscache_n_cookie_index;
56969 +atomic_unchecked_t fscache_n_cookie_data;
56970 +atomic_unchecked_t fscache_n_cookie_special;
56971
56972 -atomic_t fscache_n_object_alloc;
56973 -atomic_t fscache_n_object_no_alloc;
56974 -atomic_t fscache_n_object_lookups;
56975 -atomic_t fscache_n_object_lookups_negative;
56976 -atomic_t fscache_n_object_lookups_positive;
56977 -atomic_t fscache_n_object_lookups_timed_out;
56978 -atomic_t fscache_n_object_created;
56979 -atomic_t fscache_n_object_avail;
56980 -atomic_t fscache_n_object_dead;
56981 +atomic_unchecked_t fscache_n_object_alloc;
56982 +atomic_unchecked_t fscache_n_object_no_alloc;
56983 +atomic_unchecked_t fscache_n_object_lookups;
56984 +atomic_unchecked_t fscache_n_object_lookups_negative;
56985 +atomic_unchecked_t fscache_n_object_lookups_positive;
56986 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
56987 +atomic_unchecked_t fscache_n_object_created;
56988 +atomic_unchecked_t fscache_n_object_avail;
56989 +atomic_unchecked_t fscache_n_object_dead;
56990
56991 -atomic_t fscache_n_checkaux_none;
56992 -atomic_t fscache_n_checkaux_okay;
56993 -atomic_t fscache_n_checkaux_update;
56994 -atomic_t fscache_n_checkaux_obsolete;
56995 +atomic_unchecked_t fscache_n_checkaux_none;
56996 +atomic_unchecked_t fscache_n_checkaux_okay;
56997 +atomic_unchecked_t fscache_n_checkaux_update;
56998 +atomic_unchecked_t fscache_n_checkaux_obsolete;
56999
57000 atomic_t fscache_n_cop_alloc_object;
57001 atomic_t fscache_n_cop_lookup_object;
57002 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
57003 seq_puts(m, "FS-Cache statistics\n");
57004
57005 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
57006 - atomic_read(&fscache_n_cookie_index),
57007 - atomic_read(&fscache_n_cookie_data),
57008 - atomic_read(&fscache_n_cookie_special));
57009 + atomic_read_unchecked(&fscache_n_cookie_index),
57010 + atomic_read_unchecked(&fscache_n_cookie_data),
57011 + atomic_read_unchecked(&fscache_n_cookie_special));
57012
57013 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
57014 - atomic_read(&fscache_n_object_alloc),
57015 - atomic_read(&fscache_n_object_no_alloc),
57016 - atomic_read(&fscache_n_object_avail),
57017 - atomic_read(&fscache_n_object_dead));
57018 + atomic_read_unchecked(&fscache_n_object_alloc),
57019 + atomic_read_unchecked(&fscache_n_object_no_alloc),
57020 + atomic_read_unchecked(&fscache_n_object_avail),
57021 + atomic_read_unchecked(&fscache_n_object_dead));
57022 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
57023 - atomic_read(&fscache_n_checkaux_none),
57024 - atomic_read(&fscache_n_checkaux_okay),
57025 - atomic_read(&fscache_n_checkaux_update),
57026 - atomic_read(&fscache_n_checkaux_obsolete));
57027 + atomic_read_unchecked(&fscache_n_checkaux_none),
57028 + atomic_read_unchecked(&fscache_n_checkaux_okay),
57029 + atomic_read_unchecked(&fscache_n_checkaux_update),
57030 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
57031
57032 seq_printf(m, "Pages : mrk=%u unc=%u\n",
57033 - atomic_read(&fscache_n_marks),
57034 - atomic_read(&fscache_n_uncaches));
57035 + atomic_read_unchecked(&fscache_n_marks),
57036 + atomic_read_unchecked(&fscache_n_uncaches));
57037
57038 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57039 " oom=%u\n",
57040 - atomic_read(&fscache_n_acquires),
57041 - atomic_read(&fscache_n_acquires_null),
57042 - atomic_read(&fscache_n_acquires_no_cache),
57043 - atomic_read(&fscache_n_acquires_ok),
57044 - atomic_read(&fscache_n_acquires_nobufs),
57045 - atomic_read(&fscache_n_acquires_oom));
57046 + atomic_read_unchecked(&fscache_n_acquires),
57047 + atomic_read_unchecked(&fscache_n_acquires_null),
57048 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57049 + atomic_read_unchecked(&fscache_n_acquires_ok),
57050 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57051 + atomic_read_unchecked(&fscache_n_acquires_oom));
57052
57053 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57054 - atomic_read(&fscache_n_object_lookups),
57055 - atomic_read(&fscache_n_object_lookups_negative),
57056 - atomic_read(&fscache_n_object_lookups_positive),
57057 - atomic_read(&fscache_n_object_created),
57058 - atomic_read(&fscache_n_object_lookups_timed_out));
57059 + atomic_read_unchecked(&fscache_n_object_lookups),
57060 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57061 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57062 + atomic_read_unchecked(&fscache_n_object_created),
57063 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57064
57065 seq_printf(m, "Invals : n=%u run=%u\n",
57066 - atomic_read(&fscache_n_invalidates),
57067 - atomic_read(&fscache_n_invalidates_run));
57068 + atomic_read_unchecked(&fscache_n_invalidates),
57069 + atomic_read_unchecked(&fscache_n_invalidates_run));
57070
57071 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57072 - atomic_read(&fscache_n_updates),
57073 - atomic_read(&fscache_n_updates_null),
57074 - atomic_read(&fscache_n_updates_run));
57075 + atomic_read_unchecked(&fscache_n_updates),
57076 + atomic_read_unchecked(&fscache_n_updates_null),
57077 + atomic_read_unchecked(&fscache_n_updates_run));
57078
57079 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57080 - atomic_read(&fscache_n_relinquishes),
57081 - atomic_read(&fscache_n_relinquishes_null),
57082 - atomic_read(&fscache_n_relinquishes_waitcrt),
57083 - atomic_read(&fscache_n_relinquishes_retire));
57084 + atomic_read_unchecked(&fscache_n_relinquishes),
57085 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57086 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57087 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57088
57089 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57090 - atomic_read(&fscache_n_attr_changed),
57091 - atomic_read(&fscache_n_attr_changed_ok),
57092 - atomic_read(&fscache_n_attr_changed_nobufs),
57093 - atomic_read(&fscache_n_attr_changed_nomem),
57094 - atomic_read(&fscache_n_attr_changed_calls));
57095 + atomic_read_unchecked(&fscache_n_attr_changed),
57096 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57097 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57098 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57099 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57100
57101 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57102 - atomic_read(&fscache_n_allocs),
57103 - atomic_read(&fscache_n_allocs_ok),
57104 - atomic_read(&fscache_n_allocs_wait),
57105 - atomic_read(&fscache_n_allocs_nobufs),
57106 - atomic_read(&fscache_n_allocs_intr));
57107 + atomic_read_unchecked(&fscache_n_allocs),
57108 + atomic_read_unchecked(&fscache_n_allocs_ok),
57109 + atomic_read_unchecked(&fscache_n_allocs_wait),
57110 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57111 + atomic_read_unchecked(&fscache_n_allocs_intr));
57112 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57113 - atomic_read(&fscache_n_alloc_ops),
57114 - atomic_read(&fscache_n_alloc_op_waits),
57115 - atomic_read(&fscache_n_allocs_object_dead));
57116 + atomic_read_unchecked(&fscache_n_alloc_ops),
57117 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57118 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57119
57120 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57121 " int=%u oom=%u\n",
57122 - atomic_read(&fscache_n_retrievals),
57123 - atomic_read(&fscache_n_retrievals_ok),
57124 - atomic_read(&fscache_n_retrievals_wait),
57125 - atomic_read(&fscache_n_retrievals_nodata),
57126 - atomic_read(&fscache_n_retrievals_nobufs),
57127 - atomic_read(&fscache_n_retrievals_intr),
57128 - atomic_read(&fscache_n_retrievals_nomem));
57129 + atomic_read_unchecked(&fscache_n_retrievals),
57130 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57131 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57132 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57133 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57134 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57135 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57136 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57137 - atomic_read(&fscache_n_retrieval_ops),
57138 - atomic_read(&fscache_n_retrieval_op_waits),
57139 - atomic_read(&fscache_n_retrievals_object_dead));
57140 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57141 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57142 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57143
57144 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57145 - atomic_read(&fscache_n_stores),
57146 - atomic_read(&fscache_n_stores_ok),
57147 - atomic_read(&fscache_n_stores_again),
57148 - atomic_read(&fscache_n_stores_nobufs),
57149 - atomic_read(&fscache_n_stores_oom));
57150 + atomic_read_unchecked(&fscache_n_stores),
57151 + atomic_read_unchecked(&fscache_n_stores_ok),
57152 + atomic_read_unchecked(&fscache_n_stores_again),
57153 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57154 + atomic_read_unchecked(&fscache_n_stores_oom));
57155 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57156 - atomic_read(&fscache_n_store_ops),
57157 - atomic_read(&fscache_n_store_calls),
57158 - atomic_read(&fscache_n_store_pages),
57159 - atomic_read(&fscache_n_store_radix_deletes),
57160 - atomic_read(&fscache_n_store_pages_over_limit));
57161 + atomic_read_unchecked(&fscache_n_store_ops),
57162 + atomic_read_unchecked(&fscache_n_store_calls),
57163 + atomic_read_unchecked(&fscache_n_store_pages),
57164 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57165 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57166
57167 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57168 - atomic_read(&fscache_n_store_vmscan_not_storing),
57169 - atomic_read(&fscache_n_store_vmscan_gone),
57170 - atomic_read(&fscache_n_store_vmscan_busy),
57171 - atomic_read(&fscache_n_store_vmscan_cancelled),
57172 - atomic_read(&fscache_n_store_vmscan_wait));
57173 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57174 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57175 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57176 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57177 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57178
57179 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57180 - atomic_read(&fscache_n_op_pend),
57181 - atomic_read(&fscache_n_op_run),
57182 - atomic_read(&fscache_n_op_enqueue),
57183 - atomic_read(&fscache_n_op_cancelled),
57184 - atomic_read(&fscache_n_op_rejected));
57185 + atomic_read_unchecked(&fscache_n_op_pend),
57186 + atomic_read_unchecked(&fscache_n_op_run),
57187 + atomic_read_unchecked(&fscache_n_op_enqueue),
57188 + atomic_read_unchecked(&fscache_n_op_cancelled),
57189 + atomic_read_unchecked(&fscache_n_op_rejected));
57190 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57191 - atomic_read(&fscache_n_op_deferred_release),
57192 - atomic_read(&fscache_n_op_release),
57193 - atomic_read(&fscache_n_op_gc));
57194 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57195 + atomic_read_unchecked(&fscache_n_op_release),
57196 + atomic_read_unchecked(&fscache_n_op_gc));
57197
57198 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57199 atomic_read(&fscache_n_cop_alloc_object),
57200 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57201 index aef34b1..59bfd7b 100644
57202 --- a/fs/fuse/cuse.c
57203 +++ b/fs/fuse/cuse.c
57204 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57205 INIT_LIST_HEAD(&cuse_conntbl[i]);
57206
57207 /* inherit and extend fuse_dev_operations */
57208 - cuse_channel_fops = fuse_dev_operations;
57209 - cuse_channel_fops.owner = THIS_MODULE;
57210 - cuse_channel_fops.open = cuse_channel_open;
57211 - cuse_channel_fops.release = cuse_channel_release;
57212 + pax_open_kernel();
57213 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57214 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57215 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57216 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57217 + pax_close_kernel();
57218
57219 cuse_class = class_create(THIS_MODULE, "cuse");
57220 if (IS_ERR(cuse_class))
57221 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57222 index 1d55f94..088da65 100644
57223 --- a/fs/fuse/dev.c
57224 +++ b/fs/fuse/dev.c
57225 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57226 ret = 0;
57227 pipe_lock(pipe);
57228
57229 - if (!pipe->readers) {
57230 + if (!atomic_read(&pipe->readers)) {
57231 send_sig(SIGPIPE, current, 0);
57232 if (!ret)
57233 ret = -EPIPE;
57234 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57235 page_nr++;
57236 ret += buf->len;
57237
57238 - if (pipe->files)
57239 + if (atomic_read(&pipe->files))
57240 do_wakeup = 1;
57241 }
57242
57243 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57244 index 72a5d5b..c991011 100644
57245 --- a/fs/fuse/dir.c
57246 +++ b/fs/fuse/dir.c
57247 @@ -1433,7 +1433,7 @@ static char *read_link(struct dentry *dentry)
57248 return link;
57249 }
57250
57251 -static void free_link(char *link)
57252 +static void free_link(const char *link)
57253 {
57254 if (!IS_ERR(link))
57255 free_page((unsigned long) link);
57256 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57257 index 64915ee..6bed500 100644
57258 --- a/fs/gfs2/inode.c
57259 +++ b/fs/gfs2/inode.c
57260 @@ -1506,7 +1506,7 @@ out:
57261
57262 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57263 {
57264 - char *s = nd_get_link(nd);
57265 + const char *s = nd_get_link(nd);
57266 if (!IS_ERR(s))
57267 kfree(s);
57268 }
57269 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57270 index d19b30a..ef89c36 100644
57271 --- a/fs/hugetlbfs/inode.c
57272 +++ b/fs/hugetlbfs/inode.c
57273 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57274 struct mm_struct *mm = current->mm;
57275 struct vm_area_struct *vma;
57276 struct hstate *h = hstate_file(file);
57277 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57278 struct vm_unmapped_area_info info;
57279
57280 if (len & ~huge_page_mask(h))
57281 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57282 return addr;
57283 }
57284
57285 +#ifdef CONFIG_PAX_RANDMMAP
57286 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57287 +#endif
57288 +
57289 if (addr) {
57290 addr = ALIGN(addr, huge_page_size(h));
57291 vma = find_vma(mm, addr);
57292 - if (TASK_SIZE - len >= addr &&
57293 - (!vma || addr + len <= vma->vm_start))
57294 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57295 return addr;
57296 }
57297
57298 info.flags = 0;
57299 info.length = len;
57300 info.low_limit = TASK_UNMAPPED_BASE;
57301 +
57302 +#ifdef CONFIG_PAX_RANDMMAP
57303 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57304 + info.low_limit += mm->delta_mmap;
57305 +#endif
57306 +
57307 info.high_limit = TASK_SIZE;
57308 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57309 info.align_offset = 0;
57310 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57311 };
57312 MODULE_ALIAS_FS("hugetlbfs");
57313
57314 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57315 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57316
57317 static int can_do_hugetlb_shm(void)
57318 {
57319 diff --git a/fs/inode.c b/fs/inode.c
57320 index d6dfb09..602e77e 100644
57321 --- a/fs/inode.c
57322 +++ b/fs/inode.c
57323 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57324
57325 #ifdef CONFIG_SMP
57326 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57327 - static atomic_t shared_last_ino;
57328 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57329 + static atomic_unchecked_t shared_last_ino;
57330 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57331
57332 res = next - LAST_INO_BATCH;
57333 }
57334 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57335 index 4a6cf28..d3a29d3 100644
57336 --- a/fs/jffs2/erase.c
57337 +++ b/fs/jffs2/erase.c
57338 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57339 struct jffs2_unknown_node marker = {
57340 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57341 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57342 - .totlen = cpu_to_je32(c->cleanmarker_size)
57343 + .totlen = cpu_to_je32(c->cleanmarker_size),
57344 + .hdr_crc = cpu_to_je32(0)
57345 };
57346
57347 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57348 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57349 index a6597d6..41b30ec 100644
57350 --- a/fs/jffs2/wbuf.c
57351 +++ b/fs/jffs2/wbuf.c
57352 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57353 {
57354 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57355 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57356 - .totlen = constant_cpu_to_je32(8)
57357 + .totlen = constant_cpu_to_je32(8),
57358 + .hdr_crc = constant_cpu_to_je32(0)
57359 };
57360
57361 /*
57362 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57363 index 6669aa2..36b033d 100644
57364 --- a/fs/jfs/super.c
57365 +++ b/fs/jfs/super.c
57366 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57367
57368 jfs_inode_cachep =
57369 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57370 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57371 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57372 init_once);
57373 if (jfs_inode_cachep == NULL)
57374 return -ENOMEM;
57375 diff --git a/fs/libfs.c b/fs/libfs.c
57376 index 3a3a9b5..3a9b074 100644
57377 --- a/fs/libfs.c
57378 +++ b/fs/libfs.c
57379 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57380
57381 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57382 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57383 + char d_name[sizeof(next->d_iname)];
57384 + const unsigned char *name;
57385 +
57386 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57387 if (!simple_positive(next)) {
57388 spin_unlock(&next->d_lock);
57389 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57390
57391 spin_unlock(&next->d_lock);
57392 spin_unlock(&dentry->d_lock);
57393 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57394 + name = next->d_name.name;
57395 + if (name == next->d_iname) {
57396 + memcpy(d_name, name, next->d_name.len);
57397 + name = d_name;
57398 + }
57399 + if (!dir_emit(ctx, name, next->d_name.len,
57400 next->d_inode->i_ino, dt_type(next->d_inode)))
57401 return 0;
57402 spin_lock(&dentry->d_lock);
57403 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57404 index acd3947..1f896e2 100644
57405 --- a/fs/lockd/clntproc.c
57406 +++ b/fs/lockd/clntproc.c
57407 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57408 /*
57409 * Cookie counter for NLM requests
57410 */
57411 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57412 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57413
57414 void nlmclnt_next_cookie(struct nlm_cookie *c)
57415 {
57416 - u32 cookie = atomic_inc_return(&nlm_cookie);
57417 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57418
57419 memcpy(c->data, &cookie, 4);
57420 c->len=4;
57421 diff --git a/fs/locks.c b/fs/locks.c
57422 index b27a300..4156d0b 100644
57423 --- a/fs/locks.c
57424 +++ b/fs/locks.c
57425 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57426 return;
57427
57428 if (filp->f_op && filp->f_op->flock) {
57429 - struct file_lock fl = {
57430 + struct file_lock flock = {
57431 .fl_pid = current->tgid,
57432 .fl_file = filp,
57433 .fl_flags = FL_FLOCK,
57434 .fl_type = F_UNLCK,
57435 .fl_end = OFFSET_MAX,
57436 };
57437 - filp->f_op->flock(filp, F_SETLKW, &fl);
57438 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57439 - fl.fl_ops->fl_release_private(&fl);
57440 + filp->f_op->flock(filp, F_SETLKW, &flock);
57441 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57442 + flock.fl_ops->fl_release_private(&flock);
57443 }
57444
57445 spin_lock(&inode->i_lock);
57446 diff --git a/fs/namei.c b/fs/namei.c
57447 index 7720fbd..7934bb2 100644
57448 --- a/fs/namei.c
57449 +++ b/fs/namei.c
57450 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57451 if (ret != -EACCES)
57452 return ret;
57453
57454 +#ifdef CONFIG_GRKERNSEC
57455 + /* we'll block if we have to log due to a denied capability use */
57456 + if (mask & MAY_NOT_BLOCK)
57457 + return -ECHILD;
57458 +#endif
57459 +
57460 if (S_ISDIR(inode->i_mode)) {
57461 /* DACs are overridable for directories */
57462 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57463 - return 0;
57464 if (!(mask & MAY_WRITE))
57465 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57466 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57467 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57468 return 0;
57469 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57470 + return 0;
57471 return -EACCES;
57472 }
57473 /*
57474 + * Searching includes executable on directories, else just read.
57475 + */
57476 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57477 + if (mask == MAY_READ)
57478 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57479 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57480 + return 0;
57481 +
57482 + /*
57483 * Read/write DACs are always overridable.
57484 * Executable DACs are overridable when there is
57485 * at least one exec bit set.
57486 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57487 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57488 return 0;
57489
57490 - /*
57491 - * Searching includes executable on directories, else just read.
57492 - */
57493 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57494 - if (mask == MAY_READ)
57495 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57496 - return 0;
57497 -
57498 return -EACCES;
57499 }
57500
57501 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57502 {
57503 struct dentry *dentry = link->dentry;
57504 int error;
57505 - char *s;
57506 + const char *s;
57507
57508 BUG_ON(nd->flags & LOOKUP_RCU);
57509
57510 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57511 if (error)
57512 goto out_put_nd_path;
57513
57514 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57515 + dentry->d_inode, dentry, nd->path.mnt)) {
57516 + error = -EACCES;
57517 + goto out_put_nd_path;
57518 + }
57519 +
57520 nd->last_type = LAST_BIND;
57521 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57522 error = PTR_ERR(*p);
57523 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57524 if (res)
57525 break;
57526 res = walk_component(nd, path, LOOKUP_FOLLOW);
57527 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57528 + res = -EACCES;
57529 put_link(nd, &link, cookie);
57530 } while (res > 0);
57531
57532 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57533 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57534 {
57535 unsigned long a, b, adata, bdata, mask, hash, len;
57536 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57537 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57538
57539 hash = a = 0;
57540 len = -sizeof(unsigned long);
57541 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57542 if (err)
57543 break;
57544 err = lookup_last(nd, &path);
57545 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57546 + err = -EACCES;
57547 put_link(nd, &link, cookie);
57548 }
57549 }
57550 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57551 if (!err)
57552 err = complete_walk(nd);
57553
57554 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57555 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57556 + path_put(&nd->path);
57557 + err = -ENOENT;
57558 + }
57559 + }
57560 +
57561 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57562 if (!can_lookup(nd->inode)) {
57563 path_put(&nd->path);
57564 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57565 retval = path_lookupat(dfd, name->name,
57566 flags | LOOKUP_REVAL, nd);
57567
57568 - if (likely(!retval))
57569 + if (likely(!retval)) {
57570 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57571 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57572 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57573 + path_put(&nd->path);
57574 + return -ENOENT;
57575 + }
57576 + }
57577 + }
57578 return retval;
57579 }
57580
57581 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57582 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57583 return -EPERM;
57584
57585 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57586 + return -EPERM;
57587 + if (gr_handle_rawio(inode))
57588 + return -EPERM;
57589 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57590 + return -EACCES;
57591 +
57592 return 0;
57593 }
57594
57595 @@ -2601,7 +2640,7 @@ looked_up:
57596 * cleared otherwise prior to returning.
57597 */
57598 static int lookup_open(struct nameidata *nd, struct path *path,
57599 - struct file *file,
57600 + struct path *link, struct file *file,
57601 const struct open_flags *op,
57602 bool got_write, int *opened)
57603 {
57604 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57605 /* Negative dentry, just create the file */
57606 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57607 umode_t mode = op->mode;
57608 +
57609 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57610 + error = -EACCES;
57611 + goto out_dput;
57612 + }
57613 +
57614 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57615 + error = -EACCES;
57616 + goto out_dput;
57617 + }
57618 +
57619 if (!IS_POSIXACL(dir->d_inode))
57620 mode &= ~current_umask();
57621 /*
57622 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57623 nd->flags & LOOKUP_EXCL);
57624 if (error)
57625 goto out_dput;
57626 + else
57627 + gr_handle_create(dentry, nd->path.mnt);
57628 }
57629 out_no_open:
57630 path->dentry = dentry;
57631 @@ -2671,7 +2723,7 @@ out_dput:
57632 /*
57633 * Handle the last step of open()
57634 */
57635 -static int do_last(struct nameidata *nd, struct path *path,
57636 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57637 struct file *file, const struct open_flags *op,
57638 int *opened, struct filename *name)
57639 {
57640 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57641 if (error)
57642 return error;
57643
57644 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57645 + error = -ENOENT;
57646 + goto out;
57647 + }
57648 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57649 + error = -EACCES;
57650 + goto out;
57651 + }
57652 +
57653 audit_inode(name, dir, LOOKUP_PARENT);
57654 error = -EISDIR;
57655 /* trailing slashes? */
57656 @@ -2740,7 +2801,7 @@ retry_lookup:
57657 */
57658 }
57659 mutex_lock(&dir->d_inode->i_mutex);
57660 - error = lookup_open(nd, path, file, op, got_write, opened);
57661 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57662 mutex_unlock(&dir->d_inode->i_mutex);
57663
57664 if (error <= 0) {
57665 @@ -2764,11 +2825,28 @@ retry_lookup:
57666 goto finish_open_created;
57667 }
57668
57669 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57670 + error = -ENOENT;
57671 + goto exit_dput;
57672 + }
57673 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57674 + error = -EACCES;
57675 + goto exit_dput;
57676 + }
57677 +
57678 /*
57679 * create/update audit record if it already exists.
57680 */
57681 - if (path->dentry->d_inode)
57682 + if (path->dentry->d_inode) {
57683 + /* only check if O_CREAT is specified, all other checks need to go
57684 + into may_open */
57685 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57686 + error = -EACCES;
57687 + goto exit_dput;
57688 + }
57689 +
57690 audit_inode(name, path->dentry, 0);
57691 + }
57692
57693 /*
57694 * If atomic_open() acquired write access it is dropped now due to
57695 @@ -2809,6 +2887,11 @@ finish_lookup:
57696 }
57697 }
57698 BUG_ON(inode != path->dentry->d_inode);
57699 + /* if we're resolving a symlink to another symlink */
57700 + if (link && gr_handle_symlink_owner(link, inode)) {
57701 + error = -EACCES;
57702 + goto out;
57703 + }
57704 return 1;
57705 }
57706
57707 @@ -2818,7 +2901,6 @@ finish_lookup:
57708 save_parent.dentry = nd->path.dentry;
57709 save_parent.mnt = mntget(path->mnt);
57710 nd->path.dentry = path->dentry;
57711 -
57712 }
57713 nd->inode = inode;
57714 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57715 @@ -2828,7 +2910,18 @@ finish_open:
57716 path_put(&save_parent);
57717 return error;
57718 }
57719 +
57720 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57721 + error = -ENOENT;
57722 + goto out;
57723 + }
57724 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57725 + error = -EACCES;
57726 + goto out;
57727 + }
57728 +
57729 audit_inode(name, nd->path.dentry, 0);
57730 +
57731 error = -EISDIR;
57732 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57733 goto out;
57734 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57735 if (unlikely(error))
57736 goto out;
57737
57738 - error = do_last(nd, &path, file, op, &opened, pathname);
57739 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57740 while (unlikely(error > 0)) { /* trailing symlink */
57741 struct path link = path;
57742 void *cookie;
57743 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57744 error = follow_link(&link, nd, &cookie);
57745 if (unlikely(error))
57746 break;
57747 - error = do_last(nd, &path, file, op, &opened, pathname);
57748 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57749 put_link(nd, &link, cookie);
57750 }
57751 out:
57752 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57753 goto unlock;
57754
57755 error = -EEXIST;
57756 - if (dentry->d_inode)
57757 + if (dentry->d_inode) {
57758 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57759 + error = -ENOENT;
57760 + }
57761 goto fail;
57762 + }
57763 /*
57764 * Special case - lookup gave negative, but... we had foo/bar/
57765 * From the vfs_mknod() POV we just have a negative dentry -
57766 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57767 }
57768 EXPORT_SYMBOL(user_path_create);
57769
57770 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57771 +{
57772 + struct filename *tmp = getname(pathname);
57773 + struct dentry *res;
57774 + if (IS_ERR(tmp))
57775 + return ERR_CAST(tmp);
57776 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57777 + if (IS_ERR(res))
57778 + putname(tmp);
57779 + else
57780 + *to = tmp;
57781 + return res;
57782 +}
57783 +
57784 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57785 {
57786 int error = may_create(dir, dentry);
57787 @@ -3224,6 +3335,17 @@ retry:
57788
57789 if (!IS_POSIXACL(path.dentry->d_inode))
57790 mode &= ~current_umask();
57791 +
57792 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57793 + error = -EPERM;
57794 + goto out;
57795 + }
57796 +
57797 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57798 + error = -EACCES;
57799 + goto out;
57800 + }
57801 +
57802 error = security_path_mknod(&path, dentry, mode, dev);
57803 if (error)
57804 goto out;
57805 @@ -3240,6 +3362,8 @@ retry:
57806 break;
57807 }
57808 out:
57809 + if (!error)
57810 + gr_handle_create(dentry, path.mnt);
57811 done_path_create(&path, dentry);
57812 if (retry_estale(error, lookup_flags)) {
57813 lookup_flags |= LOOKUP_REVAL;
57814 @@ -3292,9 +3416,16 @@ retry:
57815
57816 if (!IS_POSIXACL(path.dentry->d_inode))
57817 mode &= ~current_umask();
57818 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57819 + error = -EACCES;
57820 + goto out;
57821 + }
57822 error = security_path_mkdir(&path, dentry, mode);
57823 if (!error)
57824 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57825 + if (!error)
57826 + gr_handle_create(dentry, path.mnt);
57827 +out:
57828 done_path_create(&path, dentry);
57829 if (retry_estale(error, lookup_flags)) {
57830 lookup_flags |= LOOKUP_REVAL;
57831 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57832 struct filename *name;
57833 struct dentry *dentry;
57834 struct nameidata nd;
57835 + ino_t saved_ino = 0;
57836 + dev_t saved_dev = 0;
57837 unsigned int lookup_flags = 0;
57838 retry:
57839 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57840 @@ -3407,10 +3540,21 @@ retry:
57841 error = -ENOENT;
57842 goto exit3;
57843 }
57844 +
57845 + saved_ino = dentry->d_inode->i_ino;
57846 + saved_dev = gr_get_dev_from_dentry(dentry);
57847 +
57848 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57849 + error = -EACCES;
57850 + goto exit3;
57851 + }
57852 +
57853 error = security_path_rmdir(&nd.path, dentry);
57854 if (error)
57855 goto exit3;
57856 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57857 + if (!error && (saved_dev || saved_ino))
57858 + gr_handle_delete(saved_ino, saved_dev);
57859 exit3:
57860 dput(dentry);
57861 exit2:
57862 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57863 struct dentry *dentry;
57864 struct nameidata nd;
57865 struct inode *inode = NULL;
57866 + ino_t saved_ino = 0;
57867 + dev_t saved_dev = 0;
57868 unsigned int lookup_flags = 0;
57869 retry:
57870 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57871 @@ -3502,10 +3648,22 @@ retry:
57872 if (!inode)
57873 goto slashes;
57874 ihold(inode);
57875 +
57876 + if (inode->i_nlink <= 1) {
57877 + saved_ino = inode->i_ino;
57878 + saved_dev = gr_get_dev_from_dentry(dentry);
57879 + }
57880 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57881 + error = -EACCES;
57882 + goto exit2;
57883 + }
57884 +
57885 error = security_path_unlink(&nd.path, dentry);
57886 if (error)
57887 goto exit2;
57888 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57889 + if (!error && (saved_ino || saved_dev))
57890 + gr_handle_delete(saved_ino, saved_dev);
57891 exit2:
57892 dput(dentry);
57893 }
57894 @@ -3583,9 +3741,17 @@ retry:
57895 if (IS_ERR(dentry))
57896 goto out_putname;
57897
57898 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57899 + error = -EACCES;
57900 + goto out;
57901 + }
57902 +
57903 error = security_path_symlink(&path, dentry, from->name);
57904 if (!error)
57905 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57906 + if (!error)
57907 + gr_handle_create(dentry, path.mnt);
57908 +out:
57909 done_path_create(&path, dentry);
57910 if (retry_estale(error, lookup_flags)) {
57911 lookup_flags |= LOOKUP_REVAL;
57912 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57913 {
57914 struct dentry *new_dentry;
57915 struct path old_path, new_path;
57916 + struct filename *to = NULL;
57917 int how = 0;
57918 int error;
57919
57920 @@ -3688,7 +3855,7 @@ retry:
57921 if (error)
57922 return error;
57923
57924 - new_dentry = user_path_create(newdfd, newname, &new_path,
57925 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57926 (how & LOOKUP_REVAL));
57927 error = PTR_ERR(new_dentry);
57928 if (IS_ERR(new_dentry))
57929 @@ -3700,11 +3867,28 @@ retry:
57930 error = may_linkat(&old_path);
57931 if (unlikely(error))
57932 goto out_dput;
57933 +
57934 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57935 + old_path.dentry->d_inode,
57936 + old_path.dentry->d_inode->i_mode, to)) {
57937 + error = -EACCES;
57938 + goto out_dput;
57939 + }
57940 +
57941 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
57942 + old_path.dentry, old_path.mnt, to)) {
57943 + error = -EACCES;
57944 + goto out_dput;
57945 + }
57946 +
57947 error = security_path_link(old_path.dentry, &new_path, new_dentry);
57948 if (error)
57949 goto out_dput;
57950 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
57951 + if (!error)
57952 + gr_handle_create(new_dentry, new_path.mnt);
57953 out_dput:
57954 + putname(to);
57955 done_path_create(&new_path, new_dentry);
57956 if (retry_estale(error, how)) {
57957 how |= LOOKUP_REVAL;
57958 @@ -3950,12 +4134,21 @@ retry:
57959 if (new_dentry == trap)
57960 goto exit5;
57961
57962 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
57963 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
57964 + to);
57965 + if (error)
57966 + goto exit5;
57967 +
57968 error = security_path_rename(&oldnd.path, old_dentry,
57969 &newnd.path, new_dentry);
57970 if (error)
57971 goto exit5;
57972 error = vfs_rename(old_dir->d_inode, old_dentry,
57973 new_dir->d_inode, new_dentry);
57974 + if (!error)
57975 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
57976 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
57977 exit5:
57978 dput(new_dentry);
57979 exit4:
57980 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
57981
57982 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
57983 {
57984 + char tmpbuf[64];
57985 + const char *newlink;
57986 int len;
57987
57988 len = PTR_ERR(link);
57989 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
57990 len = strlen(link);
57991 if (len > (unsigned) buflen)
57992 len = buflen;
57993 - if (copy_to_user(buffer, link, len))
57994 +
57995 + if (len < sizeof(tmpbuf)) {
57996 + memcpy(tmpbuf, link, len);
57997 + newlink = tmpbuf;
57998 + } else
57999 + newlink = link;
58000 +
58001 + if (copy_to_user(buffer, newlink, len))
58002 len = -EFAULT;
58003 out:
58004 return len;
58005 diff --git a/fs/namespace.c b/fs/namespace.c
58006 index a45ba4f..b4c7d07 100644
58007 --- a/fs/namespace.c
58008 +++ b/fs/namespace.c
58009 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
58010 if (!(sb->s_flags & MS_RDONLY))
58011 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
58012 up_write(&sb->s_umount);
58013 +
58014 + gr_log_remount(mnt->mnt_devname, retval);
58015 +
58016 return retval;
58017 }
58018
58019 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
58020 }
58021 br_write_unlock(&vfsmount_lock);
58022 namespace_unlock();
58023 +
58024 + gr_log_unmount(mnt->mnt_devname, retval);
58025 +
58026 return retval;
58027 }
58028
58029 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
58030 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
58031 */
58032
58033 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
58034 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58035 {
58036 struct path path;
58037 struct mount *mnt;
58038 @@ -1342,7 +1348,7 @@ out:
58039 /*
58040 * The 2.0 compatible umount. No flags.
58041 */
58042 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58043 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58044 {
58045 return sys_umount(name, 0);
58046 }
58047 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58048 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58049 MS_STRICTATIME);
58050
58051 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58052 + retval = -EPERM;
58053 + goto dput_out;
58054 + }
58055 +
58056 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58057 + retval = -EPERM;
58058 + goto dput_out;
58059 + }
58060 +
58061 if (flags & MS_REMOUNT)
58062 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58063 data_page);
58064 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58065 dev_name, data_page);
58066 dput_out:
58067 path_put(&path);
58068 +
58069 + gr_log_mount(dev_name, dir_name, retval);
58070 +
58071 return retval;
58072 }
58073
58074 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58075 * number incrementing at 10Ghz will take 12,427 years to wrap which
58076 * is effectively never, so we can ignore the possibility.
58077 */
58078 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58079 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58080
58081 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58082 {
58083 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58084 kfree(new_ns);
58085 return ERR_PTR(ret);
58086 }
58087 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58088 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58089 atomic_set(&new_ns->count, 1);
58090 new_ns->root = NULL;
58091 INIT_LIST_HEAD(&new_ns->list);
58092 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58093 * Allocate a new namespace structure and populate it with contents
58094 * copied from the namespace of the passed in task structure.
58095 */
58096 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58097 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58098 struct user_namespace *user_ns, struct fs_struct *fs)
58099 {
58100 struct mnt_namespace *new_ns;
58101 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58102 }
58103 EXPORT_SYMBOL(mount_subtree);
58104
58105 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58106 - char __user *, type, unsigned long, flags, void __user *, data)
58107 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58108 + const char __user *, type, unsigned long, flags, void __user *, data)
58109 {
58110 int ret;
58111 char *kernel_type;
58112 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58113 if (error)
58114 goto out2;
58115
58116 + if (gr_handle_chroot_pivot()) {
58117 + error = -EPERM;
58118 + goto out2;
58119 + }
58120 +
58121 get_fs_root(current->fs, &root);
58122 old_mp = lock_mount(&old);
58123 error = PTR_ERR(old_mp);
58124 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58125 !nsown_capable(CAP_SYS_ADMIN))
58126 return -EPERM;
58127
58128 - if (fs->users != 1)
58129 + if (atomic_read(&fs->users) != 1)
58130 return -EINVAL;
58131
58132 get_mnt_ns(mnt_ns);
58133 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58134 index f4ccfe6..a5cf064 100644
58135 --- a/fs/nfs/callback_xdr.c
58136 +++ b/fs/nfs/callback_xdr.c
58137 @@ -51,7 +51,7 @@ struct callback_op {
58138 callback_decode_arg_t decode_args;
58139 callback_encode_res_t encode_res;
58140 long res_maxsize;
58141 -};
58142 +} __do_const;
58143
58144 static struct callback_op callback_ops[];
58145
58146 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58147 index 941246f..17d8724 100644
58148 --- a/fs/nfs/inode.c
58149 +++ b/fs/nfs/inode.c
58150 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58151 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58152 }
58153
58154 -static atomic_long_t nfs_attr_generation_counter;
58155 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58156
58157 static unsigned long nfs_read_attr_generation_counter(void)
58158 {
58159 - return atomic_long_read(&nfs_attr_generation_counter);
58160 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58161 }
58162
58163 unsigned long nfs_inc_attr_generation_counter(void)
58164 {
58165 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58166 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58167 }
58168
58169 void nfs_fattr_init(struct nfs_fattr *fattr)
58170 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58171 index 419572f..5414a23 100644
58172 --- a/fs/nfsd/nfs4proc.c
58173 +++ b/fs/nfsd/nfs4proc.c
58174 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58175 nfsd4op_rsize op_rsize_bop;
58176 stateid_getter op_get_currentstateid;
58177 stateid_setter op_set_currentstateid;
58178 -};
58179 +} __do_const;
58180
58181 static struct nfsd4_operation nfsd4_ops[];
58182
58183 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58184 index c2a4701..fd80e29 100644
58185 --- a/fs/nfsd/nfs4xdr.c
58186 +++ b/fs/nfsd/nfs4xdr.c
58187 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58188
58189 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58190
58191 -static nfsd4_dec nfsd4_dec_ops[] = {
58192 +static const nfsd4_dec nfsd4_dec_ops[] = {
58193 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58194 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58195 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58196 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58197 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58198 };
58199
58200 -static nfsd4_dec nfsd41_dec_ops[] = {
58201 +static const nfsd4_dec nfsd41_dec_ops[] = {
58202 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58203 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58204 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58205 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58206 };
58207
58208 struct nfsd4_minorversion_ops {
58209 - nfsd4_dec *decoders;
58210 + const nfsd4_dec *decoders;
58211 int nops;
58212 };
58213
58214 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58215 index e76244e..9fe8f2f1 100644
58216 --- a/fs/nfsd/nfscache.c
58217 +++ b/fs/nfsd/nfscache.c
58218 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58219 {
58220 struct svc_cacherep *rp = rqstp->rq_cacherep;
58221 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58222 - int len;
58223 + long len;
58224 size_t bufsize = 0;
58225
58226 if (!rp)
58227 return;
58228
58229 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58230 - len >>= 2;
58231 + if (statp) {
58232 + len = (char*)statp - (char*)resv->iov_base;
58233 + len = resv->iov_len - len;
58234 + len >>= 2;
58235 + }
58236
58237 /* Don't cache excessive amounts of data and XDR failures */
58238 if (!statp || len > (256 >> 2)) {
58239 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58240 index c827acb..b253b77 100644
58241 --- a/fs/nfsd/vfs.c
58242 +++ b/fs/nfsd/vfs.c
58243 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58244 } else {
58245 oldfs = get_fs();
58246 set_fs(KERNEL_DS);
58247 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58248 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58249 set_fs(oldfs);
58250 }
58251
58252 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58253
58254 /* Write the data. */
58255 oldfs = get_fs(); set_fs(KERNEL_DS);
58256 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58257 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58258 set_fs(oldfs);
58259 if (host_err < 0)
58260 goto out_nfserr;
58261 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58262 */
58263
58264 oldfs = get_fs(); set_fs(KERNEL_DS);
58265 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58266 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58267 set_fs(oldfs);
58268
58269 if (host_err < 0)
58270 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58271 index fea6bd5..8ee9d81 100644
58272 --- a/fs/nls/nls_base.c
58273 +++ b/fs/nls/nls_base.c
58274 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58275
58276 int register_nls(struct nls_table * nls)
58277 {
58278 - struct nls_table ** tmp = &tables;
58279 + struct nls_table *tmp = tables;
58280
58281 if (nls->next)
58282 return -EBUSY;
58283
58284 spin_lock(&nls_lock);
58285 - while (*tmp) {
58286 - if (nls == *tmp) {
58287 + while (tmp) {
58288 + if (nls == tmp) {
58289 spin_unlock(&nls_lock);
58290 return -EBUSY;
58291 }
58292 - tmp = &(*tmp)->next;
58293 + tmp = tmp->next;
58294 }
58295 - nls->next = tables;
58296 + pax_open_kernel();
58297 + *(struct nls_table **)&nls->next = tables;
58298 + pax_close_kernel();
58299 tables = nls;
58300 spin_unlock(&nls_lock);
58301 return 0;
58302 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58303
58304 int unregister_nls(struct nls_table * nls)
58305 {
58306 - struct nls_table ** tmp = &tables;
58307 + struct nls_table * const * tmp = &tables;
58308
58309 spin_lock(&nls_lock);
58310 while (*tmp) {
58311 if (nls == *tmp) {
58312 - *tmp = nls->next;
58313 + pax_open_kernel();
58314 + *(struct nls_table **)tmp = nls->next;
58315 + pax_close_kernel();
58316 spin_unlock(&nls_lock);
58317 return 0;
58318 }
58319 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58320 index 7424929..35f6be5 100644
58321 --- a/fs/nls/nls_euc-jp.c
58322 +++ b/fs/nls/nls_euc-jp.c
58323 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58324 p_nls = load_nls("cp932");
58325
58326 if (p_nls) {
58327 - table.charset2upper = p_nls->charset2upper;
58328 - table.charset2lower = p_nls->charset2lower;
58329 + pax_open_kernel();
58330 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58331 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58332 + pax_close_kernel();
58333 return register_nls(&table);
58334 }
58335
58336 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58337 index e7bc1d7..06bd4bb 100644
58338 --- a/fs/nls/nls_koi8-ru.c
58339 +++ b/fs/nls/nls_koi8-ru.c
58340 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58341 p_nls = load_nls("koi8-u");
58342
58343 if (p_nls) {
58344 - table.charset2upper = p_nls->charset2upper;
58345 - table.charset2lower = p_nls->charset2lower;
58346 + pax_open_kernel();
58347 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58348 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58349 + pax_close_kernel();
58350 return register_nls(&table);
58351 }
58352
58353 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58354 index e44cb64..4807084 100644
58355 --- a/fs/notify/fanotify/fanotify_user.c
58356 +++ b/fs/notify/fanotify/fanotify_user.c
58357 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58358
58359 fd = fanotify_event_metadata.fd;
58360 ret = -EFAULT;
58361 - if (copy_to_user(buf, &fanotify_event_metadata,
58362 - fanotify_event_metadata.event_len))
58363 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58364 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58365 goto out_close_fd;
58366
58367 ret = prepare_for_access_response(group, event, fd);
58368 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58369 index 7b51b05..5ea5ef6 100644
58370 --- a/fs/notify/notification.c
58371 +++ b/fs/notify/notification.c
58372 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58373 * get set to 0 so it will never get 'freed'
58374 */
58375 static struct fsnotify_event *q_overflow_event;
58376 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58377 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58378
58379 /**
58380 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58381 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58382 */
58383 u32 fsnotify_get_cookie(void)
58384 {
58385 - return atomic_inc_return(&fsnotify_sync_cookie);
58386 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58387 }
58388 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58389
58390 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58391 index 9e38daf..5727cae 100644
58392 --- a/fs/ntfs/dir.c
58393 +++ b/fs/ntfs/dir.c
58394 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58395 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58396 ~(s64)(ndir->itype.index.block_size - 1)));
58397 /* Bounds checks. */
58398 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58399 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58400 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58401 "inode 0x%lx or driver bug.", vdir->i_ino);
58402 goto err_out;
58403 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58404 index c5670b8..d590213 100644
58405 --- a/fs/ntfs/file.c
58406 +++ b/fs/ntfs/file.c
58407 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58408 char *addr;
58409 size_t total = 0;
58410 unsigned len;
58411 - int left;
58412 + unsigned left;
58413
58414 do {
58415 len = PAGE_CACHE_SIZE - ofs;
58416 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58417 index 82650d5..db37dcf 100644
58418 --- a/fs/ntfs/super.c
58419 +++ b/fs/ntfs/super.c
58420 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58421 if (!silent)
58422 ntfs_error(sb, "Primary boot sector is invalid.");
58423 } else if (!silent)
58424 - ntfs_error(sb, read_err_str, "primary");
58425 + ntfs_error(sb, read_err_str, "%s", "primary");
58426 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58427 if (bh_primary)
58428 brelse(bh_primary);
58429 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58430 goto hotfix_primary_boot_sector;
58431 brelse(bh_backup);
58432 } else if (!silent)
58433 - ntfs_error(sb, read_err_str, "backup");
58434 + ntfs_error(sb, read_err_str, "%s", "backup");
58435 /* Try to read NT3.51- backup boot sector. */
58436 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58437 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58438 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58439 "sector.");
58440 brelse(bh_backup);
58441 } else if (!silent)
58442 - ntfs_error(sb, read_err_str, "backup");
58443 + ntfs_error(sb, read_err_str, "%s", "backup");
58444 /* We failed. Cleanup and return. */
58445 if (bh_primary)
58446 brelse(bh_primary);
58447 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58448 index aebeacd..0dcdd26 100644
58449 --- a/fs/ocfs2/localalloc.c
58450 +++ b/fs/ocfs2/localalloc.c
58451 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58452 goto bail;
58453 }
58454
58455 - atomic_inc(&osb->alloc_stats.moves);
58456 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58457
58458 bail:
58459 if (handle)
58460 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58461 index 3a90347..c40bef8 100644
58462 --- a/fs/ocfs2/ocfs2.h
58463 +++ b/fs/ocfs2/ocfs2.h
58464 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58465
58466 struct ocfs2_alloc_stats
58467 {
58468 - atomic_t moves;
58469 - atomic_t local_data;
58470 - atomic_t bitmap_data;
58471 - atomic_t bg_allocs;
58472 - atomic_t bg_extends;
58473 + atomic_unchecked_t moves;
58474 + atomic_unchecked_t local_data;
58475 + atomic_unchecked_t bitmap_data;
58476 + atomic_unchecked_t bg_allocs;
58477 + atomic_unchecked_t bg_extends;
58478 };
58479
58480 enum ocfs2_local_alloc_state
58481 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58482 index 5397c07..54afc55 100644
58483 --- a/fs/ocfs2/suballoc.c
58484 +++ b/fs/ocfs2/suballoc.c
58485 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58486 mlog_errno(status);
58487 goto bail;
58488 }
58489 - atomic_inc(&osb->alloc_stats.bg_extends);
58490 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58491
58492 /* You should never ask for this much metadata */
58493 BUG_ON(bits_wanted >
58494 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58495 mlog_errno(status);
58496 goto bail;
58497 }
58498 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58499 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58500
58501 *suballoc_loc = res.sr_bg_blkno;
58502 *suballoc_bit_start = res.sr_bit_offset;
58503 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58504 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58505 res->sr_bits);
58506
58507 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58508 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58509
58510 BUG_ON(res->sr_bits != 1);
58511
58512 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58513 mlog_errno(status);
58514 goto bail;
58515 }
58516 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58517 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58518
58519 BUG_ON(res.sr_bits != 1);
58520
58521 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58522 cluster_start,
58523 num_clusters);
58524 if (!status)
58525 - atomic_inc(&osb->alloc_stats.local_data);
58526 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58527 } else {
58528 if (min_clusters > (osb->bitmap_cpg - 1)) {
58529 /* The only paths asking for contiguousness
58530 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58531 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58532 res.sr_bg_blkno,
58533 res.sr_bit_offset);
58534 - atomic_inc(&osb->alloc_stats.bitmap_data);
58535 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58536 *num_clusters = res.sr_bits;
58537 }
58538 }
58539 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58540 index 121da2d..a0232bc 100644
58541 --- a/fs/ocfs2/super.c
58542 +++ b/fs/ocfs2/super.c
58543 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58544 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58545 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58546 "Stats",
58547 - atomic_read(&osb->alloc_stats.bitmap_data),
58548 - atomic_read(&osb->alloc_stats.local_data),
58549 - atomic_read(&osb->alloc_stats.bg_allocs),
58550 - atomic_read(&osb->alloc_stats.moves),
58551 - atomic_read(&osb->alloc_stats.bg_extends));
58552 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58553 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58554 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58555 + atomic_read_unchecked(&osb->alloc_stats.moves),
58556 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58557
58558 out += snprintf(buf + out, len - out,
58559 "%10s => State: %u Descriptor: %llu Size: %u bits "
58560 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58561 spin_lock_init(&osb->osb_xattr_lock);
58562 ocfs2_init_steal_slots(osb);
58563
58564 - atomic_set(&osb->alloc_stats.moves, 0);
58565 - atomic_set(&osb->alloc_stats.local_data, 0);
58566 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58567 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58568 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58569 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58570 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58571 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58572 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58573 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58574
58575 /* Copy the blockcheck stats from the superblock probe */
58576 osb->osb_ecc_stats = *stats;
58577 diff --git a/fs/open.c b/fs/open.c
58578 index 7931f76..7b03f3b 100644
58579 --- a/fs/open.c
58580 +++ b/fs/open.c
58581 @@ -32,6 +32,8 @@
58582 #include <linux/dnotify.h>
58583 #include <linux/compat.h>
58584
58585 +#define CREATE_TRACE_POINTS
58586 +#include <trace/events/fs.h>
58587 #include "internal.h"
58588
58589 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58590 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58591 error = locks_verify_truncate(inode, NULL, length);
58592 if (!error)
58593 error = security_path_truncate(path);
58594 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58595 + error = -EACCES;
58596 if (!error)
58597 error = do_truncate(path->dentry, length, 0, NULL);
58598
58599 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58600 error = locks_verify_truncate(inode, f.file, length);
58601 if (!error)
58602 error = security_path_truncate(&f.file->f_path);
58603 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58604 + error = -EACCES;
58605 if (!error)
58606 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58607 sb_end_write(inode->i_sb);
58608 @@ -360,6 +366,9 @@ retry:
58609 if (__mnt_is_readonly(path.mnt))
58610 res = -EROFS;
58611
58612 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58613 + res = -EACCES;
58614 +
58615 out_path_release:
58616 path_put(&path);
58617 if (retry_estale(res, lookup_flags)) {
58618 @@ -391,6 +400,8 @@ retry:
58619 if (error)
58620 goto dput_and_out;
58621
58622 + gr_log_chdir(path.dentry, path.mnt);
58623 +
58624 set_fs_pwd(current->fs, &path);
58625
58626 dput_and_out:
58627 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58628 goto out_putf;
58629
58630 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58631 +
58632 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58633 + error = -EPERM;
58634 +
58635 + if (!error)
58636 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58637 +
58638 if (!error)
58639 set_fs_pwd(current->fs, &f.file->f_path);
58640 out_putf:
58641 @@ -449,7 +467,13 @@ retry:
58642 if (error)
58643 goto dput_and_out;
58644
58645 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58646 + goto dput_and_out;
58647 +
58648 set_fs_root(current->fs, &path);
58649 +
58650 + gr_handle_chroot_chdir(&path);
58651 +
58652 error = 0;
58653 dput_and_out:
58654 path_put(&path);
58655 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58656 if (error)
58657 return error;
58658 mutex_lock(&inode->i_mutex);
58659 +
58660 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58661 + error = -EACCES;
58662 + goto out_unlock;
58663 + }
58664 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58665 + error = -EACCES;
58666 + goto out_unlock;
58667 + }
58668 +
58669 error = security_path_chmod(path, mode);
58670 if (error)
58671 goto out_unlock;
58672 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58673 uid = make_kuid(current_user_ns(), user);
58674 gid = make_kgid(current_user_ns(), group);
58675
58676 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58677 + return -EACCES;
58678 +
58679 newattrs.ia_valid = ATTR_CTIME;
58680 if (user != (uid_t) -1) {
58681 if (!uid_valid(uid))
58682 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58683 } else {
58684 fsnotify_open(f);
58685 fd_install(fd, f);
58686 + trace_do_sys_open(tmp->name, flags, mode);
58687 }
58688 }
58689 putname(tmp);
58690 diff --git a/fs/pipe.c b/fs/pipe.c
58691 index d2c45e1..009fe1c 100644
58692 --- a/fs/pipe.c
58693 +++ b/fs/pipe.c
58694 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58695
58696 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58697 {
58698 - if (pipe->files)
58699 + if (atomic_read(&pipe->files))
58700 mutex_lock_nested(&pipe->mutex, subclass);
58701 }
58702
58703 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58704
58705 void pipe_unlock(struct pipe_inode_info *pipe)
58706 {
58707 - if (pipe->files)
58708 + if (atomic_read(&pipe->files))
58709 mutex_unlock(&pipe->mutex);
58710 }
58711 EXPORT_SYMBOL(pipe_unlock);
58712 @@ -449,9 +449,9 @@ redo:
58713 }
58714 if (bufs) /* More to do? */
58715 continue;
58716 - if (!pipe->writers)
58717 + if (!atomic_read(&pipe->writers))
58718 break;
58719 - if (!pipe->waiting_writers) {
58720 + if (!atomic_read(&pipe->waiting_writers)) {
58721 /* syscall merging: Usually we must not sleep
58722 * if O_NONBLOCK is set, or if we got some data.
58723 * But if a writer sleeps in kernel space, then
58724 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58725 ret = 0;
58726 __pipe_lock(pipe);
58727
58728 - if (!pipe->readers) {
58729 + if (!atomic_read(&pipe->readers)) {
58730 send_sig(SIGPIPE, current, 0);
58731 ret = -EPIPE;
58732 goto out;
58733 @@ -562,7 +562,7 @@ redo1:
58734 for (;;) {
58735 int bufs;
58736
58737 - if (!pipe->readers) {
58738 + if (!atomic_read(&pipe->readers)) {
58739 send_sig(SIGPIPE, current, 0);
58740 if (!ret)
58741 ret = -EPIPE;
58742 @@ -653,9 +653,9 @@ redo2:
58743 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58744 do_wakeup = 0;
58745 }
58746 - pipe->waiting_writers++;
58747 + atomic_inc(&pipe->waiting_writers);
58748 pipe_wait(pipe);
58749 - pipe->waiting_writers--;
58750 + atomic_dec(&pipe->waiting_writers);
58751 }
58752 out:
58753 __pipe_unlock(pipe);
58754 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58755 mask = 0;
58756 if (filp->f_mode & FMODE_READ) {
58757 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58758 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58759 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58760 mask |= POLLHUP;
58761 }
58762
58763 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58764 * Most Unices do not set POLLERR for FIFOs but on Linux they
58765 * behave exactly like pipes for poll().
58766 */
58767 - if (!pipe->readers)
58768 + if (!atomic_read(&pipe->readers))
58769 mask |= POLLERR;
58770 }
58771
58772 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58773
58774 __pipe_lock(pipe);
58775 if (file->f_mode & FMODE_READ)
58776 - pipe->readers--;
58777 + atomic_dec(&pipe->readers);
58778 if (file->f_mode & FMODE_WRITE)
58779 - pipe->writers--;
58780 + atomic_dec(&pipe->writers);
58781
58782 - if (pipe->readers || pipe->writers) {
58783 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58784 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58785 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58786 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58787 }
58788 spin_lock(&inode->i_lock);
58789 - if (!--pipe->files) {
58790 + if (atomic_dec_and_test(&pipe->files)) {
58791 inode->i_pipe = NULL;
58792 kill = 1;
58793 }
58794 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58795 kfree(pipe);
58796 }
58797
58798 -static struct vfsmount *pipe_mnt __read_mostly;
58799 +struct vfsmount *pipe_mnt __read_mostly;
58800
58801 /*
58802 * pipefs_dname() is called from d_path().
58803 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58804 goto fail_iput;
58805
58806 inode->i_pipe = pipe;
58807 - pipe->files = 2;
58808 - pipe->readers = pipe->writers = 1;
58809 + atomic_set(&pipe->files, 2);
58810 + atomic_set(&pipe->readers, 1);
58811 + atomic_set(&pipe->writers, 1);
58812 inode->i_fop = &pipefifo_fops;
58813
58814 /*
58815 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58816 spin_lock(&inode->i_lock);
58817 if (inode->i_pipe) {
58818 pipe = inode->i_pipe;
58819 - pipe->files++;
58820 + atomic_inc(&pipe->files);
58821 spin_unlock(&inode->i_lock);
58822 } else {
58823 spin_unlock(&inode->i_lock);
58824 pipe = alloc_pipe_info();
58825 if (!pipe)
58826 return -ENOMEM;
58827 - pipe->files = 1;
58828 + atomic_set(&pipe->files, 1);
58829 spin_lock(&inode->i_lock);
58830 if (unlikely(inode->i_pipe)) {
58831 - inode->i_pipe->files++;
58832 + atomic_inc(&inode->i_pipe->files);
58833 spin_unlock(&inode->i_lock);
58834 free_pipe_info(pipe);
58835 pipe = inode->i_pipe;
58836 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58837 * opened, even when there is no process writing the FIFO.
58838 */
58839 pipe->r_counter++;
58840 - if (pipe->readers++ == 0)
58841 + if (atomic_inc_return(&pipe->readers) == 1)
58842 wake_up_partner(pipe);
58843
58844 - if (!is_pipe && !pipe->writers) {
58845 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58846 if ((filp->f_flags & O_NONBLOCK)) {
58847 /* suppress POLLHUP until we have
58848 * seen a writer */
58849 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58850 * errno=ENXIO when there is no process reading the FIFO.
58851 */
58852 ret = -ENXIO;
58853 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58854 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58855 goto err;
58856
58857 pipe->w_counter++;
58858 - if (!pipe->writers++)
58859 + if (atomic_inc_return(&pipe->writers) == 1)
58860 wake_up_partner(pipe);
58861
58862 - if (!is_pipe && !pipe->readers) {
58863 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58864 if (wait_for_partner(pipe, &pipe->r_counter))
58865 goto err_wr;
58866 }
58867 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58868 * the process can at least talk to itself.
58869 */
58870
58871 - pipe->readers++;
58872 - pipe->writers++;
58873 + atomic_inc(&pipe->readers);
58874 + atomic_inc(&pipe->writers);
58875 pipe->r_counter++;
58876 pipe->w_counter++;
58877 - if (pipe->readers == 1 || pipe->writers == 1)
58878 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58879 wake_up_partner(pipe);
58880 break;
58881
58882 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58883 return 0;
58884
58885 err_rd:
58886 - if (!--pipe->readers)
58887 + if (atomic_dec_and_test(&pipe->readers))
58888 wake_up_interruptible(&pipe->wait);
58889 ret = -ERESTARTSYS;
58890 goto err;
58891
58892 err_wr:
58893 - if (!--pipe->writers)
58894 + if (atomic_dec_and_test(&pipe->writers))
58895 wake_up_interruptible(&pipe->wait);
58896 ret = -ERESTARTSYS;
58897 goto err;
58898
58899 err:
58900 spin_lock(&inode->i_lock);
58901 - if (!--pipe->files) {
58902 + if (atomic_dec_and_test(&pipe->files)) {
58903 inode->i_pipe = NULL;
58904 kill = 1;
58905 }
58906 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58907 index 15af622..0e9f4467 100644
58908 --- a/fs/proc/Kconfig
58909 +++ b/fs/proc/Kconfig
58910 @@ -30,12 +30,12 @@ config PROC_FS
58911
58912 config PROC_KCORE
58913 bool "/proc/kcore support" if !ARM
58914 - depends on PROC_FS && MMU
58915 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58916
58917 config PROC_VMCORE
58918 bool "/proc/vmcore support"
58919 - depends on PROC_FS && CRASH_DUMP
58920 - default y
58921 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58922 + default n
58923 help
58924 Exports the dump image of crashed kernel in ELF format.
58925
58926 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58927 limited in memory.
58928
58929 config PROC_PAGE_MONITOR
58930 - default y
58931 - depends on PROC_FS && MMU
58932 + default n
58933 + depends on PROC_FS && MMU && !GRKERNSEC
58934 bool "Enable /proc page monitoring" if EXPERT
58935 help
58936 Various /proc files exist to monitor process memory utilization:
58937 diff --git a/fs/proc/array.c b/fs/proc/array.c
58938 index cbd0f1b..adec3f0 100644
58939 --- a/fs/proc/array.c
58940 +++ b/fs/proc/array.c
58941 @@ -60,6 +60,7 @@
58942 #include <linux/tty.h>
58943 #include <linux/string.h>
58944 #include <linux/mman.h>
58945 +#include <linux/grsecurity.h>
58946 #include <linux/proc_fs.h>
58947 #include <linux/ioport.h>
58948 #include <linux/uaccess.h>
58949 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
58950 seq_putc(m, '\n');
58951 }
58952
58953 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58954 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
58955 +{
58956 + if (p->mm)
58957 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
58958 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
58959 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
58960 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
58961 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
58962 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
58963 + else
58964 + seq_printf(m, "PaX:\t-----\n");
58965 +}
58966 +#endif
58967 +
58968 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58969 struct pid *pid, struct task_struct *task)
58970 {
58971 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58972 task_cpus_allowed(m, task);
58973 cpuset_task_status_allowed(m, task);
58974 task_context_switch_counts(m, task);
58975 +
58976 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58977 + task_pax(m, task);
58978 +#endif
58979 +
58980 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
58981 + task_grsec_rbac(m, task);
58982 +#endif
58983 +
58984 return 0;
58985 }
58986
58987 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58988 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58989 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58990 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58991 +#endif
58992 +
58993 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58994 struct pid *pid, struct task_struct *task, int whole)
58995 {
58996 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58997 char tcomm[sizeof(task->comm)];
58998 unsigned long flags;
58999
59000 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59001 + if (current->exec_id != m->exec_id) {
59002 + gr_log_badprocpid("stat");
59003 + return 0;
59004 + }
59005 +#endif
59006 +
59007 state = *get_task_state(task);
59008 vsize = eip = esp = 0;
59009 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59010 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59011 gtime = task_gtime(task);
59012 }
59013
59014 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59015 + if (PAX_RAND_FLAGS(mm)) {
59016 + eip = 0;
59017 + esp = 0;
59018 + wchan = 0;
59019 + }
59020 +#endif
59021 +#ifdef CONFIG_GRKERNSEC_HIDESYM
59022 + wchan = 0;
59023 + eip =0;
59024 + esp =0;
59025 +#endif
59026 +
59027 /* scale priority and nice values from timeslices to -20..20 */
59028 /* to make it look like a "normal" Unix priority/nice value */
59029 priority = task_prio(task);
59030 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59031 seq_put_decimal_ull(m, ' ', vsize);
59032 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59033 seq_put_decimal_ull(m, ' ', rsslim);
59034 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59035 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59036 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59037 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59038 +#else
59039 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59040 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59041 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59042 +#endif
59043 seq_put_decimal_ull(m, ' ', esp);
59044 seq_put_decimal_ull(m, ' ', eip);
59045 /* The signal information here is obsolete.
59046 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59047 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59048 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59049
59050 - if (mm && permitted) {
59051 + if (mm && permitted
59052 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59053 + && !PAX_RAND_FLAGS(mm)
59054 +#endif
59055 + ) {
59056 seq_put_decimal_ull(m, ' ', mm->start_data);
59057 seq_put_decimal_ull(m, ' ', mm->end_data);
59058 seq_put_decimal_ull(m, ' ', mm->start_brk);
59059 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59060 struct pid *pid, struct task_struct *task)
59061 {
59062 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59063 - struct mm_struct *mm = get_task_mm(task);
59064 + struct mm_struct *mm;
59065
59066 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59067 + if (current->exec_id != m->exec_id) {
59068 + gr_log_badprocpid("statm");
59069 + return 0;
59070 + }
59071 +#endif
59072 + mm = get_task_mm(task);
59073 if (mm) {
59074 size = task_statm(mm, &shared, &text, &data, &resident);
59075 mmput(mm);
59076 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59077 return 0;
59078 }
59079
59080 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59081 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59082 +{
59083 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59084 +}
59085 +#endif
59086 +
59087 #ifdef CONFIG_CHECKPOINT_RESTORE
59088 static struct pid *
59089 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59090 diff --git a/fs/proc/base.c b/fs/proc/base.c
59091 index 1485e38..8ad4236 100644
59092 --- a/fs/proc/base.c
59093 +++ b/fs/proc/base.c
59094 @@ -113,6 +113,14 @@ struct pid_entry {
59095 union proc_op op;
59096 };
59097
59098 +struct getdents_callback {
59099 + struct linux_dirent __user * current_dir;
59100 + struct linux_dirent __user * previous;
59101 + struct file * file;
59102 + int count;
59103 + int error;
59104 +};
59105 +
59106 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59107 .name = (NAME), \
59108 .len = sizeof(NAME) - 1, \
59109 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59110 if (!mm->arg_end)
59111 goto out_mm; /* Shh! No looking before we're done */
59112
59113 + if (gr_acl_handle_procpidmem(task))
59114 + goto out_mm;
59115 +
59116 len = mm->arg_end - mm->arg_start;
59117
59118 if (len > PAGE_SIZE)
59119 @@ -237,12 +248,28 @@ out:
59120 return res;
59121 }
59122
59123 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59124 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59125 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59126 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59127 +#endif
59128 +
59129 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59130 {
59131 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59132 int res = PTR_ERR(mm);
59133 if (mm && !IS_ERR(mm)) {
59134 unsigned int nwords = 0;
59135 +
59136 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59137 + /* allow if we're currently ptracing this task */
59138 + if (PAX_RAND_FLAGS(mm) &&
59139 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59140 + mmput(mm);
59141 + return 0;
59142 + }
59143 +#endif
59144 +
59145 do {
59146 nwords += 2;
59147 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59148 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59149 }
59150
59151
59152 -#ifdef CONFIG_KALLSYMS
59153 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59154 /*
59155 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59156 * Returns the resolved symbol. If that fails, simply return the address.
59157 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59158 mutex_unlock(&task->signal->cred_guard_mutex);
59159 }
59160
59161 -#ifdef CONFIG_STACKTRACE
59162 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59163
59164 #define MAX_STACK_TRACE_DEPTH 64
59165
59166 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59167 return count;
59168 }
59169
59170 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59171 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59172 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59173 {
59174 long nr;
59175 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59176 /************************************************************************/
59177
59178 /* permission checks */
59179 -static int proc_fd_access_allowed(struct inode *inode)
59180 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59181 {
59182 struct task_struct *task;
59183 int allowed = 0;
59184 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59185 */
59186 task = get_proc_task(inode);
59187 if (task) {
59188 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59189 + if (log)
59190 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59191 + else
59192 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59193 put_task_struct(task);
59194 }
59195 return allowed;
59196 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59197 struct task_struct *task,
59198 int hide_pid_min)
59199 {
59200 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59201 + return false;
59202 +
59203 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59204 + rcu_read_lock();
59205 + {
59206 + const struct cred *tmpcred = current_cred();
59207 + const struct cred *cred = __task_cred(task);
59208 +
59209 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59210 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59211 + || in_group_p(grsec_proc_gid)
59212 +#endif
59213 + ) {
59214 + rcu_read_unlock();
59215 + return true;
59216 + }
59217 + }
59218 + rcu_read_unlock();
59219 +
59220 + if (!pid->hide_pid)
59221 + return false;
59222 +#endif
59223 +
59224 if (pid->hide_pid < hide_pid_min)
59225 return true;
59226 if (in_group_p(pid->pid_gid))
59227 return true;
59228 +
59229 return ptrace_may_access(task, PTRACE_MODE_READ);
59230 }
59231
59232 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59233 put_task_struct(task);
59234
59235 if (!has_perms) {
59236 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59237 + {
59238 +#else
59239 if (pid->hide_pid == 2) {
59240 +#endif
59241 /*
59242 * Let's make getdents(), stat(), and open()
59243 * consistent with each other. If a process
59244 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59245 if (!task)
59246 return -ESRCH;
59247
59248 + if (gr_acl_handle_procpidmem(task)) {
59249 + put_task_struct(task);
59250 + return -EPERM;
59251 + }
59252 +
59253 mm = mm_access(task, mode);
59254 put_task_struct(task);
59255
59256 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59257
59258 file->private_data = mm;
59259
59260 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59261 + file->f_version = current->exec_id;
59262 +#endif
59263 +
59264 return 0;
59265 }
59266
59267 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59268 ssize_t copied;
59269 char *page;
59270
59271 +#ifdef CONFIG_GRKERNSEC
59272 + if (write)
59273 + return -EPERM;
59274 +#endif
59275 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59276 + if (file->f_version != current->exec_id) {
59277 + gr_log_badprocpid("mem");
59278 + return 0;
59279 + }
59280 +#endif
59281 +
59282 if (!mm)
59283 return 0;
59284
59285 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59286 goto free;
59287
59288 while (count > 0) {
59289 - int this_len = min_t(int, count, PAGE_SIZE);
59290 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59291
59292 if (write && copy_from_user(page, buf, this_len)) {
59293 copied = -EFAULT;
59294 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59295 if (!mm)
59296 return 0;
59297
59298 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59299 + if (file->f_version != current->exec_id) {
59300 + gr_log_badprocpid("environ");
59301 + return 0;
59302 + }
59303 +#endif
59304 +
59305 page = (char *)__get_free_page(GFP_TEMPORARY);
59306 if (!page)
59307 return -ENOMEM;
59308 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59309 goto free;
59310 while (count > 0) {
59311 size_t this_len, max_len;
59312 - int retval;
59313 + ssize_t retval;
59314
59315 if (src >= (mm->env_end - mm->env_start))
59316 break;
59317 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59318 int error = -EACCES;
59319
59320 /* Are we allowed to snoop on the tasks file descriptors? */
59321 - if (!proc_fd_access_allowed(inode))
59322 + if (!proc_fd_access_allowed(inode, 0))
59323 goto out;
59324
59325 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59326 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59327 struct path path;
59328
59329 /* Are we allowed to snoop on the tasks file descriptors? */
59330 - if (!proc_fd_access_allowed(inode))
59331 - goto out;
59332 + /* logging this is needed for learning on chromium to work properly,
59333 + but we don't want to flood the logs from 'ps' which does a readlink
59334 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59335 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59336 + */
59337 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59338 + if (!proc_fd_access_allowed(inode,0))
59339 + goto out;
59340 + } else {
59341 + if (!proc_fd_access_allowed(inode,1))
59342 + goto out;
59343 + }
59344
59345 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59346 if (error)
59347 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59348 rcu_read_lock();
59349 cred = __task_cred(task);
59350 inode->i_uid = cred->euid;
59351 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59352 + inode->i_gid = grsec_proc_gid;
59353 +#else
59354 inode->i_gid = cred->egid;
59355 +#endif
59356 rcu_read_unlock();
59357 }
59358 security_task_to_inode(task, inode);
59359 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59360 return -ENOENT;
59361 }
59362 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59363 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59364 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59365 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59366 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59367 +#endif
59368 task_dumpable(task)) {
59369 cred = __task_cred(task);
59370 stat->uid = cred->euid;
59371 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59372 + stat->gid = grsec_proc_gid;
59373 +#else
59374 stat->gid = cred->egid;
59375 +#endif
59376 }
59377 }
59378 rcu_read_unlock();
59379 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59380
59381 if (task) {
59382 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59383 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59384 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59385 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59386 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59387 +#endif
59388 task_dumpable(task)) {
59389 rcu_read_lock();
59390 cred = __task_cred(task);
59391 inode->i_uid = cred->euid;
59392 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59393 + inode->i_gid = grsec_proc_gid;
59394 +#else
59395 inode->i_gid = cred->egid;
59396 +#endif
59397 rcu_read_unlock();
59398 } else {
59399 inode->i_uid = GLOBAL_ROOT_UID;
59400 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59401 if (!task)
59402 goto out_no_task;
59403
59404 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59405 + goto out;
59406 +
59407 /*
59408 * Yes, it does not scale. And it should not. Don't add
59409 * new entries into /proc/<tgid>/ without very good reasons.
59410 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59411 if (!task)
59412 return -ENOENT;
59413
59414 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59415 + goto out;
59416 +
59417 if (!dir_emit_dots(file, ctx))
59418 goto out;
59419
59420 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59421 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59422 #endif
59423 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59424 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59425 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59426 INF("syscall", S_IRUGO, proc_pid_syscall),
59427 #endif
59428 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59429 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59430 #ifdef CONFIG_SECURITY
59431 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59432 #endif
59433 -#ifdef CONFIG_KALLSYMS
59434 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59435 INF("wchan", S_IRUGO, proc_pid_wchan),
59436 #endif
59437 -#ifdef CONFIG_STACKTRACE
59438 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59439 ONE("stack", S_IRUGO, proc_pid_stack),
59440 #endif
59441 #ifdef CONFIG_SCHEDSTATS
59442 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59443 #ifdef CONFIG_HARDWALL
59444 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59445 #endif
59446 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59447 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59448 +#endif
59449 #ifdef CONFIG_USER_NS
59450 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59451 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59452 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59453 if (!inode)
59454 goto out;
59455
59456 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59457 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59458 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59459 + inode->i_gid = grsec_proc_gid;
59460 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59461 +#else
59462 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59463 +#endif
59464 inode->i_op = &proc_tgid_base_inode_operations;
59465 inode->i_fop = &proc_tgid_base_operations;
59466 inode->i_flags|=S_IMMUTABLE;
59467 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59468 if (!task)
59469 goto out;
59470
59471 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59472 + goto out_put_task;
59473 +
59474 result = proc_pid_instantiate(dir, dentry, task, NULL);
59475 +out_put_task:
59476 put_task_struct(task);
59477 out:
59478 return ERR_PTR(result);
59479 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59480 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59481 #endif
59482 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59483 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59484 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59485 INF("syscall", S_IRUGO, proc_pid_syscall),
59486 #endif
59487 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59488 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59489 #ifdef CONFIG_SECURITY
59490 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59491 #endif
59492 -#ifdef CONFIG_KALLSYMS
59493 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59494 INF("wchan", S_IRUGO, proc_pid_wchan),
59495 #endif
59496 -#ifdef CONFIG_STACKTRACE
59497 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59498 ONE("stack", S_IRUGO, proc_pid_stack),
59499 #endif
59500 #ifdef CONFIG_SCHEDSTATS
59501 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59502 index 82676e3..5f8518a 100644
59503 --- a/fs/proc/cmdline.c
59504 +++ b/fs/proc/cmdline.c
59505 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59506
59507 static int __init proc_cmdline_init(void)
59508 {
59509 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59510 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59511 +#else
59512 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59513 +#endif
59514 return 0;
59515 }
59516 module_init(proc_cmdline_init);
59517 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59518 index b143471..bb105e5 100644
59519 --- a/fs/proc/devices.c
59520 +++ b/fs/proc/devices.c
59521 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59522
59523 static int __init proc_devices_init(void)
59524 {
59525 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59526 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59527 +#else
59528 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59529 +#endif
59530 return 0;
59531 }
59532 module_init(proc_devices_init);
59533 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59534 index 0ff80f9..a1d7500 100644
59535 --- a/fs/proc/fd.c
59536 +++ b/fs/proc/fd.c
59537 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59538 if (!task)
59539 return -ENOENT;
59540
59541 - files = get_files_struct(task);
59542 + if (!gr_acl_handle_procpidmem(task))
59543 + files = get_files_struct(task);
59544 put_task_struct(task);
59545
59546 if (files) {
59547 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59548 */
59549 int proc_fd_permission(struct inode *inode, int mask)
59550 {
59551 + struct task_struct *task;
59552 int rv = generic_permission(inode, mask);
59553 - if (rv == 0)
59554 - return 0;
59555 +
59556 if (task_pid(current) == proc_pid(inode))
59557 rv = 0;
59558 +
59559 + task = get_proc_task(inode);
59560 + if (task == NULL)
59561 + return rv;
59562 +
59563 + if (gr_acl_handle_procpidmem(task))
59564 + rv = -EACCES;
59565 +
59566 + put_task_struct(task);
59567 +
59568 return rv;
59569 }
59570
59571 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59572 index 073aea6..0630370 100644
59573 --- a/fs/proc/inode.c
59574 +++ b/fs/proc/inode.c
59575 @@ -23,11 +23,17 @@
59576 #include <linux/slab.h>
59577 #include <linux/mount.h>
59578 #include <linux/magic.h>
59579 +#include <linux/grsecurity.h>
59580
59581 #include <asm/uaccess.h>
59582
59583 #include "internal.h"
59584
59585 +#ifdef CONFIG_PROC_SYSCTL
59586 +extern const struct inode_operations proc_sys_inode_operations;
59587 +extern const struct inode_operations proc_sys_dir_operations;
59588 +#endif
59589 +
59590 static void proc_evict_inode(struct inode *inode)
59591 {
59592 struct proc_dir_entry *de;
59593 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59594 ns = PROC_I(inode)->ns.ns;
59595 if (ns_ops && ns)
59596 ns_ops->put(ns);
59597 +
59598 +#ifdef CONFIG_PROC_SYSCTL
59599 + if (inode->i_op == &proc_sys_inode_operations ||
59600 + inode->i_op == &proc_sys_dir_operations)
59601 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59602 +#endif
59603 +
59604 }
59605
59606 static struct kmem_cache * proc_inode_cachep;
59607 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59608 if (de->mode) {
59609 inode->i_mode = de->mode;
59610 inode->i_uid = de->uid;
59611 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59612 + inode->i_gid = grsec_proc_gid;
59613 +#else
59614 inode->i_gid = de->gid;
59615 +#endif
59616 }
59617 if (de->size)
59618 inode->i_size = de->size;
59619 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59620 index 651d09a..60c73ae 100644
59621 --- a/fs/proc/internal.h
59622 +++ b/fs/proc/internal.h
59623 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59624 struct pid *, struct task_struct *);
59625 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59626 struct pid *, struct task_struct *);
59627 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59628 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59629 +#endif
59630
59631 /*
59632 * base.c
59633 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59634 index 06ea155..9a798c7 100644
59635 --- a/fs/proc/kcore.c
59636 +++ b/fs/proc/kcore.c
59637 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59638 * the addresses in the elf_phdr on our list.
59639 */
59640 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59641 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59642 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59643 + if (tsz > buflen)
59644 tsz = buflen;
59645 -
59646 +
59647 while (buflen) {
59648 struct kcore_list *m;
59649
59650 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59651 kfree(elf_buf);
59652 } else {
59653 if (kern_addr_valid(start)) {
59654 - unsigned long n;
59655 + char *elf_buf;
59656 + mm_segment_t oldfs;
59657
59658 - n = copy_to_user(buffer, (char *)start, tsz);
59659 - /*
59660 - * We cannot distinguish between fault on source
59661 - * and fault on destination. When this happens
59662 - * we clear too and hope it will trigger the
59663 - * EFAULT again.
59664 - */
59665 - if (n) {
59666 - if (clear_user(buffer + tsz - n,
59667 - n))
59668 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59669 + if (!elf_buf)
59670 + return -ENOMEM;
59671 + oldfs = get_fs();
59672 + set_fs(KERNEL_DS);
59673 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59674 + set_fs(oldfs);
59675 + if (copy_to_user(buffer, elf_buf, tsz)) {
59676 + kfree(elf_buf);
59677 return -EFAULT;
59678 + }
59679 }
59680 + set_fs(oldfs);
59681 + kfree(elf_buf);
59682 } else {
59683 if (clear_user(buffer, tsz))
59684 return -EFAULT;
59685 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59686
59687 static int open_kcore(struct inode *inode, struct file *filp)
59688 {
59689 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59690 + return -EPERM;
59691 +#endif
59692 if (!capable(CAP_SYS_RAWIO))
59693 return -EPERM;
59694 if (kcore_need_update)
59695 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59696 index 5aa847a..f77c8d4 100644
59697 --- a/fs/proc/meminfo.c
59698 +++ b/fs/proc/meminfo.c
59699 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59700 vmi.used >> 10,
59701 vmi.largest_chunk >> 10
59702 #ifdef CONFIG_MEMORY_FAILURE
59703 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59704 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59705 #endif
59706 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59707 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59708 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59709 index ccfd99b..1b7e255 100644
59710 --- a/fs/proc/nommu.c
59711 +++ b/fs/proc/nommu.c
59712 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59713 if (len < 1)
59714 len = 1;
59715 seq_printf(m, "%*c", len, ' ');
59716 - seq_path(m, &file->f_path, "");
59717 + seq_path(m, &file->f_path, "\n\\");
59718 }
59719
59720 seq_putc(m, '\n');
59721 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59722 index 4677bb7..408e936 100644
59723 --- a/fs/proc/proc_net.c
59724 +++ b/fs/proc/proc_net.c
59725 @@ -23,6 +23,7 @@
59726 #include <linux/nsproxy.h>
59727 #include <net/net_namespace.h>
59728 #include <linux/seq_file.h>
59729 +#include <linux/grsecurity.h>
59730
59731 #include "internal.h"
59732
59733 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59734 struct task_struct *task;
59735 struct nsproxy *ns;
59736 struct net *net = NULL;
59737 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59738 + const struct cred *cred = current_cred();
59739 +#endif
59740 +
59741 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59742 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59743 + return net;
59744 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59745 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59746 + return net;
59747 +#endif
59748
59749 rcu_read_lock();
59750 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59751 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59752 index 7129046..f2779c6 100644
59753 --- a/fs/proc/proc_sysctl.c
59754 +++ b/fs/proc/proc_sysctl.c
59755 @@ -13,11 +13,15 @@
59756 #include <linux/module.h>
59757 #include "internal.h"
59758
59759 +extern int gr_handle_chroot_sysctl(const int op);
59760 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59761 + const int op);
59762 +
59763 static const struct dentry_operations proc_sys_dentry_operations;
59764 static const struct file_operations proc_sys_file_operations;
59765 -static const struct inode_operations proc_sys_inode_operations;
59766 +const struct inode_operations proc_sys_inode_operations;
59767 static const struct file_operations proc_sys_dir_file_operations;
59768 -static const struct inode_operations proc_sys_dir_operations;
59769 +const struct inode_operations proc_sys_dir_operations;
59770
59771 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59772 {
59773 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59774
59775 err = NULL;
59776 d_set_d_op(dentry, &proc_sys_dentry_operations);
59777 +
59778 + gr_handle_proc_create(dentry, inode);
59779 +
59780 d_add(dentry, inode);
59781
59782 out:
59783 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59784 struct inode *inode = file_inode(filp);
59785 struct ctl_table_header *head = grab_header(inode);
59786 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59787 + int op = write ? MAY_WRITE : MAY_READ;
59788 ssize_t error;
59789 size_t res;
59790
59791 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59792 * and won't be until we finish.
59793 */
59794 error = -EPERM;
59795 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59796 + if (sysctl_perm(head, table, op))
59797 goto out;
59798
59799 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59800 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59801 if (!table->proc_handler)
59802 goto out;
59803
59804 +#ifdef CONFIG_GRKERNSEC
59805 + error = -EPERM;
59806 + if (gr_handle_chroot_sysctl(op))
59807 + goto out;
59808 + dget(filp->f_path.dentry);
59809 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59810 + dput(filp->f_path.dentry);
59811 + goto out;
59812 + }
59813 + dput(filp->f_path.dentry);
59814 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59815 + goto out;
59816 + if (write && !capable(CAP_SYS_ADMIN))
59817 + goto out;
59818 +#endif
59819 +
59820 /* careful: calling conventions are nasty here */
59821 res = count;
59822 error = table->proc_handler(table, write, buf, &res, ppos);
59823 @@ -598,6 +622,9 @@ static bool proc_sys_fill_cache(struct file *file,
59824 return false;
59825 } else {
59826 d_set_d_op(child, &proc_sys_dentry_operations);
59827 +
59828 + gr_handle_proc_create(child, inode);
59829 +
59830 d_add(child, inode);
59831 }
59832 } else {
59833 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59834 if ((*pos)++ < ctx->pos)
59835 return true;
59836
59837 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59838 + return 0;
59839 +
59840 if (unlikely(S_ISLNK(table->mode)))
59841 res = proc_sys_link_fill_cache(file, ctx, head, table);
59842 else
59843 @@ -734,6 +764,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59844 if (IS_ERR(head))
59845 return PTR_ERR(head);
59846
59847 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59848 + return -ENOENT;
59849 +
59850 generic_fillattr(inode, stat);
59851 if (table)
59852 stat->mode = (stat->mode & S_IFMT) | table->mode;
59853 @@ -756,13 +789,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59854 .llseek = generic_file_llseek,
59855 };
59856
59857 -static const struct inode_operations proc_sys_inode_operations = {
59858 +const struct inode_operations proc_sys_inode_operations = {
59859 .permission = proc_sys_permission,
59860 .setattr = proc_sys_setattr,
59861 .getattr = proc_sys_getattr,
59862 };
59863
59864 -static const struct inode_operations proc_sys_dir_operations = {
59865 +const struct inode_operations proc_sys_dir_operations = {
59866 .lookup = proc_sys_lookup,
59867 .permission = proc_sys_permission,
59868 .setattr = proc_sys_setattr,
59869 @@ -839,7 +872,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59870 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59871 const char *name, int namelen)
59872 {
59873 - struct ctl_table *table;
59874 + ctl_table_no_const *table;
59875 struct ctl_dir *new;
59876 struct ctl_node *node;
59877 char *new_name;
59878 @@ -851,7 +884,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59879 return NULL;
59880
59881 node = (struct ctl_node *)(new + 1);
59882 - table = (struct ctl_table *)(node + 1);
59883 + table = (ctl_table_no_const *)(node + 1);
59884 new_name = (char *)(table + 2);
59885 memcpy(new_name, name, namelen);
59886 new_name[namelen] = '\0';
59887 @@ -1020,7 +1053,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59888 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59889 struct ctl_table_root *link_root)
59890 {
59891 - struct ctl_table *link_table, *entry, *link;
59892 + ctl_table_no_const *link_table, *link;
59893 + struct ctl_table *entry;
59894 struct ctl_table_header *links;
59895 struct ctl_node *node;
59896 char *link_name;
59897 @@ -1043,7 +1077,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59898 return NULL;
59899
59900 node = (struct ctl_node *)(links + 1);
59901 - link_table = (struct ctl_table *)(node + nr_entries);
59902 + link_table = (ctl_table_no_const *)(node + nr_entries);
59903 link_name = (char *)&link_table[nr_entries + 1];
59904
59905 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59906 @@ -1291,8 +1325,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59907 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59908 struct ctl_table *table)
59909 {
59910 - struct ctl_table *ctl_table_arg = NULL;
59911 - struct ctl_table *entry, *files;
59912 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59913 + struct ctl_table *entry;
59914 int nr_files = 0;
59915 int nr_dirs = 0;
59916 int err = -ENOMEM;
59917 @@ -1304,10 +1338,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59918 nr_files++;
59919 }
59920
59921 - files = table;
59922 /* If there are mixed files and directories we need a new table */
59923 if (nr_dirs && nr_files) {
59924 - struct ctl_table *new;
59925 + ctl_table_no_const *new;
59926 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59927 GFP_KERNEL);
59928 if (!files)
59929 @@ -1325,7 +1358,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59930 /* Register everything except a directory full of subdirectories */
59931 if (nr_files || !nr_dirs) {
59932 struct ctl_table_header *header;
59933 - header = __register_sysctl_table(set, path, files);
59934 + header = __register_sysctl_table(set, path, files ? files : table);
59935 if (!header) {
59936 kfree(ctl_table_arg);
59937 goto out;
59938 diff --git a/fs/proc/root.c b/fs/proc/root.c
59939 index e0a790d..21e095e 100644
59940 --- a/fs/proc/root.c
59941 +++ b/fs/proc/root.c
59942 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
59943 #ifdef CONFIG_PROC_DEVICETREE
59944 proc_device_tree_init();
59945 #endif
59946 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59947 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59948 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
59949 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59950 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
59951 +#endif
59952 +#else
59953 proc_mkdir("bus", NULL);
59954 +#endif
59955 proc_sys_init();
59956 }
59957
59958 diff --git a/fs/proc/self.c b/fs/proc/self.c
59959 index 6b6a993..807cccc 100644
59960 --- a/fs/proc/self.c
59961 +++ b/fs/proc/self.c
59962 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
59963 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
59964 void *cookie)
59965 {
59966 - char *s = nd_get_link(nd);
59967 + const char *s = nd_get_link(nd);
59968 if (!IS_ERR(s))
59969 kfree(s);
59970 }
59971 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
59972 index 107d026..c715aeb 100644
59973 --- a/fs/proc/task_mmu.c
59974 +++ b/fs/proc/task_mmu.c
59975 @@ -12,12 +12,19 @@
59976 #include <linux/swap.h>
59977 #include <linux/swapops.h>
59978 #include <linux/mmu_notifier.h>
59979 +#include <linux/grsecurity.h>
59980
59981 #include <asm/elf.h>
59982 #include <asm/uaccess.h>
59983 #include <asm/tlbflush.h>
59984 #include "internal.h"
59985
59986 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59987 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59988 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59989 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59990 +#endif
59991 +
59992 void task_mem(struct seq_file *m, struct mm_struct *mm)
59993 {
59994 unsigned long data, text, lib, swap;
59995 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59996 "VmExe:\t%8lu kB\n"
59997 "VmLib:\t%8lu kB\n"
59998 "VmPTE:\t%8lu kB\n"
59999 - "VmSwap:\t%8lu kB\n",
60000 - hiwater_vm << (PAGE_SHIFT-10),
60001 + "VmSwap:\t%8lu kB\n"
60002 +
60003 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60004 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
60005 +#endif
60006 +
60007 + ,hiwater_vm << (PAGE_SHIFT-10),
60008 total_vm << (PAGE_SHIFT-10),
60009 mm->locked_vm << (PAGE_SHIFT-10),
60010 mm->pinned_vm << (PAGE_SHIFT-10),
60011 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60012 data << (PAGE_SHIFT-10),
60013 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
60014 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
60015 - swap << (PAGE_SHIFT-10));
60016 + swap << (PAGE_SHIFT-10)
60017 +
60018 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60019 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60020 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60021 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60022 +#else
60023 + , mm->context.user_cs_base
60024 + , mm->context.user_cs_limit
60025 +#endif
60026 +#endif
60027 +
60028 + );
60029 }
60030
60031 unsigned long task_vsize(struct mm_struct *mm)
60032 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60033 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60034 }
60035
60036 - /* We don't show the stack guard page in /proc/maps */
60037 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60038 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60039 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60040 +#else
60041 start = vma->vm_start;
60042 - if (stack_guard_page_start(vma, start))
60043 - start += PAGE_SIZE;
60044 end = vma->vm_end;
60045 - if (stack_guard_page_end(vma, end))
60046 - end -= PAGE_SIZE;
60047 +#endif
60048
60049 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60050 start,
60051 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60052 flags & VM_WRITE ? 'w' : '-',
60053 flags & VM_EXEC ? 'x' : '-',
60054 flags & VM_MAYSHARE ? 's' : 'p',
60055 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60056 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60057 +#else
60058 pgoff,
60059 +#endif
60060 MAJOR(dev), MINOR(dev), ino, &len);
60061
60062 /*
60063 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60064 */
60065 if (file) {
60066 pad_len_spaces(m, len);
60067 - seq_path(m, &file->f_path, "\n");
60068 + seq_path(m, &file->f_path, "\n\\");
60069 goto done;
60070 }
60071
60072 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60073 * Thread stack in /proc/PID/task/TID/maps or
60074 * the main process stack.
60075 */
60076 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60077 - vma->vm_end >= mm->start_stack)) {
60078 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60079 + (vma->vm_start <= mm->start_stack &&
60080 + vma->vm_end >= mm->start_stack)) {
60081 name = "[stack]";
60082 } else {
60083 /* Thread stack in /proc/PID/maps */
60084 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60085 struct proc_maps_private *priv = m->private;
60086 struct task_struct *task = priv->task;
60087
60088 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60089 + if (current->exec_id != m->exec_id) {
60090 + gr_log_badprocpid("maps");
60091 + return 0;
60092 + }
60093 +#endif
60094 +
60095 show_map_vma(m, vma, is_pid);
60096
60097 if (m->count < m->size) /* vma is copied successfully */
60098 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60099 .private = &mss,
60100 };
60101
60102 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60103 + if (current->exec_id != m->exec_id) {
60104 + gr_log_badprocpid("smaps");
60105 + return 0;
60106 + }
60107 +#endif
60108 memset(&mss, 0, sizeof mss);
60109 - mss.vma = vma;
60110 - /* mmap_sem is held in m_start */
60111 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60112 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60113 -
60114 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60115 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60116 +#endif
60117 + mss.vma = vma;
60118 + /* mmap_sem is held in m_start */
60119 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60120 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60121 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60122 + }
60123 +#endif
60124 show_map_vma(m, vma, is_pid);
60125
60126 seq_printf(m,
60127 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60128 "KernelPageSize: %8lu kB\n"
60129 "MMUPageSize: %8lu kB\n"
60130 "Locked: %8lu kB\n",
60131 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60132 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60133 +#else
60134 (vma->vm_end - vma->vm_start) >> 10,
60135 +#endif
60136 mss.resident >> 10,
60137 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60138 mss.shared_clean >> 10,
60139 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60140 int n;
60141 char buffer[50];
60142
60143 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60144 + if (current->exec_id != m->exec_id) {
60145 + gr_log_badprocpid("numa_maps");
60146 + return 0;
60147 + }
60148 +#endif
60149 +
60150 if (!mm)
60151 return 0;
60152
60153 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60154 mpol_to_str(buffer, sizeof(buffer), pol);
60155 mpol_cond_put(pol);
60156
60157 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60158 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60159 +#else
60160 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60161 +#endif
60162
60163 if (file) {
60164 seq_printf(m, " file=");
60165 - seq_path(m, &file->f_path, "\n\t= ");
60166 + seq_path(m, &file->f_path, "\n\t\\= ");
60167 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60168 seq_printf(m, " heap");
60169 } else {
60170 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60171 index 56123a6..5a2f6ec 100644
60172 --- a/fs/proc/task_nommu.c
60173 +++ b/fs/proc/task_nommu.c
60174 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60175 else
60176 bytes += kobjsize(mm);
60177
60178 - if (current->fs && current->fs->users > 1)
60179 + if (current->fs && atomic_read(&current->fs->users) > 1)
60180 sbytes += kobjsize(current->fs);
60181 else
60182 bytes += kobjsize(current->fs);
60183 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60184
60185 if (file) {
60186 pad_len_spaces(m, len);
60187 - seq_path(m, &file->f_path, "");
60188 + seq_path(m, &file->f_path, "\n\\");
60189 } else if (mm) {
60190 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60191
60192 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60193 index a1a16eb..6be46ed 100644
60194 --- a/fs/proc/vmcore.c
60195 +++ b/fs/proc/vmcore.c
60196 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60197 nr_bytes = count;
60198
60199 /* If pfn is not ram, return zeros for sparse dump files */
60200 - if (pfn_is_ram(pfn) == 0)
60201 - memset(buf, 0, nr_bytes);
60202 - else {
60203 + if (pfn_is_ram(pfn) == 0) {
60204 + if (userbuf) {
60205 + if (clear_user((char __force_user *)buf, nr_bytes))
60206 + return -EFAULT;
60207 + } else
60208 + memset(buf, 0, nr_bytes);
60209 + } else {
60210 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60211 offset, userbuf);
60212 if (tmp < 0)
60213 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60214 if (*fpos < m->offset + m->size) {
60215 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60216 start = m->paddr + *fpos - m->offset;
60217 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60218 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60219 if (tmp < 0)
60220 return tmp;
60221 buflen -= tsz;
60222 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60223 index b00fcc9..e0c6381 100644
60224 --- a/fs/qnx6/qnx6.h
60225 +++ b/fs/qnx6/qnx6.h
60226 @@ -74,7 +74,7 @@ enum {
60227 BYTESEX_BE,
60228 };
60229
60230 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60231 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60232 {
60233 if (sbi->s_bytesex == BYTESEX_LE)
60234 return le64_to_cpu((__force __le64)n);
60235 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60236 return (__force __fs64)cpu_to_be64(n);
60237 }
60238
60239 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60240 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60241 {
60242 if (sbi->s_bytesex == BYTESEX_LE)
60243 return le32_to_cpu((__force __le32)n);
60244 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60245 index 16e8abb..2dcf914 100644
60246 --- a/fs/quota/netlink.c
60247 +++ b/fs/quota/netlink.c
60248 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60249 void quota_send_warning(struct kqid qid, dev_t dev,
60250 const char warntype)
60251 {
60252 - static atomic_t seq;
60253 + static atomic_unchecked_t seq;
60254 struct sk_buff *skb;
60255 void *msg_head;
60256 int ret;
60257 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60258 "VFS: Not enough memory to send quota warning.\n");
60259 return;
60260 }
60261 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60262 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60263 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60264 if (!msg_head) {
60265 printk(KERN_ERR
60266 diff --git a/fs/read_write.c b/fs/read_write.c
60267 index 122a384..0b7ecf2 100644
60268 --- a/fs/read_write.c
60269 +++ b/fs/read_write.c
60270 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60271
60272 old_fs = get_fs();
60273 set_fs(get_ds());
60274 - p = (__force const char __user *)buf;
60275 + p = (const char __force_user *)buf;
60276 if (count > MAX_RW_COUNT)
60277 count = MAX_RW_COUNT;
60278 if (file->f_op->write)
60279 diff --git a/fs/readdir.c b/fs/readdir.c
60280 index 93d71e5..6a14be8 100644
60281 --- a/fs/readdir.c
60282 +++ b/fs/readdir.c
60283 @@ -17,6 +17,7 @@
60284 #include <linux/security.h>
60285 #include <linux/syscalls.h>
60286 #include <linux/unistd.h>
60287 +#include <linux/namei.h>
60288
60289 #include <asm/uaccess.h>
60290
60291 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60292 struct readdir_callback {
60293 struct dir_context ctx;
60294 struct old_linux_dirent __user * dirent;
60295 + struct file * file;
60296 int result;
60297 };
60298
60299 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60300 buf->result = -EOVERFLOW;
60301 return -EOVERFLOW;
60302 }
60303 +
60304 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60305 + return 0;
60306 +
60307 buf->result++;
60308 dirent = buf->dirent;
60309 if (!access_ok(VERIFY_WRITE, dirent,
60310 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60311 if (!f.file)
60312 return -EBADF;
60313
60314 + buf.file = f.file;
60315 error = iterate_dir(f.file, &buf.ctx);
60316 if (buf.result)
60317 error = buf.result;
60318 @@ -142,6 +149,7 @@ struct getdents_callback {
60319 struct dir_context ctx;
60320 struct linux_dirent __user * current_dir;
60321 struct linux_dirent __user * previous;
60322 + struct file * file;
60323 int count;
60324 int error;
60325 };
60326 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60327 buf->error = -EOVERFLOW;
60328 return -EOVERFLOW;
60329 }
60330 +
60331 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60332 + return 0;
60333 +
60334 dirent = buf->previous;
60335 if (dirent) {
60336 if (__put_user(offset, &dirent->d_off))
60337 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60338 if (!f.file)
60339 return -EBADF;
60340
60341 + buf.file = f.file;
60342 error = iterate_dir(f.file, &buf.ctx);
60343 if (error >= 0)
60344 error = buf.error;
60345 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60346 struct dir_context ctx;
60347 struct linux_dirent64 __user * current_dir;
60348 struct linux_dirent64 __user * previous;
60349 + struct file *file;
60350 int count;
60351 int error;
60352 };
60353 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60354 buf->error = -EINVAL; /* only used if we fail.. */
60355 if (reclen > buf->count)
60356 return -EINVAL;
60357 +
60358 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60359 + return 0;
60360 +
60361 dirent = buf->previous;
60362 if (dirent) {
60363 if (__put_user(offset, &dirent->d_off))
60364 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60365 if (!f.file)
60366 return -EBADF;
60367
60368 + buf.file = f.file;
60369 error = iterate_dir(f.file, &buf.ctx);
60370 if (error >= 0)
60371 error = buf.error;
60372 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60373 index 2b7882b..1c5ef48 100644
60374 --- a/fs/reiserfs/do_balan.c
60375 +++ b/fs/reiserfs/do_balan.c
60376 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60377 return;
60378 }
60379
60380 - atomic_inc(&(fs_generation(tb->tb_sb)));
60381 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60382 do_balance_starts(tb);
60383
60384 /* balance leaf returns 0 except if combining L R and S into
60385 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60386 index a958444..42b2323 100644
60387 --- a/fs/reiserfs/procfs.c
60388 +++ b/fs/reiserfs/procfs.c
60389 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60390 "SMALL_TAILS " : "NO_TAILS ",
60391 replay_only(sb) ? "REPLAY_ONLY " : "",
60392 convert_reiserfs(sb) ? "CONV " : "",
60393 - atomic_read(&r->s_generation_counter),
60394 + atomic_read_unchecked(&r->s_generation_counter),
60395 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60396 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60397 SF(s_good_search_by_key_reada), SF(s_bmaps),
60398 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60399 index 3df5ce6..8c0f4b0 100644
60400 --- a/fs/reiserfs/reiserfs.h
60401 +++ b/fs/reiserfs/reiserfs.h
60402 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60403 /* Comment? -Hans */
60404 wait_queue_head_t s_wait;
60405 /* To be obsoleted soon by per buffer seals.. -Hans */
60406 - atomic_t s_generation_counter; // increased by one every time the
60407 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60408 // tree gets re-balanced
60409 unsigned long s_properties; /* File system properties. Currently holds
60410 on-disk FS format */
60411 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60412 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60413
60414 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60415 -#define get_generation(s) atomic_read (&fs_generation(s))
60416 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60417 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60418 #define __fs_changed(gen,s) (gen != get_generation (s))
60419 #define fs_changed(gen,s) \
60420 diff --git a/fs/select.c b/fs/select.c
60421 index 35d4adc7..d6c60db 100644
60422 --- a/fs/select.c
60423 +++ b/fs/select.c
60424 @@ -20,6 +20,7 @@
60425 #include <linux/export.h>
60426 #include <linux/slab.h>
60427 #include <linux/poll.h>
60428 +#include <linux/security.h>
60429 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60430 #include <linux/file.h>
60431 #include <linux/fdtable.h>
60432 @@ -881,6 +882,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60433 struct poll_list *walk = head;
60434 unsigned long todo = nfds;
60435
60436 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60437 if (nfds > rlimit(RLIMIT_NOFILE))
60438 return -EINVAL;
60439
60440 diff --git a/fs/seq_file.c b/fs/seq_file.c
60441 index 3135c25..d0395dd 100644
60442 --- a/fs/seq_file.c
60443 +++ b/fs/seq_file.c
60444 @@ -10,6 +10,7 @@
60445 #include <linux/seq_file.h>
60446 #include <linux/slab.h>
60447 #include <linux/cred.h>
60448 +#include <linux/sched.h>
60449
60450 #include <asm/uaccess.h>
60451 #include <asm/page.h>
60452 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60453 #ifdef CONFIG_USER_NS
60454 p->user_ns = file->f_cred->user_ns;
60455 #endif
60456 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60457 + p->exec_id = current->exec_id;
60458 +#endif
60459
60460 /*
60461 * Wrappers around seq_open(e.g. swaps_open) need to be
60462 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60463 return 0;
60464 }
60465 if (!m->buf) {
60466 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60467 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60468 if (!m->buf)
60469 return -ENOMEM;
60470 }
60471 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60472 Eoverflow:
60473 m->op->stop(m, p);
60474 kfree(m->buf);
60475 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60476 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60477 return !m->buf ? -ENOMEM : -EAGAIN;
60478 }
60479
60480 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60481
60482 /* grab buffer if we didn't have one */
60483 if (!m->buf) {
60484 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60485 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60486 if (!m->buf)
60487 goto Enomem;
60488 }
60489 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60490 goto Fill;
60491 m->op->stop(m, p);
60492 kfree(m->buf);
60493 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60494 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60495 if (!m->buf)
60496 goto Enomem;
60497 m->count = 0;
60498 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
60499 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60500 void *data)
60501 {
60502 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60503 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60504 int res = -ENOMEM;
60505
60506 if (op) {
60507 diff --git a/fs/splice.c b/fs/splice.c
60508 index 3b7ee65..87fc2e4 100644
60509 --- a/fs/splice.c
60510 +++ b/fs/splice.c
60511 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60512 pipe_lock(pipe);
60513
60514 for (;;) {
60515 - if (!pipe->readers) {
60516 + if (!atomic_read(&pipe->readers)) {
60517 send_sig(SIGPIPE, current, 0);
60518 if (!ret)
60519 ret = -EPIPE;
60520 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60521 page_nr++;
60522 ret += buf->len;
60523
60524 - if (pipe->files)
60525 + if (atomic_read(&pipe->files))
60526 do_wakeup = 1;
60527
60528 if (!--spd->nr_pages)
60529 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60530 do_wakeup = 0;
60531 }
60532
60533 - pipe->waiting_writers++;
60534 + atomic_inc(&pipe->waiting_writers);
60535 pipe_wait(pipe);
60536 - pipe->waiting_writers--;
60537 + atomic_dec(&pipe->waiting_writers);
60538 }
60539
60540 pipe_unlock(pipe);
60541 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60542 old_fs = get_fs();
60543 set_fs(get_ds());
60544 /* The cast to a user pointer is valid due to the set_fs() */
60545 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60546 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60547 set_fs(old_fs);
60548
60549 return res;
60550 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60551 old_fs = get_fs();
60552 set_fs(get_ds());
60553 /* The cast to a user pointer is valid due to the set_fs() */
60554 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60555 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60556 set_fs(old_fs);
60557
60558 return res;
60559 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60560 goto err;
60561
60562 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60563 - vec[i].iov_base = (void __user *) page_address(page);
60564 + vec[i].iov_base = (void __force_user *) page_address(page);
60565 vec[i].iov_len = this_len;
60566 spd.pages[i] = page;
60567 spd.nr_pages++;
60568 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60569 ops->release(pipe, buf);
60570 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60571 pipe->nrbufs--;
60572 - if (pipe->files)
60573 + if (atomic_read(&pipe->files))
60574 sd->need_wakeup = true;
60575 }
60576
60577 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60578 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60579 {
60580 while (!pipe->nrbufs) {
60581 - if (!pipe->writers)
60582 + if (!atomic_read(&pipe->writers))
60583 return 0;
60584
60585 - if (!pipe->waiting_writers && sd->num_spliced)
60586 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60587 return 0;
60588
60589 if (sd->flags & SPLICE_F_NONBLOCK)
60590 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60591 * out of the pipe right after the splice_to_pipe(). So set
60592 * PIPE_READERS appropriately.
60593 */
60594 - pipe->readers = 1;
60595 + atomic_set(&pipe->readers, 1);
60596
60597 current->splice_pipe = pipe;
60598 }
60599 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60600
60601 partial[buffers].offset = off;
60602 partial[buffers].len = plen;
60603 + partial[buffers].private = 0;
60604
60605 off = 0;
60606 len -= plen;
60607 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60608 ret = -ERESTARTSYS;
60609 break;
60610 }
60611 - if (!pipe->writers)
60612 + if (!atomic_read(&pipe->writers))
60613 break;
60614 - if (!pipe->waiting_writers) {
60615 + if (!atomic_read(&pipe->waiting_writers)) {
60616 if (flags & SPLICE_F_NONBLOCK) {
60617 ret = -EAGAIN;
60618 break;
60619 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60620 pipe_lock(pipe);
60621
60622 while (pipe->nrbufs >= pipe->buffers) {
60623 - if (!pipe->readers) {
60624 + if (!atomic_read(&pipe->readers)) {
60625 send_sig(SIGPIPE, current, 0);
60626 ret = -EPIPE;
60627 break;
60628 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60629 ret = -ERESTARTSYS;
60630 break;
60631 }
60632 - pipe->waiting_writers++;
60633 + atomic_inc(&pipe->waiting_writers);
60634 pipe_wait(pipe);
60635 - pipe->waiting_writers--;
60636 + atomic_dec(&pipe->waiting_writers);
60637 }
60638
60639 pipe_unlock(pipe);
60640 @@ -1862,14 +1863,14 @@ retry:
60641 pipe_double_lock(ipipe, opipe);
60642
60643 do {
60644 - if (!opipe->readers) {
60645 + if (!atomic_read(&opipe->readers)) {
60646 send_sig(SIGPIPE, current, 0);
60647 if (!ret)
60648 ret = -EPIPE;
60649 break;
60650 }
60651
60652 - if (!ipipe->nrbufs && !ipipe->writers)
60653 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60654 break;
60655
60656 /*
60657 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60658 pipe_double_lock(ipipe, opipe);
60659
60660 do {
60661 - if (!opipe->readers) {
60662 + if (!atomic_read(&opipe->readers)) {
60663 send_sig(SIGPIPE, current, 0);
60664 if (!ret)
60665 ret = -EPIPE;
60666 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60667 * return EAGAIN if we have the potential of some data in the
60668 * future, otherwise just return 0
60669 */
60670 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60671 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60672 ret = -EAGAIN;
60673
60674 pipe_unlock(ipipe);
60675 diff --git a/fs/stat.c b/fs/stat.c
60676 index 04ce1ac..a13dd1e 100644
60677 --- a/fs/stat.c
60678 +++ b/fs/stat.c
60679 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60680 stat->gid = inode->i_gid;
60681 stat->rdev = inode->i_rdev;
60682 stat->size = i_size_read(inode);
60683 - stat->atime = inode->i_atime;
60684 - stat->mtime = inode->i_mtime;
60685 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60686 + stat->atime = inode->i_ctime;
60687 + stat->mtime = inode->i_ctime;
60688 + } else {
60689 + stat->atime = inode->i_atime;
60690 + stat->mtime = inode->i_mtime;
60691 + }
60692 stat->ctime = inode->i_ctime;
60693 stat->blksize = (1 << inode->i_blkbits);
60694 stat->blocks = inode->i_blocks;
60695 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60696 if (retval)
60697 return retval;
60698
60699 - if (inode->i_op->getattr)
60700 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60701 + if (inode->i_op->getattr) {
60702 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60703 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60704 + stat->atime = stat->ctime;
60705 + stat->mtime = stat->ctime;
60706 + }
60707 + return retval;
60708 + }
60709
60710 generic_fillattr(inode, stat);
60711 return 0;
60712 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60713 index 15c68f9..36a8b3e 100644
60714 --- a/fs/sysfs/bin.c
60715 +++ b/fs/sysfs/bin.c
60716 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60717 return ret;
60718 }
60719
60720 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60721 - void *buf, int len, int write)
60722 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60723 + void *buf, size_t len, int write)
60724 {
60725 struct file *file = vma->vm_file;
60726 struct bin_buffer *bb = file->private_data;
60727 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60728 - int ret;
60729 + ssize_t ret;
60730
60731 if (!bb->vm_ops)
60732 return -EINVAL;
60733 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60734 index e068e74..92edeb8 100644
60735 --- a/fs/sysfs/dir.c
60736 +++ b/fs/sysfs/dir.c
60737 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60738 *
60739 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60740 */
60741 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60742 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60743 {
60744 unsigned long hash = init_name_hash();
60745 unsigned int len = strlen(name);
60746 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60747 struct sysfs_dirent *sd;
60748 int rc;
60749
60750 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60751 + const char *parent_name = parent_sd->s_name;
60752 +
60753 + mode = S_IFDIR | S_IRWXU;
60754 +
60755 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60756 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60757 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60758 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60759 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60760 +#endif
60761 +
60762 /* allocate */
60763 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60764 if (!sd)
60765 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60766 index d2bb7ed..fe8c331 100644
60767 --- a/fs/sysfs/file.c
60768 +++ b/fs/sysfs/file.c
60769 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60770
60771 struct sysfs_open_dirent {
60772 atomic_t refcnt;
60773 - atomic_t event;
60774 + atomic_unchecked_t event;
60775 wait_queue_head_t poll;
60776 struct list_head buffers; /* goes through sysfs_buffer.list */
60777 };
60778 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60779 if (!sysfs_get_active(attr_sd))
60780 return -ENODEV;
60781
60782 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60783 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60784 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60785
60786 sysfs_put_active(attr_sd);
60787 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60788 return -ENOMEM;
60789
60790 atomic_set(&new_od->refcnt, 0);
60791 - atomic_set(&new_od->event, 1);
60792 + atomic_set_unchecked(&new_od->event, 1);
60793 init_waitqueue_head(&new_od->poll);
60794 INIT_LIST_HEAD(&new_od->buffers);
60795 goto retry;
60796 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60797
60798 sysfs_put_active(attr_sd);
60799
60800 - if (buffer->event != atomic_read(&od->event))
60801 + if (buffer->event != atomic_read_unchecked(&od->event))
60802 goto trigger;
60803
60804 return DEFAULT_POLLMASK;
60805 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60806 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60807 od = sd->s_attr.open;
60808 if (od) {
60809 - atomic_inc(&od->event);
60810 + atomic_inc_unchecked(&od->event);
60811 wake_up_interruptible(&od->poll);
60812 }
60813 }
60814 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60815 index 8c940df..25b733e 100644
60816 --- a/fs/sysfs/symlink.c
60817 +++ b/fs/sysfs/symlink.c
60818 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60819
60820 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60821 {
60822 - char *page = nd_get_link(nd);
60823 + const char *page = nd_get_link(nd);
60824 if (!IS_ERR(page))
60825 free_page((unsigned long)page);
60826 }
60827 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60828 index 69d4889..a810bd4 100644
60829 --- a/fs/sysv/sysv.h
60830 +++ b/fs/sysv/sysv.h
60831 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60832 #endif
60833 }
60834
60835 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60836 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60837 {
60838 if (sbi->s_bytesex == BYTESEX_PDP)
60839 return PDP_swab((__force __u32)n);
60840 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60841 index e18b988..f1d4ad0f 100644
60842 --- a/fs/ubifs/io.c
60843 +++ b/fs/ubifs/io.c
60844 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60845 return err;
60846 }
60847
60848 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60849 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60850 {
60851 int err;
60852
60853 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60854 index c175b4d..8f36a16 100644
60855 --- a/fs/udf/misc.c
60856 +++ b/fs/udf/misc.c
60857 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60858
60859 u8 udf_tag_checksum(const struct tag *t)
60860 {
60861 - u8 *data = (u8 *)t;
60862 + const u8 *data = (const u8 *)t;
60863 u8 checksum = 0;
60864 int i;
60865 for (i = 0; i < sizeof(struct tag); ++i)
60866 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60867 index 8d974c4..b82f6ec 100644
60868 --- a/fs/ufs/swab.h
60869 +++ b/fs/ufs/swab.h
60870 @@ -22,7 +22,7 @@ enum {
60871 BYTESEX_BE
60872 };
60873
60874 -static inline u64
60875 +static inline u64 __intentional_overflow(-1)
60876 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60877 {
60878 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60879 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60880 return (__force __fs64)cpu_to_be64(n);
60881 }
60882
60883 -static inline u32
60884 +static inline u32 __intentional_overflow(-1)
60885 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60886 {
60887 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60888 diff --git a/fs/utimes.c b/fs/utimes.c
60889 index f4fb7ec..3fe03c0 100644
60890 --- a/fs/utimes.c
60891 +++ b/fs/utimes.c
60892 @@ -1,6 +1,7 @@
60893 #include <linux/compiler.h>
60894 #include <linux/file.h>
60895 #include <linux/fs.h>
60896 +#include <linux/security.h>
60897 #include <linux/linkage.h>
60898 #include <linux/mount.h>
60899 #include <linux/namei.h>
60900 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60901 goto mnt_drop_write_and_out;
60902 }
60903 }
60904 +
60905 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60906 + error = -EACCES;
60907 + goto mnt_drop_write_and_out;
60908 + }
60909 +
60910 mutex_lock(&inode->i_mutex);
60911 error = notify_change(path->dentry, &newattrs);
60912 mutex_unlock(&inode->i_mutex);
60913 diff --git a/fs/xattr.c b/fs/xattr.c
60914 index 3377dff..4d074d9 100644
60915 --- a/fs/xattr.c
60916 +++ b/fs/xattr.c
60917 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60918 return rc;
60919 }
60920
60921 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60922 +ssize_t
60923 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60924 +{
60925 + struct inode *inode = dentry->d_inode;
60926 + ssize_t error;
60927 +
60928 + error = inode_permission(inode, MAY_EXEC);
60929 + if (error)
60930 + return error;
60931 +
60932 + if (inode->i_op->getxattr)
60933 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60934 + else
60935 + error = -EOPNOTSUPP;
60936 +
60937 + return error;
60938 +}
60939 +EXPORT_SYMBOL(pax_getxattr);
60940 +#endif
60941 +
60942 ssize_t
60943 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
60944 {
60945 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
60946 * Extended attribute SET operations
60947 */
60948 static long
60949 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
60950 +setxattr(struct path *path, const char __user *name, const void __user *value,
60951 size_t size, int flags)
60952 {
60953 int error;
60954 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
60955 posix_acl_fix_xattr_from_user(kvalue, size);
60956 }
60957
60958 - error = vfs_setxattr(d, kname, kvalue, size, flags);
60959 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
60960 + error = -EACCES;
60961 + goto out;
60962 + }
60963 +
60964 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
60965 out:
60966 if (vvalue)
60967 vfree(vvalue);
60968 @@ -377,7 +403,7 @@ retry:
60969 return error;
60970 error = mnt_want_write(path.mnt);
60971 if (!error) {
60972 - error = setxattr(path.dentry, name, value, size, flags);
60973 + error = setxattr(&path, name, value, size, flags);
60974 mnt_drop_write(path.mnt);
60975 }
60976 path_put(&path);
60977 @@ -401,7 +427,7 @@ retry:
60978 return error;
60979 error = mnt_want_write(path.mnt);
60980 if (!error) {
60981 - error = setxattr(path.dentry, name, value, size, flags);
60982 + error = setxattr(&path, name, value, size, flags);
60983 mnt_drop_write(path.mnt);
60984 }
60985 path_put(&path);
60986 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
60987 const void __user *,value, size_t, size, int, flags)
60988 {
60989 struct fd f = fdget(fd);
60990 - struct dentry *dentry;
60991 int error = -EBADF;
60992
60993 if (!f.file)
60994 return error;
60995 - dentry = f.file->f_path.dentry;
60996 - audit_inode(NULL, dentry, 0);
60997 + audit_inode(NULL, f.file->f_path.dentry, 0);
60998 error = mnt_want_write_file(f.file);
60999 if (!error) {
61000 - error = setxattr(dentry, name, value, size, flags);
61001 + error = setxattr(&f.file->f_path, name, value, size, flags);
61002 mnt_drop_write_file(f.file);
61003 }
61004 fdput(f);
61005 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
61006 index 9fbea87..6b19972 100644
61007 --- a/fs/xattr_acl.c
61008 +++ b/fs/xattr_acl.c
61009 @@ -76,8 +76,8 @@ struct posix_acl *
61010 posix_acl_from_xattr(struct user_namespace *user_ns,
61011 const void *value, size_t size)
61012 {
61013 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
61014 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
61015 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
61016 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
61017 int count;
61018 struct posix_acl *acl;
61019 struct posix_acl_entry *acl_e;
61020 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61021 index 05c698c..6b918af 100644
61022 --- a/fs/xfs/xfs_bmap.c
61023 +++ b/fs/xfs/xfs_bmap.c
61024 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
61025
61026 #else
61027 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61028 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61029 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61030 #endif /* DEBUG */
61031
61032 /*
61033 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
61034 index 97676a3..399a75d 100644
61035 --- a/fs/xfs/xfs_dir2_sf.c
61036 +++ b/fs/xfs/xfs_dir2_sf.c
61037 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
61038
61039 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
61040 ctx->pos = off & 0x7fffffff;
61041 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61042 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61043 + char name[sfep->namelen];
61044 + memcpy(name, sfep->name, sfep->namelen);
61045 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
61046 + return 0;
61047 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61048 ino, DT_UNKNOWN))
61049 return 0;
61050 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
61051 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61052 index 6e2bca5..6ce80d3 100644
61053 --- a/fs/xfs/xfs_ioctl.c
61054 +++ b/fs/xfs/xfs_ioctl.c
61055 @@ -127,7 +127,7 @@ xfs_find_handle(
61056 }
61057
61058 error = -EFAULT;
61059 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61060 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61061 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61062 goto out_put;
61063
61064 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61065 index 96dda62..d6c6a52 100644
61066 --- a/fs/xfs/xfs_iops.c
61067 +++ b/fs/xfs/xfs_iops.c
61068 @@ -395,7 +395,7 @@ xfs_vn_put_link(
61069 struct nameidata *nd,
61070 void *p)
61071 {
61072 - char *s = nd_get_link(nd);
61073 + const char *s = nd_get_link(nd);
61074
61075 if (!IS_ERR(s))
61076 kfree(s);
61077 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61078 new file mode 100644
61079 index 0000000..0fd7c82
61080 --- /dev/null
61081 +++ b/grsecurity/Kconfig
61082 @@ -0,0 +1,1080 @@
61083 +#
61084 +# grecurity configuration
61085 +#
61086 +menu "Memory Protections"
61087 +depends on GRKERNSEC
61088 +
61089 +config GRKERNSEC_KMEM
61090 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61091 + default y if GRKERNSEC_CONFIG_AUTO
61092 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61093 + help
61094 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61095 + be written to or read from to modify or leak the contents of the running
61096 + kernel. /dev/port will also not be allowed to be opened and support
61097 + for /dev/cpu/*/msr will be removed. If you have module
61098 + support disabled, enabling this will close up five ways that are
61099 + currently used to insert malicious code into the running kernel.
61100 +
61101 + Even with all these features enabled, we still highly recommend that
61102 + you use the RBAC system, as it is still possible for an attacker to
61103 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61104 +
61105 + If you are not using XFree86, you may be able to stop this additional
61106 + case by enabling the 'Disable privileged I/O' option. Though nothing
61107 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61108 + but only to video memory, which is the only writing we allow in this
61109 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61110 + not be allowed to mprotect it with PROT_WRITE later.
61111 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61112 + from working.
61113 +
61114 + It is highly recommended that you say Y here if you meet all the
61115 + conditions above.
61116 +
61117 +config GRKERNSEC_VM86
61118 + bool "Restrict VM86 mode"
61119 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61120 + depends on X86_32
61121 +
61122 + help
61123 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61124 + make use of a special execution mode on 32bit x86 processors called
61125 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61126 + video cards and will still work with this option enabled. The purpose
61127 + of the option is to prevent exploitation of emulation errors in
61128 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61129 + Nearly all users should be able to enable this option.
61130 +
61131 +config GRKERNSEC_IO
61132 + bool "Disable privileged I/O"
61133 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61134 + depends on X86
61135 + select RTC_CLASS
61136 + select RTC_INTF_DEV
61137 + select RTC_DRV_CMOS
61138 +
61139 + help
61140 + If you say Y here, all ioperm and iopl calls will return an error.
61141 + Ioperm and iopl can be used to modify the running kernel.
61142 + Unfortunately, some programs need this access to operate properly,
61143 + the most notable of which are XFree86 and hwclock. hwclock can be
61144 + remedied by having RTC support in the kernel, so real-time
61145 + clock support is enabled if this option is enabled, to ensure
61146 + that hwclock operates correctly. XFree86 still will not
61147 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61148 + IF YOU USE XFree86. If you use XFree86 and you still want to
61149 + protect your kernel against modification, use the RBAC system.
61150 +
61151 +config GRKERNSEC_JIT_HARDEN
61152 + bool "Harden BPF JIT against spray attacks"
61153 + default y if GRKERNSEC_CONFIG_AUTO
61154 + depends on BPF_JIT
61155 + help
61156 + If you say Y here, the native code generated by the kernel's Berkeley
61157 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61158 + attacks that attempt to fit attacker-beneficial instructions in
61159 + 32bit immediate fields of JIT-generated native instructions. The
61160 + attacker will generally aim to cause an unintended instruction sequence
61161 + of JIT-generated native code to execute by jumping into the middle of
61162 + a generated instruction. This feature effectively randomizes the 32bit
61163 + immediate constants present in the generated code to thwart such attacks.
61164 +
61165 + If you're using KERNEXEC, it's recommended that you enable this option
61166 + to supplement the hardening of the kernel.
61167 +
61168 +config GRKERNSEC_PERF_HARDEN
61169 + bool "Disable unprivileged PERF_EVENTS usage by default"
61170 + default y if GRKERNSEC_CONFIG_AUTO
61171 + depends on PERF_EVENTS
61172 + help
61173 + If you say Y here, the range of acceptable values for the
61174 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61175 + default to a new value: 3. When the sysctl is set to this value, no
61176 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61177 +
61178 + Though PERF_EVENTS can be used legitimately for performance monitoring
61179 + and low-level application profiling, it is forced on regardless of
61180 + configuration, has been at fault for several vulnerabilities, and
61181 + creates new opportunities for side channels and other information leaks.
61182 +
61183 + This feature puts PERF_EVENTS into a secure default state and permits
61184 + the administrator to change out of it temporarily if unprivileged
61185 + application profiling is needed.
61186 +
61187 +config GRKERNSEC_RAND_THREADSTACK
61188 + bool "Insert random gaps between thread stacks"
61189 + default y if GRKERNSEC_CONFIG_AUTO
61190 + depends on PAX_RANDMMAP && !PPC
61191 + help
61192 + If you say Y here, a random-sized gap will be enforced between allocated
61193 + thread stacks. Glibc's NPTL and other threading libraries that
61194 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61195 + The implementation currently provides 8 bits of entropy for the gap.
61196 +
61197 + Many distributions do not compile threaded remote services with the
61198 + -fstack-check argument to GCC, causing the variable-sized stack-based
61199 + allocator, alloca(), to not probe the stack on allocation. This
61200 + permits an unbounded alloca() to skip over any guard page and potentially
61201 + modify another thread's stack reliably. An enforced random gap
61202 + reduces the reliability of such an attack and increases the chance
61203 + that such a read/write to another thread's stack instead lands in
61204 + an unmapped area, causing a crash and triggering grsecurity's
61205 + anti-bruteforcing logic.
61206 +
61207 +config GRKERNSEC_PROC_MEMMAP
61208 + bool "Harden ASLR against information leaks and entropy reduction"
61209 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61210 + depends on PAX_NOEXEC || PAX_ASLR
61211 + help
61212 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61213 + give no information about the addresses of its mappings if
61214 + PaX features that rely on random addresses are enabled on the task.
61215 + In addition to sanitizing this information and disabling other
61216 + dangerous sources of information, this option causes reads of sensitive
61217 + /proc/<pid> entries where the file descriptor was opened in a different
61218 + task than the one performing the read. Such attempts are logged.
61219 + This option also limits argv/env strings for suid/sgid binaries
61220 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61221 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61222 + binaries to prevent alternative mmap layouts from being abused.
61223 +
61224 + If you use PaX it is essential that you say Y here as it closes up
61225 + several holes that make full ASLR useless locally.
61226 +
61227 +config GRKERNSEC_BRUTE
61228 + bool "Deter exploit bruteforcing"
61229 + default y if GRKERNSEC_CONFIG_AUTO
61230 + help
61231 + If you say Y here, attempts to bruteforce exploits against forking
61232 + daemons such as apache or sshd, as well as against suid/sgid binaries
61233 + will be deterred. When a child of a forking daemon is killed by PaX
61234 + or crashes due to an illegal instruction or other suspicious signal,
61235 + the parent process will be delayed 30 seconds upon every subsequent
61236 + fork until the administrator is able to assess the situation and
61237 + restart the daemon.
61238 + In the suid/sgid case, the attempt is logged, the user has all their
61239 + existing instances of the suid/sgid binary terminated and will
61240 + be unable to execute any suid/sgid binaries for 15 minutes.
61241 +
61242 + It is recommended that you also enable signal logging in the auditing
61243 + section so that logs are generated when a process triggers a suspicious
61244 + signal.
61245 + If the sysctl option is enabled, a sysctl option with name
61246 + "deter_bruteforce" is created.
61247 +
61248 +
61249 +config GRKERNSEC_MODHARDEN
61250 + bool "Harden module auto-loading"
61251 + default y if GRKERNSEC_CONFIG_AUTO
61252 + depends on MODULES
61253 + help
61254 + If you say Y here, module auto-loading in response to use of some
61255 + feature implemented by an unloaded module will be restricted to
61256 + root users. Enabling this option helps defend against attacks
61257 + by unprivileged users who abuse the auto-loading behavior to
61258 + cause a vulnerable module to load that is then exploited.
61259 +
61260 + If this option prevents a legitimate use of auto-loading for a
61261 + non-root user, the administrator can execute modprobe manually
61262 + with the exact name of the module mentioned in the alert log.
61263 + Alternatively, the administrator can add the module to the list
61264 + of modules loaded at boot by modifying init scripts.
61265 +
61266 + Modification of init scripts will most likely be needed on
61267 + Ubuntu servers with encrypted home directory support enabled,
61268 + as the first non-root user logging in will cause the ecb(aes),
61269 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61270 +
61271 +config GRKERNSEC_HIDESYM
61272 + bool "Hide kernel symbols"
61273 + default y if GRKERNSEC_CONFIG_AUTO
61274 + select PAX_USERCOPY_SLABS
61275 + help
61276 + If you say Y here, getting information on loaded modules, and
61277 + displaying all kernel symbols through a syscall will be restricted
61278 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61279 + /proc/kallsyms will be restricted to the root user. The RBAC
61280 + system can hide that entry even from root.
61281 +
61282 + This option also prevents leaking of kernel addresses through
61283 + several /proc entries.
61284 +
61285 + Note that this option is only effective provided the following
61286 + conditions are met:
61287 + 1) The kernel using grsecurity is not precompiled by some distribution
61288 + 2) You have also enabled GRKERNSEC_DMESG
61289 + 3) You are using the RBAC system and hiding other files such as your
61290 + kernel image and System.map. Alternatively, enabling this option
61291 + causes the permissions on /boot, /lib/modules, and the kernel
61292 + source directory to change at compile time to prevent
61293 + reading by non-root users.
61294 + If the above conditions are met, this option will aid in providing a
61295 + useful protection against local kernel exploitation of overflows
61296 + and arbitrary read/write vulnerabilities.
61297 +
61298 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61299 + in addition to this feature.
61300 +
61301 +config GRKERNSEC_KERN_LOCKOUT
61302 + bool "Active kernel exploit response"
61303 + default y if GRKERNSEC_CONFIG_AUTO
61304 + depends on X86 || ARM || PPC || SPARC
61305 + help
61306 + If you say Y here, when a PaX alert is triggered due to suspicious
61307 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61308 + or an OOPS occurs due to bad memory accesses, instead of just
61309 + terminating the offending process (and potentially allowing
61310 + a subsequent exploit from the same user), we will take one of two
61311 + actions:
61312 + If the user was root, we will panic the system
61313 + If the user was non-root, we will log the attempt, terminate
61314 + all processes owned by the user, then prevent them from creating
61315 + any new processes until the system is restarted
61316 + This deters repeated kernel exploitation/bruteforcing attempts
61317 + and is useful for later forensics.
61318 +
61319 +endmenu
61320 +menu "Role Based Access Control Options"
61321 +depends on GRKERNSEC
61322 +
61323 +config GRKERNSEC_RBAC_DEBUG
61324 + bool
61325 +
61326 +config GRKERNSEC_NO_RBAC
61327 + bool "Disable RBAC system"
61328 + help
61329 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61330 + preventing the RBAC system from being enabled. You should only say Y
61331 + here if you have no intention of using the RBAC system, so as to prevent
61332 + an attacker with root access from misusing the RBAC system to hide files
61333 + and processes when loadable module support and /dev/[k]mem have been
61334 + locked down.
61335 +
61336 +config GRKERNSEC_ACL_HIDEKERN
61337 + bool "Hide kernel processes"
61338 + help
61339 + If you say Y here, all kernel threads will be hidden to all
61340 + processes but those whose subject has the "view hidden processes"
61341 + flag.
61342 +
61343 +config GRKERNSEC_ACL_MAXTRIES
61344 + int "Maximum tries before password lockout"
61345 + default 3
61346 + help
61347 + This option enforces the maximum number of times a user can attempt
61348 + to authorize themselves with the grsecurity RBAC system before being
61349 + denied the ability to attempt authorization again for a specified time.
61350 + The lower the number, the harder it will be to brute-force a password.
61351 +
61352 +config GRKERNSEC_ACL_TIMEOUT
61353 + int "Time to wait after max password tries, in seconds"
61354 + default 30
61355 + help
61356 + This option specifies the time the user must wait after attempting to
61357 + authorize to the RBAC system with the maximum number of invalid
61358 + passwords. The higher the number, the harder it will be to brute-force
61359 + a password.
61360 +
61361 +endmenu
61362 +menu "Filesystem Protections"
61363 +depends on GRKERNSEC
61364 +
61365 +config GRKERNSEC_PROC
61366 + bool "Proc restrictions"
61367 + default y if GRKERNSEC_CONFIG_AUTO
61368 + help
61369 + If you say Y here, the permissions of the /proc filesystem
61370 + will be altered to enhance system security and privacy. You MUST
61371 + choose either a user only restriction or a user and group restriction.
61372 + Depending upon the option you choose, you can either restrict users to
61373 + see only the processes they themselves run, or choose a group that can
61374 + view all processes and files normally restricted to root if you choose
61375 + the "restrict to user only" option. NOTE: If you're running identd or
61376 + ntpd as a non-root user, you will have to run it as the group you
61377 + specify here.
61378 +
61379 +config GRKERNSEC_PROC_USER
61380 + bool "Restrict /proc to user only"
61381 + depends on GRKERNSEC_PROC
61382 + help
61383 + If you say Y here, non-root users will only be able to view their own
61384 + processes, and restricts them from viewing network-related information,
61385 + and viewing kernel symbol and module information.
61386 +
61387 +config GRKERNSEC_PROC_USERGROUP
61388 + bool "Allow special group"
61389 + default y if GRKERNSEC_CONFIG_AUTO
61390 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61391 + help
61392 + If you say Y here, you will be able to select a group that will be
61393 + able to view all processes and network-related information. If you've
61394 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61395 + remain hidden. This option is useful if you want to run identd as
61396 + a non-root user. The group you select may also be chosen at boot time
61397 + via "grsec_proc_gid=" on the kernel commandline.
61398 +
61399 +config GRKERNSEC_PROC_GID
61400 + int "GID for special group"
61401 + depends on GRKERNSEC_PROC_USERGROUP
61402 + default 1001
61403 +
61404 +config GRKERNSEC_PROC_ADD
61405 + bool "Additional restrictions"
61406 + default y if GRKERNSEC_CONFIG_AUTO
61407 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61408 + help
61409 + If you say Y here, additional restrictions will be placed on
61410 + /proc that keep normal users from viewing device information and
61411 + slabinfo information that could be useful for exploits.
61412 +
61413 +config GRKERNSEC_LINK
61414 + bool "Linking restrictions"
61415 + default y if GRKERNSEC_CONFIG_AUTO
61416 + help
61417 + If you say Y here, /tmp race exploits will be prevented, since users
61418 + will no longer be able to follow symlinks owned by other users in
61419 + world-writable +t directories (e.g. /tmp), unless the owner of the
61420 + symlink is the owner of the directory. users will also not be
61421 + able to hardlink to files they do not own. If the sysctl option is
61422 + enabled, a sysctl option with name "linking_restrictions" is created.
61423 +
61424 +config GRKERNSEC_SYMLINKOWN
61425 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61426 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61427 + help
61428 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61429 + that prevents it from being used as a security feature. As Apache
61430 + verifies the symlink by performing a stat() against the target of
61431 + the symlink before it is followed, an attacker can setup a symlink
61432 + to point to a same-owned file, then replace the symlink with one
61433 + that targets another user's file just after Apache "validates" the
61434 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61435 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61436 + will be in place for the group you specify. If the sysctl option
61437 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61438 + created.
61439 +
61440 +config GRKERNSEC_SYMLINKOWN_GID
61441 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61442 + depends on GRKERNSEC_SYMLINKOWN
61443 + default 1006
61444 + help
61445 + Setting this GID determines what group kernel-enforced
61446 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61447 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61448 +
61449 +config GRKERNSEC_FIFO
61450 + bool "FIFO restrictions"
61451 + default y if GRKERNSEC_CONFIG_AUTO
61452 + help
61453 + If you say Y here, users will not be able to write to FIFOs they don't
61454 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61455 + the FIFO is the same owner of the directory it's held in. If the sysctl
61456 + option is enabled, a sysctl option with name "fifo_restrictions" is
61457 + created.
61458 +
61459 +config GRKERNSEC_SYSFS_RESTRICT
61460 + bool "Sysfs/debugfs restriction"
61461 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61462 + depends on SYSFS
61463 + help
61464 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61465 + any filesystem normally mounted under it (e.g. debugfs) will be
61466 + mostly accessible only by root. These filesystems generally provide access
61467 + to hardware and debug information that isn't appropriate for unprivileged
61468 + users of the system. Sysfs and debugfs have also become a large source
61469 + of new vulnerabilities, ranging from infoleaks to local compromise.
61470 + There has been very little oversight with an eye toward security involved
61471 + in adding new exporters of information to these filesystems, so their
61472 + use is discouraged.
61473 + For reasons of compatibility, a few directories have been whitelisted
61474 + for access by non-root users:
61475 + /sys/fs/selinux
61476 + /sys/fs/fuse
61477 + /sys/devices/system/cpu
61478 +
61479 +config GRKERNSEC_ROFS
61480 + bool "Runtime read-only mount protection"
61481 + depends on SYSCTL
61482 + help
61483 + If you say Y here, a sysctl option with name "romount_protect" will
61484 + be created. By setting this option to 1 at runtime, filesystems
61485 + will be protected in the following ways:
61486 + * No new writable mounts will be allowed
61487 + * Existing read-only mounts won't be able to be remounted read/write
61488 + * Write operations will be denied on all block devices
61489 + This option acts independently of grsec_lock: once it is set to 1,
61490 + it cannot be turned off. Therefore, please be mindful of the resulting
61491 + behavior if this option is enabled in an init script on a read-only
61492 + filesystem. This feature is mainly intended for secure embedded systems.
61493 +
61494 +config GRKERNSEC_DEVICE_SIDECHANNEL
61495 + bool "Eliminate stat/notify-based device sidechannels"
61496 + default y if GRKERNSEC_CONFIG_AUTO
61497 + help
61498 + If you say Y here, timing analyses on block or character
61499 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61500 + will be thwarted for unprivileged users. If a process without
61501 + CAP_MKNOD stats such a device, the last access and last modify times
61502 + will match the device's create time. No access or modify events
61503 + will be triggered through inotify/dnotify/fanotify for such devices.
61504 + This feature will prevent attacks that may at a minimum
61505 + allow an attacker to determine the administrator's password length.
61506 +
61507 +config GRKERNSEC_CHROOT
61508 + bool "Chroot jail restrictions"
61509 + default y if GRKERNSEC_CONFIG_AUTO
61510 + help
61511 + If you say Y here, you will be able to choose several options that will
61512 + make breaking out of a chrooted jail much more difficult. If you
61513 + encounter no software incompatibilities with the following options, it
61514 + is recommended that you enable each one.
61515 +
61516 +config GRKERNSEC_CHROOT_MOUNT
61517 + bool "Deny mounts"
61518 + default y if GRKERNSEC_CONFIG_AUTO
61519 + depends on GRKERNSEC_CHROOT
61520 + help
61521 + If you say Y here, processes inside a chroot will not be able to
61522 + mount or remount filesystems. If the sysctl option is enabled, a
61523 + sysctl option with name "chroot_deny_mount" is created.
61524 +
61525 +config GRKERNSEC_CHROOT_DOUBLE
61526 + bool "Deny double-chroots"
61527 + default y if GRKERNSEC_CONFIG_AUTO
61528 + depends on GRKERNSEC_CHROOT
61529 + help
61530 + If you say Y here, processes inside a chroot will not be able to chroot
61531 + again outside the chroot. This is a widely used method of breaking
61532 + out of a chroot jail and should not be allowed. If the sysctl
61533 + option is enabled, a sysctl option with name
61534 + "chroot_deny_chroot" is created.
61535 +
61536 +config GRKERNSEC_CHROOT_PIVOT
61537 + bool "Deny pivot_root in chroot"
61538 + default y if GRKERNSEC_CONFIG_AUTO
61539 + depends on GRKERNSEC_CHROOT
61540 + help
61541 + If you say Y here, processes inside a chroot will not be able to use
61542 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61543 + works similar to chroot in that it changes the root filesystem. This
61544 + function could be misused in a chrooted process to attempt to break out
61545 + of the chroot, and therefore should not be allowed. If the sysctl
61546 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61547 + created.
61548 +
61549 +config GRKERNSEC_CHROOT_CHDIR
61550 + bool "Enforce chdir(\"/\") on all chroots"
61551 + default y if GRKERNSEC_CONFIG_AUTO
61552 + depends on GRKERNSEC_CHROOT
61553 + help
61554 + If you say Y here, the current working directory of all newly-chrooted
61555 + applications will be set to the the root directory of the chroot.
61556 + The man page on chroot(2) states:
61557 + Note that this call does not change the current working
61558 + directory, so that `.' can be outside the tree rooted at
61559 + `/'. In particular, the super-user can escape from a
61560 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61561 +
61562 + It is recommended that you say Y here, since it's not known to break
61563 + any software. If the sysctl option is enabled, a sysctl option with
61564 + name "chroot_enforce_chdir" is created.
61565 +
61566 +config GRKERNSEC_CHROOT_CHMOD
61567 + bool "Deny (f)chmod +s"
61568 + default y if GRKERNSEC_CONFIG_AUTO
61569 + depends on GRKERNSEC_CHROOT
61570 + help
61571 + If you say Y here, processes inside a chroot will not be able to chmod
61572 + or fchmod files to make them have suid or sgid bits. This protects
61573 + against another published method of breaking a chroot. If the sysctl
61574 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61575 + created.
61576 +
61577 +config GRKERNSEC_CHROOT_FCHDIR
61578 + bool "Deny fchdir out of chroot"
61579 + default y if GRKERNSEC_CONFIG_AUTO
61580 + depends on GRKERNSEC_CHROOT
61581 + help
61582 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61583 + to a file descriptor of the chrooting process that points to a directory
61584 + outside the filesystem will be stopped. If the sysctl option
61585 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61586 +
61587 +config GRKERNSEC_CHROOT_MKNOD
61588 + bool "Deny mknod"
61589 + default y if GRKERNSEC_CONFIG_AUTO
61590 + depends on GRKERNSEC_CHROOT
61591 + help
61592 + If you say Y here, processes inside a chroot will not be allowed to
61593 + mknod. The problem with using mknod inside a chroot is that it
61594 + would allow an attacker to create a device entry that is the same
61595 + as one on the physical root of your system, which could range from
61596 + anything from the console device to a device for your harddrive (which
61597 + they could then use to wipe the drive or steal data). It is recommended
61598 + that you say Y here, unless you run into software incompatibilities.
61599 + If the sysctl option is enabled, a sysctl option with name
61600 + "chroot_deny_mknod" is created.
61601 +
61602 +config GRKERNSEC_CHROOT_SHMAT
61603 + bool "Deny shmat() out of chroot"
61604 + default y if GRKERNSEC_CONFIG_AUTO
61605 + depends on GRKERNSEC_CHROOT
61606 + help
61607 + If you say Y here, processes inside a chroot will not be able to attach
61608 + to shared memory segments that were created outside of the chroot jail.
61609 + It is recommended that you say Y here. If the sysctl option is enabled,
61610 + a sysctl option with name "chroot_deny_shmat" is created.
61611 +
61612 +config GRKERNSEC_CHROOT_UNIX
61613 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61614 + default y if GRKERNSEC_CONFIG_AUTO
61615 + depends on GRKERNSEC_CHROOT
61616 + help
61617 + If you say Y here, processes inside a chroot will not be able to
61618 + connect to abstract (meaning not belonging to a filesystem) Unix
61619 + domain sockets that were bound outside of a chroot. It is recommended
61620 + that you say Y here. If the sysctl option is enabled, a sysctl option
61621 + with name "chroot_deny_unix" is created.
61622 +
61623 +config GRKERNSEC_CHROOT_FINDTASK
61624 + bool "Protect outside processes"
61625 + default y if GRKERNSEC_CONFIG_AUTO
61626 + depends on GRKERNSEC_CHROOT
61627 + help
61628 + If you say Y here, processes inside a chroot will not be able to
61629 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61630 + getsid, or view any process outside of the chroot. If the sysctl
61631 + option is enabled, a sysctl option with name "chroot_findtask" is
61632 + created.
61633 +
61634 +config GRKERNSEC_CHROOT_NICE
61635 + bool "Restrict priority changes"
61636 + default y if GRKERNSEC_CONFIG_AUTO
61637 + depends on GRKERNSEC_CHROOT
61638 + help
61639 + If you say Y here, processes inside a chroot will not be able to raise
61640 + the priority of processes in the chroot, or alter the priority of
61641 + processes outside the chroot. This provides more security than simply
61642 + removing CAP_SYS_NICE from the process' capability set. If the
61643 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61644 + is created.
61645 +
61646 +config GRKERNSEC_CHROOT_SYSCTL
61647 + bool "Deny sysctl writes"
61648 + default y if GRKERNSEC_CONFIG_AUTO
61649 + depends on GRKERNSEC_CHROOT
61650 + help
61651 + If you say Y here, an attacker in a chroot will not be able to
61652 + write to sysctl entries, either by sysctl(2) or through a /proc
61653 + interface. It is strongly recommended that you say Y here. If the
61654 + sysctl option is enabled, a sysctl option with name
61655 + "chroot_deny_sysctl" is created.
61656 +
61657 +config GRKERNSEC_CHROOT_CAPS
61658 + bool "Capability restrictions"
61659 + default y if GRKERNSEC_CONFIG_AUTO
61660 + depends on GRKERNSEC_CHROOT
61661 + help
61662 + If you say Y here, the capabilities on all processes within a
61663 + chroot jail will be lowered to stop module insertion, raw i/o,
61664 + system and net admin tasks, rebooting the system, modifying immutable
61665 + files, modifying IPC owned by another, and changing the system time.
61666 + This is left an option because it can break some apps. Disable this
61667 + if your chrooted apps are having problems performing those kinds of
61668 + tasks. If the sysctl option is enabled, a sysctl option with
61669 + name "chroot_caps" is created.
61670 +
61671 +config GRKERNSEC_CHROOT_INITRD
61672 + bool "Exempt initrd tasks from restrictions"
61673 + default y if GRKERNSEC_CONFIG_AUTO
61674 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61675 + help
61676 + If you say Y here, tasks started prior to init will be exempted from
61677 + grsecurity's chroot restrictions. This option is mainly meant to
61678 + resolve Plymouth's performing privileged operations unnecessarily
61679 + in a chroot.
61680 +
61681 +endmenu
61682 +menu "Kernel Auditing"
61683 +depends on GRKERNSEC
61684 +
61685 +config GRKERNSEC_AUDIT_GROUP
61686 + bool "Single group for auditing"
61687 + help
61688 + If you say Y here, the exec and chdir logging features will only operate
61689 + on a group you specify. This option is recommended if you only want to
61690 + watch certain users instead of having a large amount of logs from the
61691 + entire system. If the sysctl option is enabled, a sysctl option with
61692 + name "audit_group" is created.
61693 +
61694 +config GRKERNSEC_AUDIT_GID
61695 + int "GID for auditing"
61696 + depends on GRKERNSEC_AUDIT_GROUP
61697 + default 1007
61698 +
61699 +config GRKERNSEC_EXECLOG
61700 + bool "Exec logging"
61701 + help
61702 + If you say Y here, all execve() calls will be logged (since the
61703 + other exec*() calls are frontends to execve(), all execution
61704 + will be logged). Useful for shell-servers that like to keep track
61705 + of their users. If the sysctl option is enabled, a sysctl option with
61706 + name "exec_logging" is created.
61707 + WARNING: This option when enabled will produce a LOT of logs, especially
61708 + on an active system.
61709 +
61710 +config GRKERNSEC_RESLOG
61711 + bool "Resource logging"
61712 + default y if GRKERNSEC_CONFIG_AUTO
61713 + help
61714 + If you say Y here, all attempts to overstep resource limits will
61715 + be logged with the resource name, the requested size, and the current
61716 + limit. It is highly recommended that you say Y here. If the sysctl
61717 + option is enabled, a sysctl option with name "resource_logging" is
61718 + created. If the RBAC system is enabled, the sysctl value is ignored.
61719 +
61720 +config GRKERNSEC_CHROOT_EXECLOG
61721 + bool "Log execs within chroot"
61722 + help
61723 + If you say Y here, all executions inside a chroot jail will be logged
61724 + to syslog. This can cause a large amount of logs if certain
61725 + applications (eg. djb's daemontools) are installed on the system, and
61726 + is therefore left as an option. If the sysctl option is enabled, a
61727 + sysctl option with name "chroot_execlog" is created.
61728 +
61729 +config GRKERNSEC_AUDIT_PTRACE
61730 + bool "Ptrace logging"
61731 + help
61732 + If you say Y here, all attempts to attach to a process via ptrace
61733 + will be logged. If the sysctl option is enabled, a sysctl option
61734 + with name "audit_ptrace" is created.
61735 +
61736 +config GRKERNSEC_AUDIT_CHDIR
61737 + bool "Chdir logging"
61738 + help
61739 + If you say Y here, all chdir() calls will be logged. If the sysctl
61740 + option is enabled, a sysctl option with name "audit_chdir" is created.
61741 +
61742 +config GRKERNSEC_AUDIT_MOUNT
61743 + bool "(Un)Mount logging"
61744 + help
61745 + If you say Y here, all mounts and unmounts will be logged. If the
61746 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61747 + created.
61748 +
61749 +config GRKERNSEC_SIGNAL
61750 + bool "Signal logging"
61751 + default y if GRKERNSEC_CONFIG_AUTO
61752 + help
61753 + If you say Y here, certain important signals will be logged, such as
61754 + SIGSEGV, which will as a result inform you of when a error in a program
61755 + occurred, which in some cases could mean a possible exploit attempt.
61756 + If the sysctl option is enabled, a sysctl option with name
61757 + "signal_logging" is created.
61758 +
61759 +config GRKERNSEC_FORKFAIL
61760 + bool "Fork failure logging"
61761 + help
61762 + If you say Y here, all failed fork() attempts will be logged.
61763 + This could suggest a fork bomb, or someone attempting to overstep
61764 + their process limit. If the sysctl option is enabled, a sysctl option
61765 + with name "forkfail_logging" is created.
61766 +
61767 +config GRKERNSEC_TIME
61768 + bool "Time change logging"
61769 + default y if GRKERNSEC_CONFIG_AUTO
61770 + help
61771 + If you say Y here, any changes of the system clock will be logged.
61772 + If the sysctl option is enabled, a sysctl option with name
61773 + "timechange_logging" is created.
61774 +
61775 +config GRKERNSEC_PROC_IPADDR
61776 + bool "/proc/<pid>/ipaddr support"
61777 + default y if GRKERNSEC_CONFIG_AUTO
61778 + help
61779 + If you say Y here, a new entry will be added to each /proc/<pid>
61780 + directory that contains the IP address of the person using the task.
61781 + The IP is carried across local TCP and AF_UNIX stream sockets.
61782 + This information can be useful for IDS/IPSes to perform remote response
61783 + to a local attack. The entry is readable by only the owner of the
61784 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61785 + the RBAC system), and thus does not create privacy concerns.
61786 +
61787 +config GRKERNSEC_RWXMAP_LOG
61788 + bool 'Denied RWX mmap/mprotect logging'
61789 + default y if GRKERNSEC_CONFIG_AUTO
61790 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61791 + help
61792 + If you say Y here, calls to mmap() and mprotect() with explicit
61793 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61794 + denied by the PAX_MPROTECT feature. This feature will also
61795 + log other problematic scenarios that can occur when PAX_MPROTECT
61796 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61797 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61798 + is created.
61799 +
61800 +endmenu
61801 +
61802 +menu "Executable Protections"
61803 +depends on GRKERNSEC
61804 +
61805 +config GRKERNSEC_DMESG
61806 + bool "Dmesg(8) restriction"
61807 + default y if GRKERNSEC_CONFIG_AUTO
61808 + help
61809 + If you say Y here, non-root users will not be able to use dmesg(8)
61810 + to view the contents of the kernel's circular log buffer.
61811 + The kernel's log buffer often contains kernel addresses and other
61812 + identifying information useful to an attacker in fingerprinting a
61813 + system for a targeted exploit.
61814 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61815 + created.
61816 +
61817 +config GRKERNSEC_HARDEN_PTRACE
61818 + bool "Deter ptrace-based process snooping"
61819 + default y if GRKERNSEC_CONFIG_AUTO
61820 + help
61821 + If you say Y here, TTY sniffers and other malicious monitoring
61822 + programs implemented through ptrace will be defeated. If you
61823 + have been using the RBAC system, this option has already been
61824 + enabled for several years for all users, with the ability to make
61825 + fine-grained exceptions.
61826 +
61827 + This option only affects the ability of non-root users to ptrace
61828 + processes that are not a descendent of the ptracing process.
61829 + This means that strace ./binary and gdb ./binary will still work,
61830 + but attaching to arbitrary processes will not. If the sysctl
61831 + option is enabled, a sysctl option with name "harden_ptrace" is
61832 + created.
61833 +
61834 +config GRKERNSEC_PTRACE_READEXEC
61835 + bool "Require read access to ptrace sensitive binaries"
61836 + default y if GRKERNSEC_CONFIG_AUTO
61837 + help
61838 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61839 + binaries. This option is useful in environments that
61840 + remove the read bits (e.g. file mode 4711) from suid binaries to
61841 + prevent infoleaking of their contents. This option adds
61842 + consistency to the use of that file mode, as the binary could normally
61843 + be read out when run without privileges while ptracing.
61844 +
61845 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61846 + is created.
61847 +
61848 +config GRKERNSEC_SETXID
61849 + bool "Enforce consistent multithreaded privileges"
61850 + default y if GRKERNSEC_CONFIG_AUTO
61851 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61852 + help
61853 + If you say Y here, a change from a root uid to a non-root uid
61854 + in a multithreaded application will cause the resulting uids,
61855 + gids, supplementary groups, and capabilities in that thread
61856 + to be propagated to the other threads of the process. In most
61857 + cases this is unnecessary, as glibc will emulate this behavior
61858 + on behalf of the application. Other libcs do not act in the
61859 + same way, allowing the other threads of the process to continue
61860 + running with root privileges. If the sysctl option is enabled,
61861 + a sysctl option with name "consistent_setxid" is created.
61862 +
61863 +config GRKERNSEC_TPE
61864 + bool "Trusted Path Execution (TPE)"
61865 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61866 + help
61867 + If you say Y here, you will be able to choose a gid to add to the
61868 + supplementary groups of users you want to mark as "untrusted."
61869 + These users will not be able to execute any files that are not in
61870 + root-owned directories writable only by root. If the sysctl option
61871 + is enabled, a sysctl option with name "tpe" is created.
61872 +
61873 +config GRKERNSEC_TPE_ALL
61874 + bool "Partially restrict all non-root users"
61875 + depends on GRKERNSEC_TPE
61876 + help
61877 + If you say Y here, all non-root users will be covered under
61878 + a weaker TPE restriction. This is separate from, and in addition to,
61879 + the main TPE options that you have selected elsewhere. Thus, if a
61880 + "trusted" GID is chosen, this restriction applies to even that GID.
61881 + Under this restriction, all non-root users will only be allowed to
61882 + execute files in directories they own that are not group or
61883 + world-writable, or in directories owned by root and writable only by
61884 + root. If the sysctl option is enabled, a sysctl option with name
61885 + "tpe_restrict_all" is created.
61886 +
61887 +config GRKERNSEC_TPE_INVERT
61888 + bool "Invert GID option"
61889 + depends on GRKERNSEC_TPE
61890 + help
61891 + If you say Y here, the group you specify in the TPE configuration will
61892 + decide what group TPE restrictions will be *disabled* for. This
61893 + option is useful if you want TPE restrictions to be applied to most
61894 + users on the system. If the sysctl option is enabled, a sysctl option
61895 + with name "tpe_invert" is created. Unlike other sysctl options, this
61896 + entry will default to on for backward-compatibility.
61897 +
61898 +config GRKERNSEC_TPE_GID
61899 + int
61900 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61901 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61902 +
61903 +config GRKERNSEC_TPE_UNTRUSTED_GID
61904 + int "GID for TPE-untrusted users"
61905 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61906 + default 1005
61907 + help
61908 + Setting this GID determines what group TPE restrictions will be
61909 + *enabled* for. If the sysctl option is enabled, a sysctl option
61910 + with name "tpe_gid" is created.
61911 +
61912 +config GRKERNSEC_TPE_TRUSTED_GID
61913 + int "GID for TPE-trusted users"
61914 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61915 + default 1005
61916 + help
61917 + Setting this GID determines what group TPE restrictions will be
61918 + *disabled* for. If the sysctl option is enabled, a sysctl option
61919 + with name "tpe_gid" is created.
61920 +
61921 +endmenu
61922 +menu "Network Protections"
61923 +depends on GRKERNSEC
61924 +
61925 +config GRKERNSEC_RANDNET
61926 + bool "Larger entropy pools"
61927 + default y if GRKERNSEC_CONFIG_AUTO
61928 + help
61929 + If you say Y here, the entropy pools used for many features of Linux
61930 + and grsecurity will be doubled in size. Since several grsecurity
61931 + features use additional randomness, it is recommended that you say Y
61932 + here. Saying Y here has a similar effect as modifying
61933 + /proc/sys/kernel/random/poolsize.
61934 +
61935 +config GRKERNSEC_BLACKHOLE
61936 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61937 + default y if GRKERNSEC_CONFIG_AUTO
61938 + depends on NET
61939 + help
61940 + If you say Y here, neither TCP resets nor ICMP
61941 + destination-unreachable packets will be sent in response to packets
61942 + sent to ports for which no associated listening process exists.
61943 + This feature supports both IPV4 and IPV6 and exempts the
61944 + loopback interface from blackholing. Enabling this feature
61945 + makes a host more resilient to DoS attacks and reduces network
61946 + visibility against scanners.
61947 +
61948 + The blackhole feature as-implemented is equivalent to the FreeBSD
61949 + blackhole feature, as it prevents RST responses to all packets, not
61950 + just SYNs. Under most application behavior this causes no
61951 + problems, but applications (like haproxy) may not close certain
61952 + connections in a way that cleanly terminates them on the remote
61953 + end, leaving the remote host in LAST_ACK state. Because of this
61954 + side-effect and to prevent intentional LAST_ACK DoSes, this
61955 + feature also adds automatic mitigation against such attacks.
61956 + The mitigation drastically reduces the amount of time a socket
61957 + can spend in LAST_ACK state. If you're using haproxy and not
61958 + all servers it connects to have this option enabled, consider
61959 + disabling this feature on the haproxy host.
61960 +
61961 + If the sysctl option is enabled, two sysctl options with names
61962 + "ip_blackhole" and "lastack_retries" will be created.
61963 + While "ip_blackhole" takes the standard zero/non-zero on/off
61964 + toggle, "lastack_retries" uses the same kinds of values as
61965 + "tcp_retries1" and "tcp_retries2". The default value of 4
61966 + prevents a socket from lasting more than 45 seconds in LAST_ACK
61967 + state.
61968 +
61969 +config GRKERNSEC_NO_SIMULT_CONNECT
61970 + bool "Disable TCP Simultaneous Connect"
61971 + default y if GRKERNSEC_CONFIG_AUTO
61972 + depends on NET
61973 + help
61974 + If you say Y here, a feature by Willy Tarreau will be enabled that
61975 + removes a weakness in Linux's strict implementation of TCP that
61976 + allows two clients to connect to each other without either entering
61977 + a listening state. The weakness allows an attacker to easily prevent
61978 + a client from connecting to a known server provided the source port
61979 + for the connection is guessed correctly.
61980 +
61981 + As the weakness could be used to prevent an antivirus or IPS from
61982 + fetching updates, or prevent an SSL gateway from fetching a CRL,
61983 + it should be eliminated by enabling this option. Though Linux is
61984 + one of few operating systems supporting simultaneous connect, it
61985 + has no legitimate use in practice and is rarely supported by firewalls.
61986 +
61987 +config GRKERNSEC_SOCKET
61988 + bool "Socket restrictions"
61989 + depends on NET
61990 + help
61991 + If you say Y here, you will be able to choose from several options.
61992 + If you assign a GID on your system and add it to the supplementary
61993 + groups of users you want to restrict socket access to, this patch
61994 + will perform up to three things, based on the option(s) you choose.
61995 +
61996 +config GRKERNSEC_SOCKET_ALL
61997 + bool "Deny any sockets to group"
61998 + depends on GRKERNSEC_SOCKET
61999 + help
62000 + If you say Y here, you will be able to choose a GID of whose users will
62001 + be unable to connect to other hosts from your machine or run server
62002 + applications from your machine. If the sysctl option is enabled, a
62003 + sysctl option with name "socket_all" is created.
62004 +
62005 +config GRKERNSEC_SOCKET_ALL_GID
62006 + int "GID to deny all sockets for"
62007 + depends on GRKERNSEC_SOCKET_ALL
62008 + default 1004
62009 + help
62010 + Here you can choose the GID to disable socket access for. Remember to
62011 + add the users you want socket access disabled for to the GID
62012 + specified here. If the sysctl option is enabled, a sysctl option
62013 + with name "socket_all_gid" is created.
62014 +
62015 +config GRKERNSEC_SOCKET_CLIENT
62016 + bool "Deny client sockets to group"
62017 + depends on GRKERNSEC_SOCKET
62018 + help
62019 + If you say Y here, you will be able to choose a GID of whose users will
62020 + be unable to connect to other hosts from your machine, but will be
62021 + able to run servers. If this option is enabled, all users in the group
62022 + you specify will have to use passive mode when initiating ftp transfers
62023 + from the shell on your machine. If the sysctl option is enabled, a
62024 + sysctl option with name "socket_client" is created.
62025 +
62026 +config GRKERNSEC_SOCKET_CLIENT_GID
62027 + int "GID to deny client sockets for"
62028 + depends on GRKERNSEC_SOCKET_CLIENT
62029 + default 1003
62030 + help
62031 + Here you can choose the GID to disable client socket access for.
62032 + Remember to add the users you want client socket access disabled for to
62033 + the GID specified here. If the sysctl option is enabled, a sysctl
62034 + option with name "socket_client_gid" is created.
62035 +
62036 +config GRKERNSEC_SOCKET_SERVER
62037 + bool "Deny server sockets to group"
62038 + depends on GRKERNSEC_SOCKET
62039 + help
62040 + If you say Y here, you will be able to choose a GID of whose users will
62041 + be unable to run server applications from your machine. If the sysctl
62042 + option is enabled, a sysctl option with name "socket_server" is created.
62043 +
62044 +config GRKERNSEC_SOCKET_SERVER_GID
62045 + int "GID to deny server sockets for"
62046 + depends on GRKERNSEC_SOCKET_SERVER
62047 + default 1002
62048 + help
62049 + Here you can choose the GID to disable server socket access for.
62050 + Remember to add the users you want server socket access disabled for to
62051 + the GID specified here. If the sysctl option is enabled, a sysctl
62052 + option with name "socket_server_gid" is created.
62053 +
62054 +endmenu
62055 +
62056 +menu "Physical Protections"
62057 +depends on GRKERNSEC
62058 +
62059 +config GRKERNSEC_DENYUSB
62060 + bool "Deny new USB connections after toggle"
62061 + default y if GRKERNSEC_CONFIG_AUTO
62062 + depends on SYSCTL && USB_SUPPORT
62063 + help
62064 + If you say Y here, a new sysctl option with name "deny_new_usb"
62065 + will be created. Setting its value to 1 will prevent any new
62066 + USB devices from being recognized by the OS. Any attempted USB
62067 + device insertion will be logged. This option is intended to be
62068 + used against custom USB devices designed to exploit vulnerabilities
62069 + in various USB device drivers.
62070 +
62071 + For greatest effectiveness, this sysctl should be set after any
62072 + relevant init scripts. This option is safe to enable in distros
62073 + as each user can choose whether or not to toggle the sysctl.
62074 +
62075 +config GRKERNSEC_DENYUSB_FORCE
62076 + bool "Reject all USB devices not connected at boot"
62077 + select USB
62078 + depends on GRKERNSEC_DENYUSB
62079 + help
62080 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62081 + that doesn't involve a sysctl entry. This option should only be
62082 + enabled if you're sure you want to deny all new USB connections
62083 + at runtime and don't want to modify init scripts. This should not
62084 + be enabled by distros. It forces the core USB code to be built
62085 + into the kernel image so that all devices connected at boot time
62086 + can be recognized and new USB device connections can be prevented
62087 + prior to init running.
62088 +
62089 +endmenu
62090 +
62091 +menu "Sysctl Support"
62092 +depends on GRKERNSEC && SYSCTL
62093 +
62094 +config GRKERNSEC_SYSCTL
62095 + bool "Sysctl support"
62096 + default y if GRKERNSEC_CONFIG_AUTO
62097 + help
62098 + If you say Y here, you will be able to change the options that
62099 + grsecurity runs with at bootup, without having to recompile your
62100 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62101 + to enable (1) or disable (0) various features. All the sysctl entries
62102 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62103 + All features enabled in the kernel configuration are disabled at boot
62104 + if you do not say Y to the "Turn on features by default" option.
62105 + All options should be set at startup, and the grsec_lock entry should
62106 + be set to a non-zero value after all the options are set.
62107 + *THIS IS EXTREMELY IMPORTANT*
62108 +
62109 +config GRKERNSEC_SYSCTL_DISTRO
62110 + bool "Extra sysctl support for distro makers (READ HELP)"
62111 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62112 + help
62113 + If you say Y here, additional sysctl options will be created
62114 + for features that affect processes running as root. Therefore,
62115 + it is critical when using this option that the grsec_lock entry be
62116 + enabled after boot. Only distros with prebuilt kernel packages
62117 + with this option enabled that can ensure grsec_lock is enabled
62118 + after boot should use this option.
62119 + *Failure to set grsec_lock after boot makes all grsec features
62120 + this option covers useless*
62121 +
62122 + Currently this option creates the following sysctl entries:
62123 + "Disable Privileged I/O": "disable_priv_io"
62124 +
62125 +config GRKERNSEC_SYSCTL_ON
62126 + bool "Turn on features by default"
62127 + default y if GRKERNSEC_CONFIG_AUTO
62128 + depends on GRKERNSEC_SYSCTL
62129 + help
62130 + If you say Y here, instead of having all features enabled in the
62131 + kernel configuration disabled at boot time, the features will be
62132 + enabled at boot time. It is recommended you say Y here unless
62133 + there is some reason you would want all sysctl-tunable features to
62134 + be disabled by default. As mentioned elsewhere, it is important
62135 + to enable the grsec_lock entry once you have finished modifying
62136 + the sysctl entries.
62137 +
62138 +endmenu
62139 +menu "Logging Options"
62140 +depends on GRKERNSEC
62141 +
62142 +config GRKERNSEC_FLOODTIME
62143 + int "Seconds in between log messages (minimum)"
62144 + default 10
62145 + help
62146 + This option allows you to enforce the number of seconds between
62147 + grsecurity log messages. The default should be suitable for most
62148 + people, however, if you choose to change it, choose a value small enough
62149 + to allow informative logs to be produced, but large enough to
62150 + prevent flooding.
62151 +
62152 +config GRKERNSEC_FLOODBURST
62153 + int "Number of messages in a burst (maximum)"
62154 + default 6
62155 + help
62156 + This option allows you to choose the maximum number of messages allowed
62157 + within the flood time interval you chose in a separate option. The
62158 + default should be suitable for most people, however if you find that
62159 + many of your logs are being interpreted as flooding, you may want to
62160 + raise this value.
62161 +
62162 +endmenu
62163 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62164 new file mode 100644
62165 index 0000000..b0b77d5
62166 --- /dev/null
62167 +++ b/grsecurity/Makefile
62168 @@ -0,0 +1,43 @@
62169 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62170 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62171 +# into an RBAC system
62172 +#
62173 +# All code in this directory and various hooks inserted throughout the kernel
62174 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62175 +# under the GPL v2 or higher
62176 +
62177 +KBUILD_CFLAGS += -Werror
62178 +
62179 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62180 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62181 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62182 + grsec_usb.o
62183 +
62184 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62185 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62186 + gracl_learn.o grsec_log.o
62187 +ifdef CONFIG_COMPAT
62188 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62189 +endif
62190 +
62191 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62192 +
62193 +ifdef CONFIG_NET
62194 +obj-y += grsec_sock.o
62195 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62196 +endif
62197 +
62198 +ifndef CONFIG_GRKERNSEC
62199 +obj-y += grsec_disabled.o
62200 +endif
62201 +
62202 +ifdef CONFIG_GRKERNSEC_HIDESYM
62203 +extra-y := grsec_hidesym.o
62204 +$(obj)/grsec_hidesym.o:
62205 + @-chmod -f 500 /boot
62206 + @-chmod -f 500 /lib/modules
62207 + @-chmod -f 500 /lib64/modules
62208 + @-chmod -f 500 /lib32/modules
62209 + @-chmod -f 700 .
62210 + @echo ' grsec: protected kernel image paths'
62211 +endif
62212 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62213 new file mode 100644
62214 index 0000000..c0793fd
62215 --- /dev/null
62216 +++ b/grsecurity/gracl.c
62217 @@ -0,0 +1,4178 @@
62218 +#include <linux/kernel.h>
62219 +#include <linux/module.h>
62220 +#include <linux/sched.h>
62221 +#include <linux/mm.h>
62222 +#include <linux/file.h>
62223 +#include <linux/fs.h>
62224 +#include <linux/namei.h>
62225 +#include <linux/mount.h>
62226 +#include <linux/tty.h>
62227 +#include <linux/proc_fs.h>
62228 +#include <linux/lglock.h>
62229 +#include <linux/slab.h>
62230 +#include <linux/vmalloc.h>
62231 +#include <linux/types.h>
62232 +#include <linux/sysctl.h>
62233 +#include <linux/netdevice.h>
62234 +#include <linux/ptrace.h>
62235 +#include <linux/gracl.h>
62236 +#include <linux/gralloc.h>
62237 +#include <linux/security.h>
62238 +#include <linux/grinternal.h>
62239 +#include <linux/pid_namespace.h>
62240 +#include <linux/stop_machine.h>
62241 +#include <linux/fdtable.h>
62242 +#include <linux/percpu.h>
62243 +#include <linux/lglock.h>
62244 +#include <linux/hugetlb.h>
62245 +#include <linux/posix-timers.h>
62246 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62247 +#include <linux/magic.h>
62248 +#include <linux/pagemap.h>
62249 +#include "../fs/btrfs/async-thread.h"
62250 +#include "../fs/btrfs/ctree.h"
62251 +#include "../fs/btrfs/btrfs_inode.h"
62252 +#endif
62253 +#include "../fs/mount.h"
62254 +
62255 +#include <asm/uaccess.h>
62256 +#include <asm/errno.h>
62257 +#include <asm/mman.h>
62258 +
62259 +extern struct lglock vfsmount_lock;
62260 +
62261 +static struct acl_role_db acl_role_set;
62262 +static struct name_db name_set;
62263 +static struct inodev_db inodev_set;
62264 +
62265 +/* for keeping track of userspace pointers used for subjects, so we
62266 + can share references in the kernel as well
62267 +*/
62268 +
62269 +static struct path real_root;
62270 +
62271 +static struct acl_subj_map_db subj_map_set;
62272 +
62273 +static struct acl_role_label *default_role;
62274 +
62275 +static struct acl_role_label *role_list;
62276 +
62277 +static u16 acl_sp_role_value;
62278 +
62279 +extern char *gr_shared_page[4];
62280 +static DEFINE_MUTEX(gr_dev_mutex);
62281 +DEFINE_RWLOCK(gr_inode_lock);
62282 +
62283 +struct gr_arg *gr_usermode;
62284 +
62285 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62286 +
62287 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
62288 +extern void gr_clear_learn_entries(void);
62289 +
62290 +unsigned char *gr_system_salt;
62291 +unsigned char *gr_system_sum;
62292 +
62293 +static struct sprole_pw **acl_special_roles = NULL;
62294 +static __u16 num_sprole_pws = 0;
62295 +
62296 +static struct acl_role_label *kernel_role = NULL;
62297 +
62298 +static unsigned int gr_auth_attempts = 0;
62299 +static unsigned long gr_auth_expires = 0UL;
62300 +
62301 +#ifdef CONFIG_NET
62302 +extern struct vfsmount *sock_mnt;
62303 +#endif
62304 +
62305 +extern struct vfsmount *pipe_mnt;
62306 +extern struct vfsmount *shm_mnt;
62307 +
62308 +#ifdef CONFIG_HUGETLBFS
62309 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62310 +#endif
62311 +
62312 +static struct acl_object_label *fakefs_obj_rw;
62313 +static struct acl_object_label *fakefs_obj_rwx;
62314 +
62315 +extern int gr_init_uidset(void);
62316 +extern void gr_free_uidset(void);
62317 +extern void gr_remove_uid(uid_t uid);
62318 +extern int gr_find_uid(uid_t uid);
62319 +
62320 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
62321 +{
62322 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
62323 + return -EFAULT;
62324 +
62325 + return 0;
62326 +}
62327 +
62328 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
62329 +{
62330 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
62331 + return -EFAULT;
62332 +
62333 + return 0;
62334 +}
62335 +
62336 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62337 +{
62338 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
62339 + return -EFAULT;
62340 +
62341 + return 0;
62342 +}
62343 +
62344 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
62345 +{
62346 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
62347 + return -EFAULT;
62348 +
62349 + return 0;
62350 +}
62351 +
62352 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
62353 +{
62354 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
62355 + return -EFAULT;
62356 +
62357 + return 0;
62358 +}
62359 +
62360 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
62361 +{
62362 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
62363 + return -EFAULT;
62364 +
62365 + return 0;
62366 +}
62367 +
62368 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
62369 +{
62370 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
62371 + return -EFAULT;
62372 +
62373 + return 0;
62374 +}
62375 +
62376 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
62377 +{
62378 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
62379 + return -EFAULT;
62380 +
62381 + return 0;
62382 +}
62383 +
62384 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
62385 +{
62386 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
62387 + return -EFAULT;
62388 +
62389 + return 0;
62390 +}
62391 +
62392 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62393 +{
62394 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62395 + return -EFAULT;
62396 +
62397 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62398 + return -EINVAL;
62399 +
62400 + return 0;
62401 +}
62402 +
62403 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62404 +{
62405 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62406 + return -EFAULT;
62407 +
62408 + return 0;
62409 +}
62410 +
62411 +static size_t get_gr_arg_wrapper_size_normal(void)
62412 +{
62413 + return sizeof(struct gr_arg_wrapper);
62414 +}
62415 +
62416 +#ifdef CONFIG_COMPAT
62417 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62418 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62419 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62420 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62421 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62422 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62423 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62424 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62425 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62426 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62427 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62428 +extern size_t get_gr_arg_wrapper_size_compat(void);
62429 +
62430 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62431 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62432 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62433 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62434 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62435 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62436 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62437 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62438 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62439 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62440 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62441 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62442 +
62443 +#else
62444 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62445 +#define copy_gr_arg copy_gr_arg_normal
62446 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62447 +#define copy_acl_object_label copy_acl_object_label_normal
62448 +#define copy_acl_subject_label copy_acl_subject_label_normal
62449 +#define copy_acl_role_label copy_acl_role_label_normal
62450 +#define copy_acl_ip_label copy_acl_ip_label_normal
62451 +#define copy_pointer_from_array copy_pointer_from_array_normal
62452 +#define copy_sprole_pw copy_sprole_pw_normal
62453 +#define copy_role_transition copy_role_transition_normal
62454 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62455 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62456 +#endif
62457 +
62458 +__inline__ int
62459 +gr_acl_is_enabled(void)
62460 +{
62461 + return (gr_status & GR_READY);
62462 +}
62463 +
62464 +static inline dev_t __get_dev(const struct dentry *dentry)
62465 +{
62466 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62467 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62468 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62469 + else
62470 +#endif
62471 + return dentry->d_sb->s_dev;
62472 +}
62473 +
62474 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62475 +{
62476 + return __get_dev(dentry);
62477 +}
62478 +
62479 +static char gr_task_roletype_to_char(struct task_struct *task)
62480 +{
62481 + switch (task->role->roletype &
62482 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62483 + GR_ROLE_SPECIAL)) {
62484 + case GR_ROLE_DEFAULT:
62485 + return 'D';
62486 + case GR_ROLE_USER:
62487 + return 'U';
62488 + case GR_ROLE_GROUP:
62489 + return 'G';
62490 + case GR_ROLE_SPECIAL:
62491 + return 'S';
62492 + }
62493 +
62494 + return 'X';
62495 +}
62496 +
62497 +char gr_roletype_to_char(void)
62498 +{
62499 + return gr_task_roletype_to_char(current);
62500 +}
62501 +
62502 +__inline__ int
62503 +gr_acl_tpe_check(void)
62504 +{
62505 + if (unlikely(!(gr_status & GR_READY)))
62506 + return 0;
62507 + if (current->role->roletype & GR_ROLE_TPE)
62508 + return 1;
62509 + else
62510 + return 0;
62511 +}
62512 +
62513 +int
62514 +gr_handle_rawio(const struct inode *inode)
62515 +{
62516 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62517 + if (inode && S_ISBLK(inode->i_mode) &&
62518 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62519 + !capable(CAP_SYS_RAWIO))
62520 + return 1;
62521 +#endif
62522 + return 0;
62523 +}
62524 +
62525 +static int
62526 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62527 +{
62528 + if (likely(lena != lenb))
62529 + return 0;
62530 +
62531 + return !memcmp(a, b, lena);
62532 +}
62533 +
62534 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62535 +{
62536 + *buflen -= namelen;
62537 + if (*buflen < 0)
62538 + return -ENAMETOOLONG;
62539 + *buffer -= namelen;
62540 + memcpy(*buffer, str, namelen);
62541 + return 0;
62542 +}
62543 +
62544 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62545 +{
62546 + return prepend(buffer, buflen, name->name, name->len);
62547 +}
62548 +
62549 +static int prepend_path(const struct path *path, struct path *root,
62550 + char **buffer, int *buflen)
62551 +{
62552 + struct dentry *dentry = path->dentry;
62553 + struct vfsmount *vfsmnt = path->mnt;
62554 + struct mount *mnt = real_mount(vfsmnt);
62555 + bool slash = false;
62556 + int error = 0;
62557 +
62558 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62559 + struct dentry * parent;
62560 +
62561 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62562 + /* Global root? */
62563 + if (!mnt_has_parent(mnt)) {
62564 + goto out;
62565 + }
62566 + dentry = mnt->mnt_mountpoint;
62567 + mnt = mnt->mnt_parent;
62568 + vfsmnt = &mnt->mnt;
62569 + continue;
62570 + }
62571 + parent = dentry->d_parent;
62572 + prefetch(parent);
62573 + spin_lock(&dentry->d_lock);
62574 + error = prepend_name(buffer, buflen, &dentry->d_name);
62575 + spin_unlock(&dentry->d_lock);
62576 + if (!error)
62577 + error = prepend(buffer, buflen, "/", 1);
62578 + if (error)
62579 + break;
62580 +
62581 + slash = true;
62582 + dentry = parent;
62583 + }
62584 +
62585 +out:
62586 + if (!error && !slash)
62587 + error = prepend(buffer, buflen, "/", 1);
62588 +
62589 + return error;
62590 +}
62591 +
62592 +/* this must be called with vfsmount_lock and rename_lock held */
62593 +
62594 +static char *__our_d_path(const struct path *path, struct path *root,
62595 + char *buf, int buflen)
62596 +{
62597 + char *res = buf + buflen;
62598 + int error;
62599 +
62600 + prepend(&res, &buflen, "\0", 1);
62601 + error = prepend_path(path, root, &res, &buflen);
62602 + if (error)
62603 + return ERR_PTR(error);
62604 +
62605 + return res;
62606 +}
62607 +
62608 +static char *
62609 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62610 +{
62611 + char *retval;
62612 +
62613 + retval = __our_d_path(path, root, buf, buflen);
62614 + if (unlikely(IS_ERR(retval)))
62615 + retval = strcpy(buf, "<path too long>");
62616 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62617 + retval[1] = '\0';
62618 +
62619 + return retval;
62620 +}
62621 +
62622 +static char *
62623 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62624 + char *buf, int buflen)
62625 +{
62626 + struct path path;
62627 + char *res;
62628 +
62629 + path.dentry = (struct dentry *)dentry;
62630 + path.mnt = (struct vfsmount *)vfsmnt;
62631 +
62632 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62633 + by the RBAC system */
62634 + res = gen_full_path(&path, &real_root, buf, buflen);
62635 +
62636 + return res;
62637 +}
62638 +
62639 +static char *
62640 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62641 + char *buf, int buflen)
62642 +{
62643 + char *res;
62644 + struct path path;
62645 + struct path root;
62646 + struct task_struct *reaper = init_pid_ns.child_reaper;
62647 +
62648 + path.dentry = (struct dentry *)dentry;
62649 + path.mnt = (struct vfsmount *)vfsmnt;
62650 +
62651 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62652 + get_fs_root(reaper->fs, &root);
62653 +
62654 + br_read_lock(&vfsmount_lock);
62655 + write_seqlock(&rename_lock);
62656 + res = gen_full_path(&path, &root, buf, buflen);
62657 + write_sequnlock(&rename_lock);
62658 + br_read_unlock(&vfsmount_lock);
62659 +
62660 + path_put(&root);
62661 + return res;
62662 +}
62663 +
62664 +static char *
62665 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62666 +{
62667 + char *ret;
62668 + br_read_lock(&vfsmount_lock);
62669 + write_seqlock(&rename_lock);
62670 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62671 + PAGE_SIZE);
62672 + write_sequnlock(&rename_lock);
62673 + br_read_unlock(&vfsmount_lock);
62674 + return ret;
62675 +}
62676 +
62677 +static char *
62678 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62679 +{
62680 + char *ret;
62681 + char *buf;
62682 + int buflen;
62683 +
62684 + br_read_lock(&vfsmount_lock);
62685 + write_seqlock(&rename_lock);
62686 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62687 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62688 + buflen = (int)(ret - buf);
62689 + if (buflen >= 5)
62690 + prepend(&ret, &buflen, "/proc", 5);
62691 + else
62692 + ret = strcpy(buf, "<path too long>");
62693 + write_sequnlock(&rename_lock);
62694 + br_read_unlock(&vfsmount_lock);
62695 + return ret;
62696 +}
62697 +
62698 +char *
62699 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62700 +{
62701 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62702 + PAGE_SIZE);
62703 +}
62704 +
62705 +char *
62706 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62707 +{
62708 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62709 + PAGE_SIZE);
62710 +}
62711 +
62712 +char *
62713 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62714 +{
62715 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62716 + PAGE_SIZE);
62717 +}
62718 +
62719 +char *
62720 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62721 +{
62722 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62723 + PAGE_SIZE);
62724 +}
62725 +
62726 +char *
62727 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62728 +{
62729 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62730 + PAGE_SIZE);
62731 +}
62732 +
62733 +__inline__ __u32
62734 +to_gr_audit(const __u32 reqmode)
62735 +{
62736 + /* masks off auditable permission flags, then shifts them to create
62737 + auditing flags, and adds the special case of append auditing if
62738 + we're requesting write */
62739 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62740 +}
62741 +
62742 +struct acl_subject_label *
62743 +lookup_subject_map(const struct acl_subject_label *userp)
62744 +{
62745 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62746 + struct subject_map *match;
62747 +
62748 + match = subj_map_set.s_hash[index];
62749 +
62750 + while (match && match->user != userp)
62751 + match = match->next;
62752 +
62753 + if (match != NULL)
62754 + return match->kernel;
62755 + else
62756 + return NULL;
62757 +}
62758 +
62759 +static void
62760 +insert_subj_map_entry(struct subject_map *subjmap)
62761 +{
62762 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62763 + struct subject_map **curr;
62764 +
62765 + subjmap->prev = NULL;
62766 +
62767 + curr = &subj_map_set.s_hash[index];
62768 + if (*curr != NULL)
62769 + (*curr)->prev = subjmap;
62770 +
62771 + subjmap->next = *curr;
62772 + *curr = subjmap;
62773 +
62774 + return;
62775 +}
62776 +
62777 +static struct acl_role_label *
62778 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62779 + const gid_t gid)
62780 +{
62781 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62782 + struct acl_role_label *match;
62783 + struct role_allowed_ip *ipp;
62784 + unsigned int x;
62785 + u32 curr_ip = task->signal->curr_ip;
62786 +
62787 + task->signal->saved_ip = curr_ip;
62788 +
62789 + match = acl_role_set.r_hash[index];
62790 +
62791 + while (match) {
62792 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62793 + for (x = 0; x < match->domain_child_num; x++) {
62794 + if (match->domain_children[x] == uid)
62795 + goto found;
62796 + }
62797 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62798 + break;
62799 + match = match->next;
62800 + }
62801 +found:
62802 + if (match == NULL) {
62803 + try_group:
62804 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62805 + match = acl_role_set.r_hash[index];
62806 +
62807 + while (match) {
62808 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62809 + for (x = 0; x < match->domain_child_num; x++) {
62810 + if (match->domain_children[x] == gid)
62811 + goto found2;
62812 + }
62813 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62814 + break;
62815 + match = match->next;
62816 + }
62817 +found2:
62818 + if (match == NULL)
62819 + match = default_role;
62820 + if (match->allowed_ips == NULL)
62821 + return match;
62822 + else {
62823 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62824 + if (likely
62825 + ((ntohl(curr_ip) & ipp->netmask) ==
62826 + (ntohl(ipp->addr) & ipp->netmask)))
62827 + return match;
62828 + }
62829 + match = default_role;
62830 + }
62831 + } else if (match->allowed_ips == NULL) {
62832 + return match;
62833 + } else {
62834 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62835 + if (likely
62836 + ((ntohl(curr_ip) & ipp->netmask) ==
62837 + (ntohl(ipp->addr) & ipp->netmask)))
62838 + return match;
62839 + }
62840 + goto try_group;
62841 + }
62842 +
62843 + return match;
62844 +}
62845 +
62846 +struct acl_subject_label *
62847 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62848 + const struct acl_role_label *role)
62849 +{
62850 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62851 + struct acl_subject_label *match;
62852 +
62853 + match = role->subj_hash[index];
62854 +
62855 + while (match && (match->inode != ino || match->device != dev ||
62856 + (match->mode & GR_DELETED))) {
62857 + match = match->next;
62858 + }
62859 +
62860 + if (match && !(match->mode & GR_DELETED))
62861 + return match;
62862 + else
62863 + return NULL;
62864 +}
62865 +
62866 +struct acl_subject_label *
62867 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62868 + const struct acl_role_label *role)
62869 +{
62870 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62871 + struct acl_subject_label *match;
62872 +
62873 + match = role->subj_hash[index];
62874 +
62875 + while (match && (match->inode != ino || match->device != dev ||
62876 + !(match->mode & GR_DELETED))) {
62877 + match = match->next;
62878 + }
62879 +
62880 + if (match && (match->mode & GR_DELETED))
62881 + return match;
62882 + else
62883 + return NULL;
62884 +}
62885 +
62886 +static struct acl_object_label *
62887 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62888 + const struct acl_subject_label *subj)
62889 +{
62890 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62891 + struct acl_object_label *match;
62892 +
62893 + match = subj->obj_hash[index];
62894 +
62895 + while (match && (match->inode != ino || match->device != dev ||
62896 + (match->mode & GR_DELETED))) {
62897 + match = match->next;
62898 + }
62899 +
62900 + if (match && !(match->mode & GR_DELETED))
62901 + return match;
62902 + else
62903 + return NULL;
62904 +}
62905 +
62906 +static struct acl_object_label *
62907 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62908 + const struct acl_subject_label *subj)
62909 +{
62910 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62911 + struct acl_object_label *match;
62912 +
62913 + match = subj->obj_hash[index];
62914 +
62915 + while (match && (match->inode != ino || match->device != dev ||
62916 + !(match->mode & GR_DELETED))) {
62917 + match = match->next;
62918 + }
62919 +
62920 + if (match && (match->mode & GR_DELETED))
62921 + return match;
62922 +
62923 + match = subj->obj_hash[index];
62924 +
62925 + while (match && (match->inode != ino || match->device != dev ||
62926 + (match->mode & GR_DELETED))) {
62927 + match = match->next;
62928 + }
62929 +
62930 + if (match && !(match->mode & GR_DELETED))
62931 + return match;
62932 + else
62933 + return NULL;
62934 +}
62935 +
62936 +static struct name_entry *
62937 +lookup_name_entry(const char *name)
62938 +{
62939 + unsigned int len = strlen(name);
62940 + unsigned int key = full_name_hash(name, len);
62941 + unsigned int index = key % name_set.n_size;
62942 + struct name_entry *match;
62943 +
62944 + match = name_set.n_hash[index];
62945 +
62946 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
62947 + match = match->next;
62948 +
62949 + return match;
62950 +}
62951 +
62952 +static struct name_entry *
62953 +lookup_name_entry_create(const char *name)
62954 +{
62955 + unsigned int len = strlen(name);
62956 + unsigned int key = full_name_hash(name, len);
62957 + unsigned int index = key % name_set.n_size;
62958 + struct name_entry *match;
62959 +
62960 + match = name_set.n_hash[index];
62961 +
62962 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62963 + !match->deleted))
62964 + match = match->next;
62965 +
62966 + if (match && match->deleted)
62967 + return match;
62968 +
62969 + match = name_set.n_hash[index];
62970 +
62971 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62972 + match->deleted))
62973 + match = match->next;
62974 +
62975 + if (match && !match->deleted)
62976 + return match;
62977 + else
62978 + return NULL;
62979 +}
62980 +
62981 +static struct inodev_entry *
62982 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
62983 +{
62984 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
62985 + struct inodev_entry *match;
62986 +
62987 + match = inodev_set.i_hash[index];
62988 +
62989 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
62990 + match = match->next;
62991 +
62992 + return match;
62993 +}
62994 +
62995 +static void
62996 +insert_inodev_entry(struct inodev_entry *entry)
62997 +{
62998 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
62999 + inodev_set.i_size);
63000 + struct inodev_entry **curr;
63001 +
63002 + entry->prev = NULL;
63003 +
63004 + curr = &inodev_set.i_hash[index];
63005 + if (*curr != NULL)
63006 + (*curr)->prev = entry;
63007 +
63008 + entry->next = *curr;
63009 + *curr = entry;
63010 +
63011 + return;
63012 +}
63013 +
63014 +static void
63015 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
63016 +{
63017 + unsigned int index =
63018 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
63019 + struct acl_role_label **curr;
63020 + struct acl_role_label *tmp, *tmp2;
63021 +
63022 + curr = &acl_role_set.r_hash[index];
63023 +
63024 + /* simple case, slot is empty, just set it to our role */
63025 + if (*curr == NULL) {
63026 + *curr = role;
63027 + } else {
63028 + /* example:
63029 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
63030 + 2 -> 3
63031 + */
63032 + /* first check to see if we can already be reached via this slot */
63033 + tmp = *curr;
63034 + while (tmp && tmp != role)
63035 + tmp = tmp->next;
63036 + if (tmp == role) {
63037 + /* we don't need to add ourselves to this slot's chain */
63038 + return;
63039 + }
63040 + /* we need to add ourselves to this chain, two cases */
63041 + if (role->next == NULL) {
63042 + /* simple case, append the current chain to our role */
63043 + role->next = *curr;
63044 + *curr = role;
63045 + } else {
63046 + /* 1 -> 2 -> 3 -> 4
63047 + 2 -> 3 -> 4
63048 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
63049 + */
63050 + /* trickier case: walk our role's chain until we find
63051 + the role for the start of the current slot's chain */
63052 + tmp = role;
63053 + tmp2 = *curr;
63054 + while (tmp->next && tmp->next != tmp2)
63055 + tmp = tmp->next;
63056 + if (tmp->next == tmp2) {
63057 + /* from example above, we found 3, so just
63058 + replace this slot's chain with ours */
63059 + *curr = role;
63060 + } else {
63061 + /* we didn't find a subset of our role's chain
63062 + in the current slot's chain, so append their
63063 + chain to ours, and set us as the first role in
63064 + the slot's chain
63065 +
63066 + we could fold this case with the case above,
63067 + but making it explicit for clarity
63068 + */
63069 + tmp->next = tmp2;
63070 + *curr = role;
63071 + }
63072 + }
63073 + }
63074 +
63075 + return;
63076 +}
63077 +
63078 +static void
63079 +insert_acl_role_label(struct acl_role_label *role)
63080 +{
63081 + int i;
63082 +
63083 + if (role_list == NULL) {
63084 + role_list = role;
63085 + role->prev = NULL;
63086 + } else {
63087 + role->prev = role_list;
63088 + role_list = role;
63089 + }
63090 +
63091 + /* used for hash chains */
63092 + role->next = NULL;
63093 +
63094 + if (role->roletype & GR_ROLE_DOMAIN) {
63095 + for (i = 0; i < role->domain_child_num; i++)
63096 + __insert_acl_role_label(role, role->domain_children[i]);
63097 + } else
63098 + __insert_acl_role_label(role, role->uidgid);
63099 +}
63100 +
63101 +static int
63102 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
63103 +{
63104 + struct name_entry **curr, *nentry;
63105 + struct inodev_entry *ientry;
63106 + unsigned int len = strlen(name);
63107 + unsigned int key = full_name_hash(name, len);
63108 + unsigned int index = key % name_set.n_size;
63109 +
63110 + curr = &name_set.n_hash[index];
63111 +
63112 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
63113 + curr = &((*curr)->next);
63114 +
63115 + if (*curr != NULL)
63116 + return 1;
63117 +
63118 + nentry = acl_alloc(sizeof (struct name_entry));
63119 + if (nentry == NULL)
63120 + return 0;
63121 + ientry = acl_alloc(sizeof (struct inodev_entry));
63122 + if (ientry == NULL)
63123 + return 0;
63124 + ientry->nentry = nentry;
63125 +
63126 + nentry->key = key;
63127 + nentry->name = name;
63128 + nentry->inode = inode;
63129 + nentry->device = device;
63130 + nentry->len = len;
63131 + nentry->deleted = deleted;
63132 +
63133 + nentry->prev = NULL;
63134 + curr = &name_set.n_hash[index];
63135 + if (*curr != NULL)
63136 + (*curr)->prev = nentry;
63137 + nentry->next = *curr;
63138 + *curr = nentry;
63139 +
63140 + /* insert us into the table searchable by inode/dev */
63141 + insert_inodev_entry(ientry);
63142 +
63143 + return 1;
63144 +}
63145 +
63146 +static void
63147 +insert_acl_obj_label(struct acl_object_label *obj,
63148 + struct acl_subject_label *subj)
63149 +{
63150 + unsigned int index =
63151 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63152 + struct acl_object_label **curr;
63153 +
63154 +
63155 + obj->prev = NULL;
63156 +
63157 + curr = &subj->obj_hash[index];
63158 + if (*curr != NULL)
63159 + (*curr)->prev = obj;
63160 +
63161 + obj->next = *curr;
63162 + *curr = obj;
63163 +
63164 + return;
63165 +}
63166 +
63167 +static void
63168 +insert_acl_subj_label(struct acl_subject_label *obj,
63169 + struct acl_role_label *role)
63170 +{
63171 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63172 + struct acl_subject_label **curr;
63173 +
63174 + obj->prev = NULL;
63175 +
63176 + curr = &role->subj_hash[index];
63177 + if (*curr != NULL)
63178 + (*curr)->prev = obj;
63179 +
63180 + obj->next = *curr;
63181 + *curr = obj;
63182 +
63183 + return;
63184 +}
63185 +
63186 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
63187 +
63188 +static void *
63189 +create_table(__u32 * len, int elementsize)
63190 +{
63191 + unsigned int table_sizes[] = {
63192 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
63193 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
63194 + 4194301, 8388593, 16777213, 33554393, 67108859
63195 + };
63196 + void *newtable = NULL;
63197 + unsigned int pwr = 0;
63198 +
63199 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
63200 + table_sizes[pwr] <= *len)
63201 + pwr++;
63202 +
63203 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
63204 + return newtable;
63205 +
63206 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
63207 + newtable =
63208 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
63209 + else
63210 + newtable = vmalloc(table_sizes[pwr] * elementsize);
63211 +
63212 + *len = table_sizes[pwr];
63213 +
63214 + return newtable;
63215 +}
63216 +
63217 +static int
63218 +init_variables(const struct gr_arg *arg)
63219 +{
63220 + struct task_struct *reaper = init_pid_ns.child_reaper;
63221 + unsigned int stacksize;
63222 +
63223 + subj_map_set.s_size = arg->role_db.num_subjects;
63224 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
63225 + name_set.n_size = arg->role_db.num_objects;
63226 + inodev_set.i_size = arg->role_db.num_objects;
63227 +
63228 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
63229 + !name_set.n_size || !inodev_set.i_size)
63230 + return 1;
63231 +
63232 + if (!gr_init_uidset())
63233 + return 1;
63234 +
63235 + /* set up the stack that holds allocation info */
63236 +
63237 + stacksize = arg->role_db.num_pointers + 5;
63238 +
63239 + if (!acl_alloc_stack_init(stacksize))
63240 + return 1;
63241 +
63242 + /* grab reference for the real root dentry and vfsmount */
63243 + get_fs_root(reaper->fs, &real_root);
63244 +
63245 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63246 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
63247 +#endif
63248 +
63249 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
63250 + if (fakefs_obj_rw == NULL)
63251 + return 1;
63252 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
63253 +
63254 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
63255 + if (fakefs_obj_rwx == NULL)
63256 + return 1;
63257 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
63258 +
63259 + subj_map_set.s_hash =
63260 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
63261 + acl_role_set.r_hash =
63262 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
63263 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
63264 + inodev_set.i_hash =
63265 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
63266 +
63267 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
63268 + !name_set.n_hash || !inodev_set.i_hash)
63269 + return 1;
63270 +
63271 + memset(subj_map_set.s_hash, 0,
63272 + sizeof(struct subject_map *) * subj_map_set.s_size);
63273 + memset(acl_role_set.r_hash, 0,
63274 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
63275 + memset(name_set.n_hash, 0,
63276 + sizeof (struct name_entry *) * name_set.n_size);
63277 + memset(inodev_set.i_hash, 0,
63278 + sizeof (struct inodev_entry *) * inodev_set.i_size);
63279 +
63280 + return 0;
63281 +}
63282 +
63283 +/* free information not needed after startup
63284 + currently contains user->kernel pointer mappings for subjects
63285 +*/
63286 +
63287 +static void
63288 +free_init_variables(void)
63289 +{
63290 + __u32 i;
63291 +
63292 + if (subj_map_set.s_hash) {
63293 + for (i = 0; i < subj_map_set.s_size; i++) {
63294 + if (subj_map_set.s_hash[i]) {
63295 + kfree(subj_map_set.s_hash[i]);
63296 + subj_map_set.s_hash[i] = NULL;
63297 + }
63298 + }
63299 +
63300 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
63301 + PAGE_SIZE)
63302 + kfree(subj_map_set.s_hash);
63303 + else
63304 + vfree(subj_map_set.s_hash);
63305 + }
63306 +
63307 + return;
63308 +}
63309 +
63310 +static void
63311 +free_variables(void)
63312 +{
63313 + struct acl_subject_label *s;
63314 + struct acl_role_label *r;
63315 + struct task_struct *task, *task2;
63316 + unsigned int x;
63317 +
63318 + gr_clear_learn_entries();
63319 +
63320 + read_lock(&tasklist_lock);
63321 + do_each_thread(task2, task) {
63322 + task->acl_sp_role = 0;
63323 + task->acl_role_id = 0;
63324 + task->acl = NULL;
63325 + task->role = NULL;
63326 + } while_each_thread(task2, task);
63327 + read_unlock(&tasklist_lock);
63328 +
63329 + /* release the reference to the real root dentry and vfsmount */
63330 + path_put(&real_root);
63331 + memset(&real_root, 0, sizeof(real_root));
63332 +
63333 + /* free all object hash tables */
63334 +
63335 + FOR_EACH_ROLE_START(r)
63336 + if (r->subj_hash == NULL)
63337 + goto next_role;
63338 + FOR_EACH_SUBJECT_START(r, s, x)
63339 + if (s->obj_hash == NULL)
63340 + break;
63341 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63342 + kfree(s->obj_hash);
63343 + else
63344 + vfree(s->obj_hash);
63345 + FOR_EACH_SUBJECT_END(s, x)
63346 + FOR_EACH_NESTED_SUBJECT_START(r, s)
63347 + if (s->obj_hash == NULL)
63348 + break;
63349 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63350 + kfree(s->obj_hash);
63351 + else
63352 + vfree(s->obj_hash);
63353 + FOR_EACH_NESTED_SUBJECT_END(s)
63354 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
63355 + kfree(r->subj_hash);
63356 + else
63357 + vfree(r->subj_hash);
63358 + r->subj_hash = NULL;
63359 +next_role:
63360 + FOR_EACH_ROLE_END(r)
63361 +
63362 + acl_free_all();
63363 +
63364 + if (acl_role_set.r_hash) {
63365 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
63366 + PAGE_SIZE)
63367 + kfree(acl_role_set.r_hash);
63368 + else
63369 + vfree(acl_role_set.r_hash);
63370 + }
63371 + if (name_set.n_hash) {
63372 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
63373 + PAGE_SIZE)
63374 + kfree(name_set.n_hash);
63375 + else
63376 + vfree(name_set.n_hash);
63377 + }
63378 +
63379 + if (inodev_set.i_hash) {
63380 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
63381 + PAGE_SIZE)
63382 + kfree(inodev_set.i_hash);
63383 + else
63384 + vfree(inodev_set.i_hash);
63385 + }
63386 +
63387 + gr_free_uidset();
63388 +
63389 + memset(&name_set, 0, sizeof (struct name_db));
63390 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63391 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63392 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63393 +
63394 + default_role = NULL;
63395 + kernel_role = NULL;
63396 + role_list = NULL;
63397 +
63398 + return;
63399 +}
63400 +
63401 +static struct acl_subject_label *
63402 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63403 +
63404 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63405 +{
63406 + unsigned int len = strnlen_user(*name, maxlen);
63407 + char *tmp;
63408 +
63409 + if (!len || len >= maxlen)
63410 + return -EINVAL;
63411 +
63412 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63413 + return -ENOMEM;
63414 +
63415 + if (copy_from_user(tmp, *name, len))
63416 + return -EFAULT;
63417 +
63418 + tmp[len-1] = '\0';
63419 + *name = tmp;
63420 +
63421 + return 0;
63422 +}
63423 +
63424 +static int
63425 +copy_user_glob(struct acl_object_label *obj)
63426 +{
63427 + struct acl_object_label *g_tmp, **guser;
63428 + int error;
63429 +
63430 + if (obj->globbed == NULL)
63431 + return 0;
63432 +
63433 + guser = &obj->globbed;
63434 + while (*guser) {
63435 + g_tmp = (struct acl_object_label *)
63436 + acl_alloc(sizeof (struct acl_object_label));
63437 + if (g_tmp == NULL)
63438 + return -ENOMEM;
63439 +
63440 + if (copy_acl_object_label(g_tmp, *guser))
63441 + return -EFAULT;
63442 +
63443 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63444 + if (error)
63445 + return error;
63446 +
63447 + *guser = g_tmp;
63448 + guser = &(g_tmp->next);
63449 + }
63450 +
63451 + return 0;
63452 +}
63453 +
63454 +static int
63455 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63456 + struct acl_role_label *role)
63457 +{
63458 + struct acl_object_label *o_tmp;
63459 + int ret;
63460 +
63461 + while (userp) {
63462 + if ((o_tmp = (struct acl_object_label *)
63463 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63464 + return -ENOMEM;
63465 +
63466 + if (copy_acl_object_label(o_tmp, userp))
63467 + return -EFAULT;
63468 +
63469 + userp = o_tmp->prev;
63470 +
63471 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63472 + if (ret)
63473 + return ret;
63474 +
63475 + insert_acl_obj_label(o_tmp, subj);
63476 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63477 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63478 + return -ENOMEM;
63479 +
63480 + ret = copy_user_glob(o_tmp);
63481 + if (ret)
63482 + return ret;
63483 +
63484 + if (o_tmp->nested) {
63485 + int already_copied;
63486 +
63487 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63488 + if (IS_ERR(o_tmp->nested))
63489 + return PTR_ERR(o_tmp->nested);
63490 +
63491 + /* insert into nested subject list if we haven't copied this one yet
63492 + to prevent duplicate entries */
63493 + if (!already_copied) {
63494 + o_tmp->nested->next = role->hash->first;
63495 + role->hash->first = o_tmp->nested;
63496 + }
63497 + }
63498 + }
63499 +
63500 + return 0;
63501 +}
63502 +
63503 +static __u32
63504 +count_user_subjs(struct acl_subject_label *userp)
63505 +{
63506 + struct acl_subject_label s_tmp;
63507 + __u32 num = 0;
63508 +
63509 + while (userp) {
63510 + if (copy_acl_subject_label(&s_tmp, userp))
63511 + break;
63512 +
63513 + userp = s_tmp.prev;
63514 + }
63515 +
63516 + return num;
63517 +}
63518 +
63519 +static int
63520 +copy_user_allowedips(struct acl_role_label *rolep)
63521 +{
63522 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63523 +
63524 + ruserip = rolep->allowed_ips;
63525 +
63526 + while (ruserip) {
63527 + rlast = rtmp;
63528 +
63529 + if ((rtmp = (struct role_allowed_ip *)
63530 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63531 + return -ENOMEM;
63532 +
63533 + if (copy_role_allowed_ip(rtmp, ruserip))
63534 + return -EFAULT;
63535 +
63536 + ruserip = rtmp->prev;
63537 +
63538 + if (!rlast) {
63539 + rtmp->prev = NULL;
63540 + rolep->allowed_ips = rtmp;
63541 + } else {
63542 + rlast->next = rtmp;
63543 + rtmp->prev = rlast;
63544 + }
63545 +
63546 + if (!ruserip)
63547 + rtmp->next = NULL;
63548 + }
63549 +
63550 + return 0;
63551 +}
63552 +
63553 +static int
63554 +copy_user_transitions(struct acl_role_label *rolep)
63555 +{
63556 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63557 + int error;
63558 +
63559 + rusertp = rolep->transitions;
63560 +
63561 + while (rusertp) {
63562 + rlast = rtmp;
63563 +
63564 + if ((rtmp = (struct role_transition *)
63565 + acl_alloc(sizeof (struct role_transition))) == NULL)
63566 + return -ENOMEM;
63567 +
63568 + if (copy_role_transition(rtmp, rusertp))
63569 + return -EFAULT;
63570 +
63571 + rusertp = rtmp->prev;
63572 +
63573 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63574 + if (error)
63575 + return error;
63576 +
63577 + if (!rlast) {
63578 + rtmp->prev = NULL;
63579 + rolep->transitions = rtmp;
63580 + } else {
63581 + rlast->next = rtmp;
63582 + rtmp->prev = rlast;
63583 + }
63584 +
63585 + if (!rusertp)
63586 + rtmp->next = NULL;
63587 + }
63588 +
63589 + return 0;
63590 +}
63591 +
63592 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63593 +{
63594 + struct acl_object_label o_tmp;
63595 + __u32 num = 0;
63596 +
63597 + while (userp) {
63598 + if (copy_acl_object_label(&o_tmp, userp))
63599 + break;
63600 +
63601 + userp = o_tmp.prev;
63602 + num++;
63603 + }
63604 +
63605 + return num;
63606 +}
63607 +
63608 +static struct acl_subject_label *
63609 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63610 +{
63611 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63612 + __u32 num_objs;
63613 + struct acl_ip_label **i_tmp, *i_utmp2;
63614 + struct gr_hash_struct ghash;
63615 + struct subject_map *subjmap;
63616 + unsigned int i_num;
63617 + int err;
63618 +
63619 + if (already_copied != NULL)
63620 + *already_copied = 0;
63621 +
63622 + s_tmp = lookup_subject_map(userp);
63623 +
63624 + /* we've already copied this subject into the kernel, just return
63625 + the reference to it, and don't copy it over again
63626 + */
63627 + if (s_tmp) {
63628 + if (already_copied != NULL)
63629 + *already_copied = 1;
63630 + return(s_tmp);
63631 + }
63632 +
63633 + if ((s_tmp = (struct acl_subject_label *)
63634 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63635 + return ERR_PTR(-ENOMEM);
63636 +
63637 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63638 + if (subjmap == NULL)
63639 + return ERR_PTR(-ENOMEM);
63640 +
63641 + subjmap->user = userp;
63642 + subjmap->kernel = s_tmp;
63643 + insert_subj_map_entry(subjmap);
63644 +
63645 + if (copy_acl_subject_label(s_tmp, userp))
63646 + return ERR_PTR(-EFAULT);
63647 +
63648 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63649 + if (err)
63650 + return ERR_PTR(err);
63651 +
63652 + if (!strcmp(s_tmp->filename, "/"))
63653 + role->root_label = s_tmp;
63654 +
63655 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63656 + return ERR_PTR(-EFAULT);
63657 +
63658 + /* copy user and group transition tables */
63659 +
63660 + if (s_tmp->user_trans_num) {
63661 + uid_t *uidlist;
63662 +
63663 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63664 + if (uidlist == NULL)
63665 + return ERR_PTR(-ENOMEM);
63666 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63667 + return ERR_PTR(-EFAULT);
63668 +
63669 + s_tmp->user_transitions = uidlist;
63670 + }
63671 +
63672 + if (s_tmp->group_trans_num) {
63673 + gid_t *gidlist;
63674 +
63675 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63676 + if (gidlist == NULL)
63677 + return ERR_PTR(-ENOMEM);
63678 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63679 + return ERR_PTR(-EFAULT);
63680 +
63681 + s_tmp->group_transitions = gidlist;
63682 + }
63683 +
63684 + /* set up object hash table */
63685 + num_objs = count_user_objs(ghash.first);
63686 +
63687 + s_tmp->obj_hash_size = num_objs;
63688 + s_tmp->obj_hash =
63689 + (struct acl_object_label **)
63690 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63691 +
63692 + if (!s_tmp->obj_hash)
63693 + return ERR_PTR(-ENOMEM);
63694 +
63695 + memset(s_tmp->obj_hash, 0,
63696 + s_tmp->obj_hash_size *
63697 + sizeof (struct acl_object_label *));
63698 +
63699 + /* add in objects */
63700 + err = copy_user_objs(ghash.first, s_tmp, role);
63701 +
63702 + if (err)
63703 + return ERR_PTR(err);
63704 +
63705 + /* set pointer for parent subject */
63706 + if (s_tmp->parent_subject) {
63707 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63708 +
63709 + if (IS_ERR(s_tmp2))
63710 + return s_tmp2;
63711 +
63712 + s_tmp->parent_subject = s_tmp2;
63713 + }
63714 +
63715 + /* add in ip acls */
63716 +
63717 + if (!s_tmp->ip_num) {
63718 + s_tmp->ips = NULL;
63719 + goto insert;
63720 + }
63721 +
63722 + i_tmp =
63723 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63724 + sizeof (struct acl_ip_label *));
63725 +
63726 + if (!i_tmp)
63727 + return ERR_PTR(-ENOMEM);
63728 +
63729 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63730 + *(i_tmp + i_num) =
63731 + (struct acl_ip_label *)
63732 + acl_alloc(sizeof (struct acl_ip_label));
63733 + if (!*(i_tmp + i_num))
63734 + return ERR_PTR(-ENOMEM);
63735 +
63736 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63737 + return ERR_PTR(-EFAULT);
63738 +
63739 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63740 + return ERR_PTR(-EFAULT);
63741 +
63742 + if ((*(i_tmp + i_num))->iface == NULL)
63743 + continue;
63744 +
63745 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63746 + if (err)
63747 + return ERR_PTR(err);
63748 + }
63749 +
63750 + s_tmp->ips = i_tmp;
63751 +
63752 +insert:
63753 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63754 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63755 + return ERR_PTR(-ENOMEM);
63756 +
63757 + return s_tmp;
63758 +}
63759 +
63760 +static int
63761 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63762 +{
63763 + struct acl_subject_label s_pre;
63764 + struct acl_subject_label * ret;
63765 + int err;
63766 +
63767 + while (userp) {
63768 + if (copy_acl_subject_label(&s_pre, userp))
63769 + return -EFAULT;
63770 +
63771 + ret = do_copy_user_subj(userp, role, NULL);
63772 +
63773 + err = PTR_ERR(ret);
63774 + if (IS_ERR(ret))
63775 + return err;
63776 +
63777 + insert_acl_subj_label(ret, role);
63778 +
63779 + userp = s_pre.prev;
63780 + }
63781 +
63782 + return 0;
63783 +}
63784 +
63785 +static int
63786 +copy_user_acl(struct gr_arg *arg)
63787 +{
63788 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63789 + struct acl_subject_label *subj_list;
63790 + struct sprole_pw *sptmp;
63791 + struct gr_hash_struct *ghash;
63792 + uid_t *domainlist;
63793 + unsigned int r_num;
63794 + int err = 0;
63795 + __u16 i;
63796 + __u32 num_subjs;
63797 +
63798 + /* we need a default and kernel role */
63799 + if (arg->role_db.num_roles < 2)
63800 + return -EINVAL;
63801 +
63802 + /* copy special role authentication info from userspace */
63803 +
63804 + num_sprole_pws = arg->num_sprole_pws;
63805 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63806 +
63807 + if (!acl_special_roles && num_sprole_pws)
63808 + return -ENOMEM;
63809 +
63810 + for (i = 0; i < num_sprole_pws; i++) {
63811 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63812 + if (!sptmp)
63813 + return -ENOMEM;
63814 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63815 + return -EFAULT;
63816 +
63817 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63818 + if (err)
63819 + return err;
63820 +
63821 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63822 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63823 +#endif
63824 +
63825 + acl_special_roles[i] = sptmp;
63826 + }
63827 +
63828 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63829 +
63830 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63831 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63832 +
63833 + if (!r_tmp)
63834 + return -ENOMEM;
63835 +
63836 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63837 + return -EFAULT;
63838 +
63839 + if (copy_acl_role_label(r_tmp, r_utmp2))
63840 + return -EFAULT;
63841 +
63842 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63843 + if (err)
63844 + return err;
63845 +
63846 + if (!strcmp(r_tmp->rolename, "default")
63847 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63848 + default_role = r_tmp;
63849 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63850 + kernel_role = r_tmp;
63851 + }
63852 +
63853 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63854 + return -ENOMEM;
63855 +
63856 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63857 + return -EFAULT;
63858 +
63859 + r_tmp->hash = ghash;
63860 +
63861 + num_subjs = count_user_subjs(r_tmp->hash->first);
63862 +
63863 + r_tmp->subj_hash_size = num_subjs;
63864 + r_tmp->subj_hash =
63865 + (struct acl_subject_label **)
63866 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
63867 +
63868 + if (!r_tmp->subj_hash)
63869 + return -ENOMEM;
63870 +
63871 + err = copy_user_allowedips(r_tmp);
63872 + if (err)
63873 + return err;
63874 +
63875 + /* copy domain info */
63876 + if (r_tmp->domain_children != NULL) {
63877 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
63878 + if (domainlist == NULL)
63879 + return -ENOMEM;
63880 +
63881 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
63882 + return -EFAULT;
63883 +
63884 + r_tmp->domain_children = domainlist;
63885 + }
63886 +
63887 + err = copy_user_transitions(r_tmp);
63888 + if (err)
63889 + return err;
63890 +
63891 + memset(r_tmp->subj_hash, 0,
63892 + r_tmp->subj_hash_size *
63893 + sizeof (struct acl_subject_label *));
63894 +
63895 + /* acquire the list of subjects, then NULL out
63896 + the list prior to parsing the subjects for this role,
63897 + as during this parsing the list is replaced with a list
63898 + of *nested* subjects for the role
63899 + */
63900 + subj_list = r_tmp->hash->first;
63901 +
63902 + /* set nested subject list to null */
63903 + r_tmp->hash->first = NULL;
63904 +
63905 + err = copy_user_subjs(subj_list, r_tmp);
63906 +
63907 + if (err)
63908 + return err;
63909 +
63910 + insert_acl_role_label(r_tmp);
63911 + }
63912 +
63913 + if (default_role == NULL || kernel_role == NULL)
63914 + return -EINVAL;
63915 +
63916 + return err;
63917 +}
63918 +
63919 +static int
63920 +gracl_init(struct gr_arg *args)
63921 +{
63922 + int error = 0;
63923 +
63924 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
63925 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
63926 +
63927 + if (init_variables(args)) {
63928 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
63929 + error = -ENOMEM;
63930 + free_variables();
63931 + goto out;
63932 + }
63933 +
63934 + error = copy_user_acl(args);
63935 + free_init_variables();
63936 + if (error) {
63937 + free_variables();
63938 + goto out;
63939 + }
63940 +
63941 + if ((error = gr_set_acls(0))) {
63942 + free_variables();
63943 + goto out;
63944 + }
63945 +
63946 + pax_open_kernel();
63947 + gr_status |= GR_READY;
63948 + pax_close_kernel();
63949 +
63950 + out:
63951 + return error;
63952 +}
63953 +
63954 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63955 +
63956 +static int
63957 +glob_match(const char *p, const char *n)
63958 +{
63959 + char c;
63960 +
63961 + while ((c = *p++) != '\0') {
63962 + switch (c) {
63963 + case '?':
63964 + if (*n == '\0')
63965 + return 1;
63966 + else if (*n == '/')
63967 + return 1;
63968 + break;
63969 + case '\\':
63970 + if (*n != c)
63971 + return 1;
63972 + break;
63973 + case '*':
63974 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63975 + if (*n == '/')
63976 + return 1;
63977 + else if (c == '?') {
63978 + if (*n == '\0')
63979 + return 1;
63980 + else
63981 + ++n;
63982 + }
63983 + }
63984 + if (c == '\0') {
63985 + return 0;
63986 + } else {
63987 + const char *endp;
63988 +
63989 + if ((endp = strchr(n, '/')) == NULL)
63990 + endp = n + strlen(n);
63991 +
63992 + if (c == '[') {
63993 + for (--p; n < endp; ++n)
63994 + if (!glob_match(p, n))
63995 + return 0;
63996 + } else if (c == '/') {
63997 + while (*n != '\0' && *n != '/')
63998 + ++n;
63999 + if (*n == '/' && !glob_match(p, n + 1))
64000 + return 0;
64001 + } else {
64002 + for (--p; n < endp; ++n)
64003 + if (*n == c && !glob_match(p, n))
64004 + return 0;
64005 + }
64006 +
64007 + return 1;
64008 + }
64009 + case '[':
64010 + {
64011 + int not;
64012 + char cold;
64013 +
64014 + if (*n == '\0' || *n == '/')
64015 + return 1;
64016 +
64017 + not = (*p == '!' || *p == '^');
64018 + if (not)
64019 + ++p;
64020 +
64021 + c = *p++;
64022 + for (;;) {
64023 + unsigned char fn = (unsigned char)*n;
64024 +
64025 + if (c == '\0')
64026 + return 1;
64027 + else {
64028 + if (c == fn)
64029 + goto matched;
64030 + cold = c;
64031 + c = *p++;
64032 +
64033 + if (c == '-' && *p != ']') {
64034 + unsigned char cend = *p++;
64035 +
64036 + if (cend == '\0')
64037 + return 1;
64038 +
64039 + if (cold <= fn && fn <= cend)
64040 + goto matched;
64041 +
64042 + c = *p++;
64043 + }
64044 + }
64045 +
64046 + if (c == ']')
64047 + break;
64048 + }
64049 + if (!not)
64050 + return 1;
64051 + break;
64052 + matched:
64053 + while (c != ']') {
64054 + if (c == '\0')
64055 + return 1;
64056 +
64057 + c = *p++;
64058 + }
64059 + if (not)
64060 + return 1;
64061 + }
64062 + break;
64063 + default:
64064 + if (c != *n)
64065 + return 1;
64066 + }
64067 +
64068 + ++n;
64069 + }
64070 +
64071 + if (*n == '\0')
64072 + return 0;
64073 +
64074 + if (*n == '/')
64075 + return 0;
64076 +
64077 + return 1;
64078 +}
64079 +
64080 +static struct acl_object_label *
64081 +chk_glob_label(struct acl_object_label *globbed,
64082 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64083 +{
64084 + struct acl_object_label *tmp;
64085 +
64086 + if (*path == NULL)
64087 + *path = gr_to_filename_nolock(dentry, mnt);
64088 +
64089 + tmp = globbed;
64090 +
64091 + while (tmp) {
64092 + if (!glob_match(tmp->filename, *path))
64093 + return tmp;
64094 + tmp = tmp->next;
64095 + }
64096 +
64097 + return NULL;
64098 +}
64099 +
64100 +static struct acl_object_label *
64101 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64102 + const ino_t curr_ino, const dev_t curr_dev,
64103 + const struct acl_subject_label *subj, char **path, const int checkglob)
64104 +{
64105 + struct acl_subject_label *tmpsubj;
64106 + struct acl_object_label *retval;
64107 + struct acl_object_label *retval2;
64108 +
64109 + tmpsubj = (struct acl_subject_label *) subj;
64110 + read_lock(&gr_inode_lock);
64111 + do {
64112 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64113 + if (retval) {
64114 + if (checkglob && retval->globbed) {
64115 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64116 + if (retval2)
64117 + retval = retval2;
64118 + }
64119 + break;
64120 + }
64121 + } while ((tmpsubj = tmpsubj->parent_subject));
64122 + read_unlock(&gr_inode_lock);
64123 +
64124 + return retval;
64125 +}
64126 +
64127 +static __inline__ struct acl_object_label *
64128 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64129 + struct dentry *curr_dentry,
64130 + const struct acl_subject_label *subj, char **path, const int checkglob)
64131 +{
64132 + int newglob = checkglob;
64133 + ino_t inode;
64134 + dev_t device;
64135 +
64136 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64137 + as we don't want a / * rule to match instead of the / object
64138 + don't do this for create lookups that call this function though, since they're looking up
64139 + on the parent and thus need globbing checks on all paths
64140 + */
64141 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64142 + newglob = GR_NO_GLOB;
64143 +
64144 + spin_lock(&curr_dentry->d_lock);
64145 + inode = curr_dentry->d_inode->i_ino;
64146 + device = __get_dev(curr_dentry);
64147 + spin_unlock(&curr_dentry->d_lock);
64148 +
64149 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64150 +}
64151 +
64152 +#ifdef CONFIG_HUGETLBFS
64153 +static inline bool
64154 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64155 +{
64156 + int i;
64157 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64158 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64159 + return true;
64160 + }
64161 +
64162 + return false;
64163 +}
64164 +#endif
64165 +
64166 +static struct acl_object_label *
64167 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64168 + const struct acl_subject_label *subj, char *path, const int checkglob)
64169 +{
64170 + struct dentry *dentry = (struct dentry *) l_dentry;
64171 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64172 + struct mount *real_mnt = real_mount(mnt);
64173 + struct acl_object_label *retval;
64174 + struct dentry *parent;
64175 +
64176 + br_read_lock(&vfsmount_lock);
64177 + write_seqlock(&rename_lock);
64178 +
64179 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64180 +#ifdef CONFIG_NET
64181 + mnt == sock_mnt ||
64182 +#endif
64183 +#ifdef CONFIG_HUGETLBFS
64184 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64185 +#endif
64186 + /* ignore Eric Biederman */
64187 + IS_PRIVATE(l_dentry->d_inode))) {
64188 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64189 + goto out;
64190 + }
64191 +
64192 + for (;;) {
64193 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64194 + break;
64195 +
64196 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64197 + if (!mnt_has_parent(real_mnt))
64198 + break;
64199 +
64200 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64201 + if (retval != NULL)
64202 + goto out;
64203 +
64204 + dentry = real_mnt->mnt_mountpoint;
64205 + real_mnt = real_mnt->mnt_parent;
64206 + mnt = &real_mnt->mnt;
64207 + continue;
64208 + }
64209 +
64210 + parent = dentry->d_parent;
64211 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64212 + if (retval != NULL)
64213 + goto out;
64214 +
64215 + dentry = parent;
64216 + }
64217 +
64218 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64219 +
64220 + /* real_root is pinned so we don't have to hold a reference */
64221 + if (retval == NULL)
64222 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
64223 +out:
64224 + write_sequnlock(&rename_lock);
64225 + br_read_unlock(&vfsmount_lock);
64226 +
64227 + BUG_ON(retval == NULL);
64228 +
64229 + return retval;
64230 +}
64231 +
64232 +static __inline__ struct acl_object_label *
64233 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64234 + const struct acl_subject_label *subj)
64235 +{
64236 + char *path = NULL;
64237 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64238 +}
64239 +
64240 +static __inline__ struct acl_object_label *
64241 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64242 + const struct acl_subject_label *subj)
64243 +{
64244 + char *path = NULL;
64245 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64246 +}
64247 +
64248 +static __inline__ struct acl_object_label *
64249 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64250 + const struct acl_subject_label *subj, char *path)
64251 +{
64252 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64253 +}
64254 +
64255 +static struct acl_subject_label *
64256 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64257 + const struct acl_role_label *role)
64258 +{
64259 + struct dentry *dentry = (struct dentry *) l_dentry;
64260 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64261 + struct mount *real_mnt = real_mount(mnt);
64262 + struct acl_subject_label *retval;
64263 + struct dentry *parent;
64264 +
64265 + br_read_lock(&vfsmount_lock);
64266 + write_seqlock(&rename_lock);
64267 +
64268 + for (;;) {
64269 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64270 + break;
64271 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64272 + if (!mnt_has_parent(real_mnt))
64273 + break;
64274 +
64275 + spin_lock(&dentry->d_lock);
64276 + read_lock(&gr_inode_lock);
64277 + retval =
64278 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64279 + __get_dev(dentry), role);
64280 + read_unlock(&gr_inode_lock);
64281 + spin_unlock(&dentry->d_lock);
64282 + if (retval != NULL)
64283 + goto out;
64284 +
64285 + dentry = real_mnt->mnt_mountpoint;
64286 + real_mnt = real_mnt->mnt_parent;
64287 + mnt = &real_mnt->mnt;
64288 + continue;
64289 + }
64290 +
64291 + spin_lock(&dentry->d_lock);
64292 + read_lock(&gr_inode_lock);
64293 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64294 + __get_dev(dentry), role);
64295 + read_unlock(&gr_inode_lock);
64296 + parent = dentry->d_parent;
64297 + spin_unlock(&dentry->d_lock);
64298 +
64299 + if (retval != NULL)
64300 + goto out;
64301 +
64302 + dentry = parent;
64303 + }
64304 +
64305 + spin_lock(&dentry->d_lock);
64306 + read_lock(&gr_inode_lock);
64307 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64308 + __get_dev(dentry), role);
64309 + read_unlock(&gr_inode_lock);
64310 + spin_unlock(&dentry->d_lock);
64311 +
64312 + if (unlikely(retval == NULL)) {
64313 + /* real_root is pinned, we don't need to hold a reference */
64314 + read_lock(&gr_inode_lock);
64315 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
64316 + __get_dev(real_root.dentry), role);
64317 + read_unlock(&gr_inode_lock);
64318 + }
64319 +out:
64320 + write_sequnlock(&rename_lock);
64321 + br_read_unlock(&vfsmount_lock);
64322 +
64323 + BUG_ON(retval == NULL);
64324 +
64325 + return retval;
64326 +}
64327 +
64328 +static void
64329 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64330 +{
64331 + struct task_struct *task = current;
64332 + const struct cred *cred = current_cred();
64333 +
64334 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64335 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64336 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64337 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64338 +
64339 + return;
64340 +}
64341 +
64342 +static void
64343 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64344 +{
64345 + struct task_struct *task = current;
64346 + const struct cred *cred = current_cred();
64347 +
64348 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64349 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64350 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64351 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64352 +
64353 + return;
64354 +}
64355 +
64356 +static void
64357 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64358 +{
64359 + struct task_struct *task = current;
64360 + const struct cred *cred = current_cred();
64361 +
64362 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64363 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64364 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64365 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64366 +
64367 + return;
64368 +}
64369 +
64370 +__u32
64371 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64372 + const struct vfsmount * mnt)
64373 +{
64374 + __u32 retval = mode;
64375 + struct acl_subject_label *curracl;
64376 + struct acl_object_label *currobj;
64377 +
64378 + if (unlikely(!(gr_status & GR_READY)))
64379 + return (mode & ~GR_AUDITS);
64380 +
64381 + curracl = current->acl;
64382 +
64383 + currobj = chk_obj_label(dentry, mnt, curracl);
64384 + retval = currobj->mode & mode;
64385 +
64386 + /* if we're opening a specified transfer file for writing
64387 + (e.g. /dev/initctl), then transfer our role to init
64388 + */
64389 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64390 + current->role->roletype & GR_ROLE_PERSIST)) {
64391 + struct task_struct *task = init_pid_ns.child_reaper;
64392 +
64393 + if (task->role != current->role) {
64394 + task->acl_sp_role = 0;
64395 + task->acl_role_id = current->acl_role_id;
64396 + task->role = current->role;
64397 + rcu_read_lock();
64398 + read_lock(&grsec_exec_file_lock);
64399 + gr_apply_subject_to_task(task);
64400 + read_unlock(&grsec_exec_file_lock);
64401 + rcu_read_unlock();
64402 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64403 + }
64404 + }
64405 +
64406 + if (unlikely
64407 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64408 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64409 + __u32 new_mode = mode;
64410 +
64411 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64412 +
64413 + retval = new_mode;
64414 +
64415 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64416 + new_mode |= GR_INHERIT;
64417 +
64418 + if (!(mode & GR_NOLEARN))
64419 + gr_log_learn(dentry, mnt, new_mode);
64420 + }
64421 +
64422 + return retval;
64423 +}
64424 +
64425 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64426 + const struct dentry *parent,
64427 + const struct vfsmount *mnt)
64428 +{
64429 + struct name_entry *match;
64430 + struct acl_object_label *matchpo;
64431 + struct acl_subject_label *curracl;
64432 + char *path;
64433 +
64434 + if (unlikely(!(gr_status & GR_READY)))
64435 + return NULL;
64436 +
64437 + preempt_disable();
64438 + path = gr_to_filename_rbac(new_dentry, mnt);
64439 + match = lookup_name_entry_create(path);
64440 +
64441 + curracl = current->acl;
64442 +
64443 + if (match) {
64444 + read_lock(&gr_inode_lock);
64445 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64446 + read_unlock(&gr_inode_lock);
64447 +
64448 + if (matchpo) {
64449 + preempt_enable();
64450 + return matchpo;
64451 + }
64452 + }
64453 +
64454 + // lookup parent
64455 +
64456 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64457 +
64458 + preempt_enable();
64459 + return matchpo;
64460 +}
64461 +
64462 +__u32
64463 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64464 + const struct vfsmount * mnt, const __u32 mode)
64465 +{
64466 + struct acl_object_label *matchpo;
64467 + __u32 retval;
64468 +
64469 + if (unlikely(!(gr_status & GR_READY)))
64470 + return (mode & ~GR_AUDITS);
64471 +
64472 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64473 +
64474 + retval = matchpo->mode & mode;
64475 +
64476 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64477 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64478 + __u32 new_mode = mode;
64479 +
64480 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64481 +
64482 + gr_log_learn(new_dentry, mnt, new_mode);
64483 + return new_mode;
64484 + }
64485 +
64486 + return retval;
64487 +}
64488 +
64489 +__u32
64490 +gr_check_link(const struct dentry * new_dentry,
64491 + const struct dentry * parent_dentry,
64492 + const struct vfsmount * parent_mnt,
64493 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64494 +{
64495 + struct acl_object_label *obj;
64496 + __u32 oldmode, newmode;
64497 + __u32 needmode;
64498 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64499 + GR_DELETE | GR_INHERIT;
64500 +
64501 + if (unlikely(!(gr_status & GR_READY)))
64502 + return (GR_CREATE | GR_LINK);
64503 +
64504 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64505 + oldmode = obj->mode;
64506 +
64507 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64508 + newmode = obj->mode;
64509 +
64510 + needmode = newmode & checkmodes;
64511 +
64512 + // old name for hardlink must have at least the permissions of the new name
64513 + if ((oldmode & needmode) != needmode)
64514 + goto bad;
64515 +
64516 + // if old name had restrictions/auditing, make sure the new name does as well
64517 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64518 +
64519 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64520 + if (is_privileged_binary(old_dentry))
64521 + needmode |= GR_SETID;
64522 +
64523 + if ((newmode & needmode) != needmode)
64524 + goto bad;
64525 +
64526 + // enforce minimum permissions
64527 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64528 + return newmode;
64529 +bad:
64530 + needmode = oldmode;
64531 + if (is_privileged_binary(old_dentry))
64532 + needmode |= GR_SETID;
64533 +
64534 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64535 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64536 + return (GR_CREATE | GR_LINK);
64537 + } else if (newmode & GR_SUPPRESS)
64538 + return GR_SUPPRESS;
64539 + else
64540 + return 0;
64541 +}
64542 +
64543 +int
64544 +gr_check_hidden_task(const struct task_struct *task)
64545 +{
64546 + if (unlikely(!(gr_status & GR_READY)))
64547 + return 0;
64548 +
64549 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64550 + return 1;
64551 +
64552 + return 0;
64553 +}
64554 +
64555 +int
64556 +gr_check_protected_task(const struct task_struct *task)
64557 +{
64558 + if (unlikely(!(gr_status & GR_READY) || !task))
64559 + return 0;
64560 +
64561 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64562 + task->acl != current->acl)
64563 + return 1;
64564 +
64565 + return 0;
64566 +}
64567 +
64568 +int
64569 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64570 +{
64571 + struct task_struct *p;
64572 + int ret = 0;
64573 +
64574 + if (unlikely(!(gr_status & GR_READY) || !pid))
64575 + return ret;
64576 +
64577 + read_lock(&tasklist_lock);
64578 + do_each_pid_task(pid, type, p) {
64579 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64580 + p->acl != current->acl) {
64581 + ret = 1;
64582 + goto out;
64583 + }
64584 + } while_each_pid_task(pid, type, p);
64585 +out:
64586 + read_unlock(&tasklist_lock);
64587 +
64588 + return ret;
64589 +}
64590 +
64591 +void
64592 +gr_copy_label(struct task_struct *tsk)
64593 +{
64594 + tsk->signal->used_accept = 0;
64595 + tsk->acl_sp_role = 0;
64596 + tsk->acl_role_id = current->acl_role_id;
64597 + tsk->acl = current->acl;
64598 + tsk->role = current->role;
64599 + tsk->signal->curr_ip = current->signal->curr_ip;
64600 + tsk->signal->saved_ip = current->signal->saved_ip;
64601 + if (current->exec_file)
64602 + get_file(current->exec_file);
64603 + tsk->exec_file = current->exec_file;
64604 + tsk->is_writable = current->is_writable;
64605 + if (unlikely(current->signal->used_accept)) {
64606 + current->signal->curr_ip = 0;
64607 + current->signal->saved_ip = 0;
64608 + }
64609 +
64610 + return;
64611 +}
64612 +
64613 +static void
64614 +gr_set_proc_res(struct task_struct *task)
64615 +{
64616 + struct acl_subject_label *proc;
64617 + unsigned short i;
64618 +
64619 + proc = task->acl;
64620 +
64621 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64622 + return;
64623 +
64624 + for (i = 0; i < RLIM_NLIMITS; i++) {
64625 + if (!(proc->resmask & (1U << i)))
64626 + continue;
64627 +
64628 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64629 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64630 +
64631 + if (i == RLIMIT_CPU)
64632 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64633 + }
64634 +
64635 + return;
64636 +}
64637 +
64638 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64639 +
64640 +int
64641 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64642 +{
64643 + unsigned int i;
64644 + __u16 num;
64645 + uid_t *uidlist;
64646 + uid_t curuid;
64647 + int realok = 0;
64648 + int effectiveok = 0;
64649 + int fsok = 0;
64650 + uid_t globalreal, globaleffective, globalfs;
64651 +
64652 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64653 + struct user_struct *user;
64654 +
64655 + if (!uid_valid(real))
64656 + goto skipit;
64657 +
64658 + /* find user based on global namespace */
64659 +
64660 + globalreal = GR_GLOBAL_UID(real);
64661 +
64662 + user = find_user(make_kuid(&init_user_ns, globalreal));
64663 + if (user == NULL)
64664 + goto skipit;
64665 +
64666 + if (gr_process_kernel_setuid_ban(user)) {
64667 + /* for find_user */
64668 + free_uid(user);
64669 + return 1;
64670 + }
64671 +
64672 + /* for find_user */
64673 + free_uid(user);
64674 +
64675 +skipit:
64676 +#endif
64677 +
64678 + if (unlikely(!(gr_status & GR_READY)))
64679 + return 0;
64680 +
64681 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64682 + gr_log_learn_uid_change(real, effective, fs);
64683 +
64684 + num = current->acl->user_trans_num;
64685 + uidlist = current->acl->user_transitions;
64686 +
64687 + if (uidlist == NULL)
64688 + return 0;
64689 +
64690 + if (!uid_valid(real)) {
64691 + realok = 1;
64692 + globalreal = (uid_t)-1;
64693 + } else {
64694 + globalreal = GR_GLOBAL_UID(real);
64695 + }
64696 + if (!uid_valid(effective)) {
64697 + effectiveok = 1;
64698 + globaleffective = (uid_t)-1;
64699 + } else {
64700 + globaleffective = GR_GLOBAL_UID(effective);
64701 + }
64702 + if (!uid_valid(fs)) {
64703 + fsok = 1;
64704 + globalfs = (uid_t)-1;
64705 + } else {
64706 + globalfs = GR_GLOBAL_UID(fs);
64707 + }
64708 +
64709 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64710 + for (i = 0; i < num; i++) {
64711 + curuid = uidlist[i];
64712 + if (globalreal == curuid)
64713 + realok = 1;
64714 + if (globaleffective == curuid)
64715 + effectiveok = 1;
64716 + if (globalfs == curuid)
64717 + fsok = 1;
64718 + }
64719 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64720 + for (i = 0; i < num; i++) {
64721 + curuid = uidlist[i];
64722 + if (globalreal == curuid)
64723 + break;
64724 + if (globaleffective == curuid)
64725 + break;
64726 + if (globalfs == curuid)
64727 + break;
64728 + }
64729 + /* not in deny list */
64730 + if (i == num) {
64731 + realok = 1;
64732 + effectiveok = 1;
64733 + fsok = 1;
64734 + }
64735 + }
64736 +
64737 + if (realok && effectiveok && fsok)
64738 + return 0;
64739 + else {
64740 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64741 + return 1;
64742 + }
64743 +}
64744 +
64745 +int
64746 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64747 +{
64748 + unsigned int i;
64749 + __u16 num;
64750 + gid_t *gidlist;
64751 + gid_t curgid;
64752 + int realok = 0;
64753 + int effectiveok = 0;
64754 + int fsok = 0;
64755 + gid_t globalreal, globaleffective, globalfs;
64756 +
64757 + if (unlikely(!(gr_status & GR_READY)))
64758 + return 0;
64759 +
64760 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64761 + gr_log_learn_gid_change(real, effective, fs);
64762 +
64763 + num = current->acl->group_trans_num;
64764 + gidlist = current->acl->group_transitions;
64765 +
64766 + if (gidlist == NULL)
64767 + return 0;
64768 +
64769 + if (!gid_valid(real)) {
64770 + realok = 1;
64771 + globalreal = (gid_t)-1;
64772 + } else {
64773 + globalreal = GR_GLOBAL_GID(real);
64774 + }
64775 + if (!gid_valid(effective)) {
64776 + effectiveok = 1;
64777 + globaleffective = (gid_t)-1;
64778 + } else {
64779 + globaleffective = GR_GLOBAL_GID(effective);
64780 + }
64781 + if (!gid_valid(fs)) {
64782 + fsok = 1;
64783 + globalfs = (gid_t)-1;
64784 + } else {
64785 + globalfs = GR_GLOBAL_GID(fs);
64786 + }
64787 +
64788 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64789 + for (i = 0; i < num; i++) {
64790 + curgid = gidlist[i];
64791 + if (globalreal == curgid)
64792 + realok = 1;
64793 + if (globaleffective == curgid)
64794 + effectiveok = 1;
64795 + if (globalfs == curgid)
64796 + fsok = 1;
64797 + }
64798 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64799 + for (i = 0; i < num; i++) {
64800 + curgid = gidlist[i];
64801 + if (globalreal == curgid)
64802 + break;
64803 + if (globaleffective == curgid)
64804 + break;
64805 + if (globalfs == curgid)
64806 + break;
64807 + }
64808 + /* not in deny list */
64809 + if (i == num) {
64810 + realok = 1;
64811 + effectiveok = 1;
64812 + fsok = 1;
64813 + }
64814 + }
64815 +
64816 + if (realok && effectiveok && fsok)
64817 + return 0;
64818 + else {
64819 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64820 + return 1;
64821 + }
64822 +}
64823 +
64824 +extern int gr_acl_is_capable(const int cap);
64825 +
64826 +void
64827 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64828 +{
64829 + struct acl_role_label *role = task->role;
64830 + struct acl_subject_label *subj = NULL;
64831 + struct acl_object_label *obj;
64832 + struct file *filp;
64833 + uid_t uid;
64834 + gid_t gid;
64835 +
64836 + if (unlikely(!(gr_status & GR_READY)))
64837 + return;
64838 +
64839 + uid = GR_GLOBAL_UID(kuid);
64840 + gid = GR_GLOBAL_GID(kgid);
64841 +
64842 + filp = task->exec_file;
64843 +
64844 + /* kernel process, we'll give them the kernel role */
64845 + if (unlikely(!filp)) {
64846 + task->role = kernel_role;
64847 + task->acl = kernel_role->root_label;
64848 + return;
64849 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64850 + role = lookup_acl_role_label(task, uid, gid);
64851 +
64852 + /* don't change the role if we're not a privileged process */
64853 + if (role && task->role != role &&
64854 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64855 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64856 + return;
64857 +
64858 + /* perform subject lookup in possibly new role
64859 + we can use this result below in the case where role == task->role
64860 + */
64861 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64862 +
64863 + /* if we changed uid/gid, but result in the same role
64864 + and are using inheritance, don't lose the inherited subject
64865 + if current subject is other than what normal lookup
64866 + would result in, we arrived via inheritance, don't
64867 + lose subject
64868 + */
64869 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64870 + (subj == task->acl)))
64871 + task->acl = subj;
64872 +
64873 + task->role = role;
64874 +
64875 + task->is_writable = 0;
64876 +
64877 + /* ignore additional mmap checks for processes that are writable
64878 + by the default ACL */
64879 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64880 + if (unlikely(obj->mode & GR_WRITE))
64881 + task->is_writable = 1;
64882 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64883 + if (unlikely(obj->mode & GR_WRITE))
64884 + task->is_writable = 1;
64885 +
64886 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64887 + 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);
64888 +#endif
64889 +
64890 + gr_set_proc_res(task);
64891 +
64892 + return;
64893 +}
64894 +
64895 +int
64896 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64897 + const int unsafe_flags)
64898 +{
64899 + struct task_struct *task = current;
64900 + struct acl_subject_label *newacl;
64901 + struct acl_object_label *obj;
64902 + __u32 retmode;
64903 +
64904 + if (unlikely(!(gr_status & GR_READY)))
64905 + return 0;
64906 +
64907 + newacl = chk_subj_label(dentry, mnt, task->role);
64908 +
64909 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64910 + did an exec
64911 + */
64912 + rcu_read_lock();
64913 + read_lock(&tasklist_lock);
64914 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64915 + (task->parent->acl->mode & GR_POVERRIDE))) {
64916 + read_unlock(&tasklist_lock);
64917 + rcu_read_unlock();
64918 + goto skip_check;
64919 + }
64920 + read_unlock(&tasklist_lock);
64921 + rcu_read_unlock();
64922 +
64923 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64924 + !(task->role->roletype & GR_ROLE_GOD) &&
64925 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64926 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64927 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64928 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64929 + else
64930 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64931 + return -EACCES;
64932 + }
64933 +
64934 +skip_check:
64935 +
64936 + obj = chk_obj_label(dentry, mnt, task->acl);
64937 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64938 +
64939 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64940 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64941 + if (obj->nested)
64942 + task->acl = obj->nested;
64943 + else
64944 + task->acl = newacl;
64945 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64946 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64947 +
64948 + task->is_writable = 0;
64949 +
64950 + /* ignore additional mmap checks for processes that are writable
64951 + by the default ACL */
64952 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
64953 + if (unlikely(obj->mode & GR_WRITE))
64954 + task->is_writable = 1;
64955 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64956 + if (unlikely(obj->mode & GR_WRITE))
64957 + task->is_writable = 1;
64958 +
64959 + gr_set_proc_res(task);
64960 +
64961 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64962 + 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);
64963 +#endif
64964 + return 0;
64965 +}
64966 +
64967 +/* always called with valid inodev ptr */
64968 +static void
64969 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64970 +{
64971 + struct acl_object_label *matchpo;
64972 + struct acl_subject_label *matchps;
64973 + struct acl_subject_label *subj;
64974 + struct acl_role_label *role;
64975 + unsigned int x;
64976 +
64977 + FOR_EACH_ROLE_START(role)
64978 + FOR_EACH_SUBJECT_START(role, subj, x)
64979 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64980 + matchpo->mode |= GR_DELETED;
64981 + FOR_EACH_SUBJECT_END(subj,x)
64982 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64983 + /* nested subjects aren't in the role's subj_hash table */
64984 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64985 + matchpo->mode |= GR_DELETED;
64986 + FOR_EACH_NESTED_SUBJECT_END(subj)
64987 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64988 + matchps->mode |= GR_DELETED;
64989 + FOR_EACH_ROLE_END(role)
64990 +
64991 + inodev->nentry->deleted = 1;
64992 +
64993 + return;
64994 +}
64995 +
64996 +void
64997 +gr_handle_delete(const ino_t ino, const dev_t dev)
64998 +{
64999 + struct inodev_entry *inodev;
65000 +
65001 + if (unlikely(!(gr_status & GR_READY)))
65002 + return;
65003 +
65004 + write_lock(&gr_inode_lock);
65005 + inodev = lookup_inodev_entry(ino, dev);
65006 + if (inodev != NULL)
65007 + do_handle_delete(inodev, ino, dev);
65008 + write_unlock(&gr_inode_lock);
65009 +
65010 + return;
65011 +}
65012 +
65013 +static void
65014 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65015 + const ino_t newinode, const dev_t newdevice,
65016 + struct acl_subject_label *subj)
65017 +{
65018 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65019 + struct acl_object_label *match;
65020 +
65021 + match = subj->obj_hash[index];
65022 +
65023 + while (match && (match->inode != oldinode ||
65024 + match->device != olddevice ||
65025 + !(match->mode & GR_DELETED)))
65026 + match = match->next;
65027 +
65028 + if (match && (match->inode == oldinode)
65029 + && (match->device == olddevice)
65030 + && (match->mode & GR_DELETED)) {
65031 + if (match->prev == NULL) {
65032 + subj->obj_hash[index] = match->next;
65033 + if (match->next != NULL)
65034 + match->next->prev = NULL;
65035 + } else {
65036 + match->prev->next = match->next;
65037 + if (match->next != NULL)
65038 + match->next->prev = match->prev;
65039 + }
65040 + match->prev = NULL;
65041 + match->next = NULL;
65042 + match->inode = newinode;
65043 + match->device = newdevice;
65044 + match->mode &= ~GR_DELETED;
65045 +
65046 + insert_acl_obj_label(match, subj);
65047 + }
65048 +
65049 + return;
65050 +}
65051 +
65052 +static void
65053 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65054 + const ino_t newinode, const dev_t newdevice,
65055 + struct acl_role_label *role)
65056 +{
65057 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65058 + struct acl_subject_label *match;
65059 +
65060 + match = role->subj_hash[index];
65061 +
65062 + while (match && (match->inode != oldinode ||
65063 + match->device != olddevice ||
65064 + !(match->mode & GR_DELETED)))
65065 + match = match->next;
65066 +
65067 + if (match && (match->inode == oldinode)
65068 + && (match->device == olddevice)
65069 + && (match->mode & GR_DELETED)) {
65070 + if (match->prev == NULL) {
65071 + role->subj_hash[index] = match->next;
65072 + if (match->next != NULL)
65073 + match->next->prev = NULL;
65074 + } else {
65075 + match->prev->next = match->next;
65076 + if (match->next != NULL)
65077 + match->next->prev = match->prev;
65078 + }
65079 + match->prev = NULL;
65080 + match->next = NULL;
65081 + match->inode = newinode;
65082 + match->device = newdevice;
65083 + match->mode &= ~GR_DELETED;
65084 +
65085 + insert_acl_subj_label(match, role);
65086 + }
65087 +
65088 + return;
65089 +}
65090 +
65091 +static void
65092 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65093 + const ino_t newinode, const dev_t newdevice)
65094 +{
65095 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
65096 + struct inodev_entry *match;
65097 +
65098 + match = inodev_set.i_hash[index];
65099 +
65100 + while (match && (match->nentry->inode != oldinode ||
65101 + match->nentry->device != olddevice || !match->nentry->deleted))
65102 + match = match->next;
65103 +
65104 + if (match && (match->nentry->inode == oldinode)
65105 + && (match->nentry->device == olddevice) &&
65106 + match->nentry->deleted) {
65107 + if (match->prev == NULL) {
65108 + inodev_set.i_hash[index] = match->next;
65109 + if (match->next != NULL)
65110 + match->next->prev = NULL;
65111 + } else {
65112 + match->prev->next = match->next;
65113 + if (match->next != NULL)
65114 + match->next->prev = match->prev;
65115 + }
65116 + match->prev = NULL;
65117 + match->next = NULL;
65118 + match->nentry->inode = newinode;
65119 + match->nentry->device = newdevice;
65120 + match->nentry->deleted = 0;
65121 +
65122 + insert_inodev_entry(match);
65123 + }
65124 +
65125 + return;
65126 +}
65127 +
65128 +static void
65129 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65130 +{
65131 + struct acl_subject_label *subj;
65132 + struct acl_role_label *role;
65133 + unsigned int x;
65134 +
65135 + FOR_EACH_ROLE_START(role)
65136 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65137 +
65138 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65139 + if ((subj->inode == ino) && (subj->device == dev)) {
65140 + subj->inode = ino;
65141 + subj->device = dev;
65142 + }
65143 + /* nested subjects aren't in the role's subj_hash table */
65144 + update_acl_obj_label(matchn->inode, matchn->device,
65145 + ino, dev, subj);
65146 + FOR_EACH_NESTED_SUBJECT_END(subj)
65147 + FOR_EACH_SUBJECT_START(role, subj, x)
65148 + update_acl_obj_label(matchn->inode, matchn->device,
65149 + ino, dev, subj);
65150 + FOR_EACH_SUBJECT_END(subj,x)
65151 + FOR_EACH_ROLE_END(role)
65152 +
65153 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65154 +
65155 + return;
65156 +}
65157 +
65158 +static void
65159 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65160 + const struct vfsmount *mnt)
65161 +{
65162 + ino_t ino = dentry->d_inode->i_ino;
65163 + dev_t dev = __get_dev(dentry);
65164 +
65165 + __do_handle_create(matchn, ino, dev);
65166 +
65167 + return;
65168 +}
65169 +
65170 +void
65171 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65172 +{
65173 + struct name_entry *matchn;
65174 +
65175 + if (unlikely(!(gr_status & GR_READY)))
65176 + return;
65177 +
65178 + preempt_disable();
65179 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65180 +
65181 + if (unlikely((unsigned long)matchn)) {
65182 + write_lock(&gr_inode_lock);
65183 + do_handle_create(matchn, dentry, mnt);
65184 + write_unlock(&gr_inode_lock);
65185 + }
65186 + preempt_enable();
65187 +
65188 + return;
65189 +}
65190 +
65191 +void
65192 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65193 +{
65194 + struct name_entry *matchn;
65195 +
65196 + if (unlikely(!(gr_status & GR_READY)))
65197 + return;
65198 +
65199 + preempt_disable();
65200 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65201 +
65202 + if (unlikely((unsigned long)matchn)) {
65203 + write_lock(&gr_inode_lock);
65204 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65205 + write_unlock(&gr_inode_lock);
65206 + }
65207 + preempt_enable();
65208 +
65209 + return;
65210 +}
65211 +
65212 +void
65213 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65214 + struct dentry *old_dentry,
65215 + struct dentry *new_dentry,
65216 + struct vfsmount *mnt, const __u8 replace)
65217 +{
65218 + struct name_entry *matchn;
65219 + struct inodev_entry *inodev;
65220 + struct inode *inode = new_dentry->d_inode;
65221 + ino_t old_ino = old_dentry->d_inode->i_ino;
65222 + dev_t old_dev = __get_dev(old_dentry);
65223 +
65224 + /* vfs_rename swaps the name and parent link for old_dentry and
65225 + new_dentry
65226 + at this point, old_dentry has the new name, parent link, and inode
65227 + for the renamed file
65228 + if a file is being replaced by a rename, new_dentry has the inode
65229 + and name for the replaced file
65230 + */
65231 +
65232 + if (unlikely(!(gr_status & GR_READY)))
65233 + return;
65234 +
65235 + preempt_disable();
65236 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65237 +
65238 + /* we wouldn't have to check d_inode if it weren't for
65239 + NFS silly-renaming
65240 + */
65241 +
65242 + write_lock(&gr_inode_lock);
65243 + if (unlikely(replace && inode)) {
65244 + ino_t new_ino = inode->i_ino;
65245 + dev_t new_dev = __get_dev(new_dentry);
65246 +
65247 + inodev = lookup_inodev_entry(new_ino, new_dev);
65248 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65249 + do_handle_delete(inodev, new_ino, new_dev);
65250 + }
65251 +
65252 + inodev = lookup_inodev_entry(old_ino, old_dev);
65253 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65254 + do_handle_delete(inodev, old_ino, old_dev);
65255 +
65256 + if (unlikely((unsigned long)matchn))
65257 + do_handle_create(matchn, old_dentry, mnt);
65258 +
65259 + write_unlock(&gr_inode_lock);
65260 + preempt_enable();
65261 +
65262 + return;
65263 +}
65264 +
65265 +static int
65266 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
65267 + unsigned char **sum)
65268 +{
65269 + struct acl_role_label *r;
65270 + struct role_allowed_ip *ipp;
65271 + struct role_transition *trans;
65272 + unsigned int i;
65273 + int found = 0;
65274 + u32 curr_ip = current->signal->curr_ip;
65275 +
65276 + current->signal->saved_ip = curr_ip;
65277 +
65278 + /* check transition table */
65279 +
65280 + for (trans = current->role->transitions; trans; trans = trans->next) {
65281 + if (!strcmp(rolename, trans->rolename)) {
65282 + found = 1;
65283 + break;
65284 + }
65285 + }
65286 +
65287 + if (!found)
65288 + return 0;
65289 +
65290 + /* handle special roles that do not require authentication
65291 + and check ip */
65292 +
65293 + FOR_EACH_ROLE_START(r)
65294 + if (!strcmp(rolename, r->rolename) &&
65295 + (r->roletype & GR_ROLE_SPECIAL)) {
65296 + found = 0;
65297 + if (r->allowed_ips != NULL) {
65298 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
65299 + if ((ntohl(curr_ip) & ipp->netmask) ==
65300 + (ntohl(ipp->addr) & ipp->netmask))
65301 + found = 1;
65302 + }
65303 + } else
65304 + found = 2;
65305 + if (!found)
65306 + return 0;
65307 +
65308 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
65309 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
65310 + *salt = NULL;
65311 + *sum = NULL;
65312 + return 1;
65313 + }
65314 + }
65315 + FOR_EACH_ROLE_END(r)
65316 +
65317 + for (i = 0; i < num_sprole_pws; i++) {
65318 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
65319 + *salt = acl_special_roles[i]->salt;
65320 + *sum = acl_special_roles[i]->sum;
65321 + return 1;
65322 + }
65323 + }
65324 +
65325 + return 0;
65326 +}
65327 +
65328 +static void
65329 +assign_special_role(char *rolename)
65330 +{
65331 + struct acl_object_label *obj;
65332 + struct acl_role_label *r;
65333 + struct acl_role_label *assigned = NULL;
65334 + struct task_struct *tsk;
65335 + struct file *filp;
65336 +
65337 + FOR_EACH_ROLE_START(r)
65338 + if (!strcmp(rolename, r->rolename) &&
65339 + (r->roletype & GR_ROLE_SPECIAL)) {
65340 + assigned = r;
65341 + break;
65342 + }
65343 + FOR_EACH_ROLE_END(r)
65344 +
65345 + if (!assigned)
65346 + return;
65347 +
65348 + read_lock(&tasklist_lock);
65349 + read_lock(&grsec_exec_file_lock);
65350 +
65351 + tsk = current->real_parent;
65352 + if (tsk == NULL)
65353 + goto out_unlock;
65354 +
65355 + filp = tsk->exec_file;
65356 + if (filp == NULL)
65357 + goto out_unlock;
65358 +
65359 + tsk->is_writable = 0;
65360 +
65361 + tsk->acl_sp_role = 1;
65362 + tsk->acl_role_id = ++acl_sp_role_value;
65363 + tsk->role = assigned;
65364 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65365 +
65366 + /* ignore additional mmap checks for processes that are writable
65367 + by the default ACL */
65368 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65369 + if (unlikely(obj->mode & GR_WRITE))
65370 + tsk->is_writable = 1;
65371 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65372 + if (unlikely(obj->mode & GR_WRITE))
65373 + tsk->is_writable = 1;
65374 +
65375 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65376 + 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));
65377 +#endif
65378 +
65379 +out_unlock:
65380 + read_unlock(&grsec_exec_file_lock);
65381 + read_unlock(&tasklist_lock);
65382 + return;
65383 +}
65384 +
65385 +int gr_check_secure_terminal(struct task_struct *task)
65386 +{
65387 + struct task_struct *p, *p2, *p3;
65388 + struct files_struct *files;
65389 + struct fdtable *fdt;
65390 + struct file *our_file = NULL, *file;
65391 + int i;
65392 +
65393 + if (task->signal->tty == NULL)
65394 + return 1;
65395 +
65396 + files = get_files_struct(task);
65397 + if (files != NULL) {
65398 + rcu_read_lock();
65399 + fdt = files_fdtable(files);
65400 + for (i=0; i < fdt->max_fds; i++) {
65401 + file = fcheck_files(files, i);
65402 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65403 + get_file(file);
65404 + our_file = file;
65405 + }
65406 + }
65407 + rcu_read_unlock();
65408 + put_files_struct(files);
65409 + }
65410 +
65411 + if (our_file == NULL)
65412 + return 1;
65413 +
65414 + read_lock(&tasklist_lock);
65415 + do_each_thread(p2, p) {
65416 + files = get_files_struct(p);
65417 + if (files == NULL ||
65418 + (p->signal && p->signal->tty == task->signal->tty)) {
65419 + if (files != NULL)
65420 + put_files_struct(files);
65421 + continue;
65422 + }
65423 + rcu_read_lock();
65424 + fdt = files_fdtable(files);
65425 + for (i=0; i < fdt->max_fds; i++) {
65426 + file = fcheck_files(files, i);
65427 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65428 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65429 + p3 = task;
65430 + while (task_pid_nr(p3) > 0) {
65431 + if (p3 == p)
65432 + break;
65433 + p3 = p3->real_parent;
65434 + }
65435 + if (p3 == p)
65436 + break;
65437 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65438 + gr_handle_alertkill(p);
65439 + rcu_read_unlock();
65440 + put_files_struct(files);
65441 + read_unlock(&tasklist_lock);
65442 + fput(our_file);
65443 + return 0;
65444 + }
65445 + }
65446 + rcu_read_unlock();
65447 + put_files_struct(files);
65448 + } while_each_thread(p2, p);
65449 + read_unlock(&tasklist_lock);
65450 +
65451 + fput(our_file);
65452 + return 1;
65453 +}
65454 +
65455 +static int gr_rbac_disable(void *unused)
65456 +{
65457 + pax_open_kernel();
65458 + gr_status &= ~GR_READY;
65459 + pax_close_kernel();
65460 +
65461 + return 0;
65462 +}
65463 +
65464 +ssize_t
65465 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65466 +{
65467 + struct gr_arg_wrapper uwrap;
65468 + unsigned char *sprole_salt = NULL;
65469 + unsigned char *sprole_sum = NULL;
65470 + int error = 0;
65471 + int error2 = 0;
65472 + size_t req_count = 0;
65473 +
65474 + mutex_lock(&gr_dev_mutex);
65475 +
65476 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65477 + error = -EPERM;
65478 + goto out;
65479 + }
65480 +
65481 +#ifdef CONFIG_COMPAT
65482 + pax_open_kernel();
65483 + if (is_compat_task()) {
65484 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65485 + copy_gr_arg = &copy_gr_arg_compat;
65486 + copy_acl_object_label = &copy_acl_object_label_compat;
65487 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65488 + copy_acl_role_label = &copy_acl_role_label_compat;
65489 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65490 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65491 + copy_role_transition = &copy_role_transition_compat;
65492 + copy_sprole_pw = &copy_sprole_pw_compat;
65493 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65494 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65495 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65496 + } else {
65497 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65498 + copy_gr_arg = &copy_gr_arg_normal;
65499 + copy_acl_object_label = &copy_acl_object_label_normal;
65500 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65501 + copy_acl_role_label = &copy_acl_role_label_normal;
65502 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65503 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65504 + copy_role_transition = &copy_role_transition_normal;
65505 + copy_sprole_pw = &copy_sprole_pw_normal;
65506 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65507 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65508 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65509 + }
65510 + pax_close_kernel();
65511 +#endif
65512 +
65513 + req_count = get_gr_arg_wrapper_size();
65514 +
65515 + if (count != req_count) {
65516 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65517 + error = -EINVAL;
65518 + goto out;
65519 + }
65520 +
65521 +
65522 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65523 + gr_auth_expires = 0;
65524 + gr_auth_attempts = 0;
65525 + }
65526 +
65527 + error = copy_gr_arg_wrapper(buf, &uwrap);
65528 + if (error)
65529 + goto out;
65530 +
65531 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65532 + if (error)
65533 + goto out;
65534 +
65535 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65536 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65537 + time_after(gr_auth_expires, get_seconds())) {
65538 + error = -EBUSY;
65539 + goto out;
65540 + }
65541 +
65542 + /* if non-root trying to do anything other than use a special role,
65543 + do not attempt authentication, do not count towards authentication
65544 + locking
65545 + */
65546 +
65547 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65548 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65549 + gr_is_global_nonroot(current_uid())) {
65550 + error = -EPERM;
65551 + goto out;
65552 + }
65553 +
65554 + /* ensure pw and special role name are null terminated */
65555 +
65556 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65557 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65558 +
65559 + /* Okay.
65560 + * We have our enough of the argument structure..(we have yet
65561 + * to copy_from_user the tables themselves) . Copy the tables
65562 + * only if we need them, i.e. for loading operations. */
65563 +
65564 + switch (gr_usermode->mode) {
65565 + case GR_STATUS:
65566 + if (gr_status & GR_READY) {
65567 + error = 1;
65568 + if (!gr_check_secure_terminal(current))
65569 + error = 3;
65570 + } else
65571 + error = 2;
65572 + goto out;
65573 + case GR_SHUTDOWN:
65574 + if ((gr_status & GR_READY)
65575 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65576 + stop_machine(gr_rbac_disable, NULL, NULL);
65577 + free_variables();
65578 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65579 + memset(gr_system_salt, 0, GR_SALT_LEN);
65580 + memset(gr_system_sum, 0, GR_SHA_LEN);
65581 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65582 + } else if (gr_status & GR_READY) {
65583 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65584 + error = -EPERM;
65585 + } else {
65586 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65587 + error = -EAGAIN;
65588 + }
65589 + break;
65590 + case GR_ENABLE:
65591 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65592 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65593 + else {
65594 + if (gr_status & GR_READY)
65595 + error = -EAGAIN;
65596 + else
65597 + error = error2;
65598 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65599 + }
65600 + break;
65601 + case GR_RELOAD:
65602 + if (!(gr_status & GR_READY)) {
65603 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65604 + error = -EAGAIN;
65605 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65606 + stop_machine(gr_rbac_disable, NULL, NULL);
65607 + free_variables();
65608 + error2 = gracl_init(gr_usermode);
65609 + if (!error2)
65610 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65611 + else {
65612 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65613 + error = error2;
65614 + }
65615 + } else {
65616 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65617 + error = -EPERM;
65618 + }
65619 + break;
65620 + case GR_SEGVMOD:
65621 + if (unlikely(!(gr_status & GR_READY))) {
65622 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65623 + error = -EAGAIN;
65624 + break;
65625 + }
65626 +
65627 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65628 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65629 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65630 + struct acl_subject_label *segvacl;
65631 + segvacl =
65632 + lookup_acl_subj_label(gr_usermode->segv_inode,
65633 + gr_usermode->segv_device,
65634 + current->role);
65635 + if (segvacl) {
65636 + segvacl->crashes = 0;
65637 + segvacl->expires = 0;
65638 + }
65639 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65640 + gr_remove_uid(gr_usermode->segv_uid);
65641 + }
65642 + } else {
65643 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65644 + error = -EPERM;
65645 + }
65646 + break;
65647 + case GR_SPROLE:
65648 + case GR_SPROLEPAM:
65649 + if (unlikely(!(gr_status & GR_READY))) {
65650 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65651 + error = -EAGAIN;
65652 + break;
65653 + }
65654 +
65655 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65656 + current->role->expires = 0;
65657 + current->role->auth_attempts = 0;
65658 + }
65659 +
65660 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65661 + time_after(current->role->expires, get_seconds())) {
65662 + error = -EBUSY;
65663 + goto out;
65664 + }
65665 +
65666 + if (lookup_special_role_auth
65667 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65668 + && ((!sprole_salt && !sprole_sum)
65669 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65670 + char *p = "";
65671 + assign_special_role(gr_usermode->sp_role);
65672 + read_lock(&tasklist_lock);
65673 + if (current->real_parent)
65674 + p = current->real_parent->role->rolename;
65675 + read_unlock(&tasklist_lock);
65676 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65677 + p, acl_sp_role_value);
65678 + } else {
65679 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65680 + error = -EPERM;
65681 + if(!(current->role->auth_attempts++))
65682 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65683 +
65684 + goto out;
65685 + }
65686 + break;
65687 + case GR_UNSPROLE:
65688 + if (unlikely(!(gr_status & GR_READY))) {
65689 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65690 + error = -EAGAIN;
65691 + break;
65692 + }
65693 +
65694 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65695 + char *p = "";
65696 + int i = 0;
65697 +
65698 + read_lock(&tasklist_lock);
65699 + if (current->real_parent) {
65700 + p = current->real_parent->role->rolename;
65701 + i = current->real_parent->acl_role_id;
65702 + }
65703 + read_unlock(&tasklist_lock);
65704 +
65705 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65706 + gr_set_acls(1);
65707 + } else {
65708 + error = -EPERM;
65709 + goto out;
65710 + }
65711 + break;
65712 + default:
65713 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65714 + error = -EINVAL;
65715 + break;
65716 + }
65717 +
65718 + if (error != -EPERM)
65719 + goto out;
65720 +
65721 + if(!(gr_auth_attempts++))
65722 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65723 +
65724 + out:
65725 + mutex_unlock(&gr_dev_mutex);
65726 +
65727 + if (!error)
65728 + error = req_count;
65729 +
65730 + return error;
65731 +}
65732 +
65733 +/* must be called with
65734 + rcu_read_lock();
65735 + read_lock(&tasklist_lock);
65736 + read_lock(&grsec_exec_file_lock);
65737 +*/
65738 +int gr_apply_subject_to_task(struct task_struct *task)
65739 +{
65740 + struct acl_object_label *obj;
65741 + char *tmpname;
65742 + struct acl_subject_label *tmpsubj;
65743 + struct file *filp;
65744 + struct name_entry *nmatch;
65745 +
65746 + filp = task->exec_file;
65747 + if (filp == NULL)
65748 + return 0;
65749 +
65750 + /* the following is to apply the correct subject
65751 + on binaries running when the RBAC system
65752 + is enabled, when the binaries have been
65753 + replaced or deleted since their execution
65754 + -----
65755 + when the RBAC system starts, the inode/dev
65756 + from exec_file will be one the RBAC system
65757 + is unaware of. It only knows the inode/dev
65758 + of the present file on disk, or the absence
65759 + of it.
65760 + */
65761 + preempt_disable();
65762 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65763 +
65764 + nmatch = lookup_name_entry(tmpname);
65765 + preempt_enable();
65766 + tmpsubj = NULL;
65767 + if (nmatch) {
65768 + if (nmatch->deleted)
65769 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65770 + else
65771 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65772 + if (tmpsubj != NULL)
65773 + task->acl = tmpsubj;
65774 + }
65775 + if (tmpsubj == NULL)
65776 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65777 + task->role);
65778 + if (task->acl) {
65779 + task->is_writable = 0;
65780 + /* ignore additional mmap checks for processes that are writable
65781 + by the default ACL */
65782 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65783 + if (unlikely(obj->mode & GR_WRITE))
65784 + task->is_writable = 1;
65785 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65786 + if (unlikely(obj->mode & GR_WRITE))
65787 + task->is_writable = 1;
65788 +
65789 + gr_set_proc_res(task);
65790 +
65791 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65792 + 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);
65793 +#endif
65794 + } else {
65795 + return 1;
65796 + }
65797 +
65798 + return 0;
65799 +}
65800 +
65801 +int
65802 +gr_set_acls(const int type)
65803 +{
65804 + struct task_struct *task, *task2;
65805 + struct acl_role_label *role = current->role;
65806 + __u16 acl_role_id = current->acl_role_id;
65807 + const struct cred *cred;
65808 + int ret;
65809 +
65810 + rcu_read_lock();
65811 + read_lock(&tasklist_lock);
65812 + read_lock(&grsec_exec_file_lock);
65813 + do_each_thread(task2, task) {
65814 + /* check to see if we're called from the exit handler,
65815 + if so, only replace ACLs that have inherited the admin
65816 + ACL */
65817 +
65818 + if (type && (task->role != role ||
65819 + task->acl_role_id != acl_role_id))
65820 + continue;
65821 +
65822 + task->acl_role_id = 0;
65823 + task->acl_sp_role = 0;
65824 +
65825 + if (task->exec_file) {
65826 + cred = __task_cred(task);
65827 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65828 + ret = gr_apply_subject_to_task(task);
65829 + if (ret) {
65830 + read_unlock(&grsec_exec_file_lock);
65831 + read_unlock(&tasklist_lock);
65832 + rcu_read_unlock();
65833 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65834 + return ret;
65835 + }
65836 + } else {
65837 + // it's a kernel process
65838 + task->role = kernel_role;
65839 + task->acl = kernel_role->root_label;
65840 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65841 + task->acl->mode &= ~GR_PROCFIND;
65842 +#endif
65843 + }
65844 + } while_each_thread(task2, task);
65845 + read_unlock(&grsec_exec_file_lock);
65846 + read_unlock(&tasklist_lock);
65847 + rcu_read_unlock();
65848 +
65849 + return 0;
65850 +}
65851 +
65852 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65853 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65854 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65855 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65856 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65857 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65858 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65859 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65860 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65861 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65862 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65863 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65864 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65865 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65866 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65867 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65868 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65869 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65870 +};
65871 +
65872 +void
65873 +gr_learn_resource(const struct task_struct *task,
65874 + const int res, const unsigned long wanted, const int gt)
65875 +{
65876 + struct acl_subject_label *acl;
65877 + const struct cred *cred;
65878 +
65879 + if (unlikely((gr_status & GR_READY) &&
65880 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65881 + goto skip_reslog;
65882 +
65883 + gr_log_resource(task, res, wanted, gt);
65884 +skip_reslog:
65885 +
65886 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65887 + return;
65888 +
65889 + acl = task->acl;
65890 +
65891 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65892 + !(acl->resmask & (1U << (unsigned short) res))))
65893 + return;
65894 +
65895 + if (wanted >= acl->res[res].rlim_cur) {
65896 + unsigned long res_add;
65897 +
65898 + res_add = wanted + res_learn_bumps[res];
65899 +
65900 + acl->res[res].rlim_cur = res_add;
65901 +
65902 + if (wanted > acl->res[res].rlim_max)
65903 + acl->res[res].rlim_max = res_add;
65904 +
65905 + /* only log the subject filename, since resource logging is supported for
65906 + single-subject learning only */
65907 + rcu_read_lock();
65908 + cred = __task_cred(task);
65909 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65910 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65911 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65912 + "", (unsigned long) res, &task->signal->saved_ip);
65913 + rcu_read_unlock();
65914 + }
65915 +
65916 + return;
65917 +}
65918 +EXPORT_SYMBOL(gr_learn_resource);
65919 +#endif
65920 +
65921 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65922 +void
65923 +pax_set_initial_flags(struct linux_binprm *bprm)
65924 +{
65925 + struct task_struct *task = current;
65926 + struct acl_subject_label *proc;
65927 + unsigned long flags;
65928 +
65929 + if (unlikely(!(gr_status & GR_READY)))
65930 + return;
65931 +
65932 + flags = pax_get_flags(task);
65933 +
65934 + proc = task->acl;
65935 +
65936 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65937 + flags &= ~MF_PAX_PAGEEXEC;
65938 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65939 + flags &= ~MF_PAX_SEGMEXEC;
65940 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65941 + flags &= ~MF_PAX_RANDMMAP;
65942 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65943 + flags &= ~MF_PAX_EMUTRAMP;
65944 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65945 + flags &= ~MF_PAX_MPROTECT;
65946 +
65947 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65948 + flags |= MF_PAX_PAGEEXEC;
65949 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65950 + flags |= MF_PAX_SEGMEXEC;
65951 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65952 + flags |= MF_PAX_RANDMMAP;
65953 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65954 + flags |= MF_PAX_EMUTRAMP;
65955 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65956 + flags |= MF_PAX_MPROTECT;
65957 +
65958 + pax_set_flags(task, flags);
65959 +
65960 + return;
65961 +}
65962 +#endif
65963 +
65964 +int
65965 +gr_handle_proc_ptrace(struct task_struct *task)
65966 +{
65967 + struct file *filp;
65968 + struct task_struct *tmp = task;
65969 + struct task_struct *curtemp = current;
65970 + __u32 retmode;
65971 +
65972 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65973 + if (unlikely(!(gr_status & GR_READY)))
65974 + return 0;
65975 +#endif
65976 +
65977 + read_lock(&tasklist_lock);
65978 + read_lock(&grsec_exec_file_lock);
65979 + filp = task->exec_file;
65980 +
65981 + while (task_pid_nr(tmp) > 0) {
65982 + if (tmp == curtemp)
65983 + break;
65984 + tmp = tmp->real_parent;
65985 + }
65986 +
65987 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65988 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65989 + read_unlock(&grsec_exec_file_lock);
65990 + read_unlock(&tasklist_lock);
65991 + return 1;
65992 + }
65993 +
65994 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65995 + if (!(gr_status & GR_READY)) {
65996 + read_unlock(&grsec_exec_file_lock);
65997 + read_unlock(&tasklist_lock);
65998 + return 0;
65999 + }
66000 +#endif
66001 +
66002 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
66003 + read_unlock(&grsec_exec_file_lock);
66004 + read_unlock(&tasklist_lock);
66005 +
66006 + if (retmode & GR_NOPTRACE)
66007 + return 1;
66008 +
66009 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
66010 + && (current->acl != task->acl || (current->acl != current->role->root_label
66011 + && task_pid_nr(current) != task_pid_nr(task))))
66012 + return 1;
66013 +
66014 + return 0;
66015 +}
66016 +
66017 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
66018 +{
66019 + if (unlikely(!(gr_status & GR_READY)))
66020 + return;
66021 +
66022 + if (!(current->role->roletype & GR_ROLE_GOD))
66023 + return;
66024 +
66025 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
66026 + p->role->rolename, gr_task_roletype_to_char(p),
66027 + p->acl->filename);
66028 +}
66029 +
66030 +int
66031 +gr_handle_ptrace(struct task_struct *task, const long request)
66032 +{
66033 + struct task_struct *tmp = task;
66034 + struct task_struct *curtemp = current;
66035 + __u32 retmode;
66036 +
66037 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66038 + if (unlikely(!(gr_status & GR_READY)))
66039 + return 0;
66040 +#endif
66041 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66042 + read_lock(&tasklist_lock);
66043 + while (task_pid_nr(tmp) > 0) {
66044 + if (tmp == curtemp)
66045 + break;
66046 + tmp = tmp->real_parent;
66047 + }
66048 +
66049 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66050 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66051 + read_unlock(&tasklist_lock);
66052 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66053 + return 1;
66054 + }
66055 + read_unlock(&tasklist_lock);
66056 + }
66057 +
66058 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66059 + if (!(gr_status & GR_READY))
66060 + return 0;
66061 +#endif
66062 +
66063 + read_lock(&grsec_exec_file_lock);
66064 + if (unlikely(!task->exec_file)) {
66065 + read_unlock(&grsec_exec_file_lock);
66066 + return 0;
66067 + }
66068 +
66069 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66070 + read_unlock(&grsec_exec_file_lock);
66071 +
66072 + if (retmode & GR_NOPTRACE) {
66073 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66074 + return 1;
66075 + }
66076 +
66077 + if (retmode & GR_PTRACERD) {
66078 + switch (request) {
66079 + case PTRACE_SEIZE:
66080 + case PTRACE_POKETEXT:
66081 + case PTRACE_POKEDATA:
66082 + case PTRACE_POKEUSR:
66083 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66084 + case PTRACE_SETREGS:
66085 + case PTRACE_SETFPREGS:
66086 +#endif
66087 +#ifdef CONFIG_X86
66088 + case PTRACE_SETFPXREGS:
66089 +#endif
66090 +#ifdef CONFIG_ALTIVEC
66091 + case PTRACE_SETVRREGS:
66092 +#endif
66093 + return 1;
66094 + default:
66095 + return 0;
66096 + }
66097 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66098 + !(current->role->roletype & GR_ROLE_GOD) &&
66099 + (current->acl != task->acl)) {
66100 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66101 + return 1;
66102 + }
66103 +
66104 + return 0;
66105 +}
66106 +
66107 +static int is_writable_mmap(const struct file *filp)
66108 +{
66109 + struct task_struct *task = current;
66110 + struct acl_object_label *obj, *obj2;
66111 +
66112 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66113 + !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))) {
66114 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66115 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66116 + task->role->root_label);
66117 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66118 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66119 + return 1;
66120 + }
66121 + }
66122 + return 0;
66123 +}
66124 +
66125 +int
66126 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66127 +{
66128 + __u32 mode;
66129 +
66130 + if (unlikely(!file || !(prot & PROT_EXEC)))
66131 + return 1;
66132 +
66133 + if (is_writable_mmap(file))
66134 + return 0;
66135 +
66136 + mode =
66137 + gr_search_file(file->f_path.dentry,
66138 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66139 + file->f_path.mnt);
66140 +
66141 + if (!gr_tpe_allow(file))
66142 + return 0;
66143 +
66144 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66145 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66146 + return 0;
66147 + } else if (unlikely(!(mode & GR_EXEC))) {
66148 + return 0;
66149 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66150 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66151 + return 1;
66152 + }
66153 +
66154 + return 1;
66155 +}
66156 +
66157 +int
66158 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66159 +{
66160 + __u32 mode;
66161 +
66162 + if (unlikely(!file || !(prot & PROT_EXEC)))
66163 + return 1;
66164 +
66165 + if (is_writable_mmap(file))
66166 + return 0;
66167 +
66168 + mode =
66169 + gr_search_file(file->f_path.dentry,
66170 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66171 + file->f_path.mnt);
66172 +
66173 + if (!gr_tpe_allow(file))
66174 + return 0;
66175 +
66176 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66177 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66178 + return 0;
66179 + } else if (unlikely(!(mode & GR_EXEC))) {
66180 + return 0;
66181 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66182 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66183 + return 1;
66184 + }
66185 +
66186 + return 1;
66187 +}
66188 +
66189 +void
66190 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66191 +{
66192 + unsigned long runtime;
66193 + unsigned long cputime;
66194 + unsigned int wday, cday;
66195 + __u8 whr, chr;
66196 + __u8 wmin, cmin;
66197 + __u8 wsec, csec;
66198 + struct timespec timeval;
66199 +
66200 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66201 + !(task->acl->mode & GR_PROCACCT)))
66202 + return;
66203 +
66204 + do_posix_clock_monotonic_gettime(&timeval);
66205 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66206 + wday = runtime / (3600 * 24);
66207 + runtime -= wday * (3600 * 24);
66208 + whr = runtime / 3600;
66209 + runtime -= whr * 3600;
66210 + wmin = runtime / 60;
66211 + runtime -= wmin * 60;
66212 + wsec = runtime;
66213 +
66214 + cputime = (task->utime + task->stime) / HZ;
66215 + cday = cputime / (3600 * 24);
66216 + cputime -= cday * (3600 * 24);
66217 + chr = cputime / 3600;
66218 + cputime -= chr * 3600;
66219 + cmin = cputime / 60;
66220 + cputime -= cmin * 60;
66221 + csec = cputime;
66222 +
66223 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66224 +
66225 + return;
66226 +}
66227 +
66228 +void gr_set_kernel_label(struct task_struct *task)
66229 +{
66230 + if (gr_status & GR_READY) {
66231 + task->role = kernel_role;
66232 + task->acl = kernel_role->root_label;
66233 + }
66234 + return;
66235 +}
66236 +
66237 +#ifdef CONFIG_TASKSTATS
66238 +int gr_is_taskstats_denied(int pid)
66239 +{
66240 + struct task_struct *task;
66241 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66242 + const struct cred *cred;
66243 +#endif
66244 + int ret = 0;
66245 +
66246 + /* restrict taskstats viewing to un-chrooted root users
66247 + who have the 'view' subject flag if the RBAC system is enabled
66248 + */
66249 +
66250 + rcu_read_lock();
66251 + read_lock(&tasklist_lock);
66252 + task = find_task_by_vpid(pid);
66253 + if (task) {
66254 +#ifdef CONFIG_GRKERNSEC_CHROOT
66255 + if (proc_is_chrooted(task))
66256 + ret = -EACCES;
66257 +#endif
66258 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66259 + cred = __task_cred(task);
66260 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66261 + if (gr_is_global_nonroot(cred->uid))
66262 + ret = -EACCES;
66263 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66264 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66265 + ret = -EACCES;
66266 +#endif
66267 +#endif
66268 + if (gr_status & GR_READY) {
66269 + if (!(task->acl->mode & GR_VIEW))
66270 + ret = -EACCES;
66271 + }
66272 + } else
66273 + ret = -ENOENT;
66274 +
66275 + read_unlock(&tasklist_lock);
66276 + rcu_read_unlock();
66277 +
66278 + return ret;
66279 +}
66280 +#endif
66281 +
66282 +/* AUXV entries are filled via a descendant of search_binary_handler
66283 + after we've already applied the subject for the target
66284 +*/
66285 +int gr_acl_enable_at_secure(void)
66286 +{
66287 + if (unlikely(!(gr_status & GR_READY)))
66288 + return 0;
66289 +
66290 + if (current->acl->mode & GR_ATSECURE)
66291 + return 1;
66292 +
66293 + return 0;
66294 +}
66295 +
66296 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66297 +{
66298 + struct task_struct *task = current;
66299 + struct dentry *dentry = file->f_path.dentry;
66300 + struct vfsmount *mnt = file->f_path.mnt;
66301 + struct acl_object_label *obj, *tmp;
66302 + struct acl_subject_label *subj;
66303 + unsigned int bufsize;
66304 + int is_not_root;
66305 + char *path;
66306 + dev_t dev = __get_dev(dentry);
66307 +
66308 + if (unlikely(!(gr_status & GR_READY)))
66309 + return 1;
66310 +
66311 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66312 + return 1;
66313 +
66314 + /* ignore Eric Biederman */
66315 + if (IS_PRIVATE(dentry->d_inode))
66316 + return 1;
66317 +
66318 + subj = task->acl;
66319 + read_lock(&gr_inode_lock);
66320 + do {
66321 + obj = lookup_acl_obj_label(ino, dev, subj);
66322 + if (obj != NULL) {
66323 + read_unlock(&gr_inode_lock);
66324 + return (obj->mode & GR_FIND) ? 1 : 0;
66325 + }
66326 + } while ((subj = subj->parent_subject));
66327 + read_unlock(&gr_inode_lock);
66328 +
66329 + /* this is purely an optimization since we're looking for an object
66330 + for the directory we're doing a readdir on
66331 + if it's possible for any globbed object to match the entry we're
66332 + filling into the directory, then the object we find here will be
66333 + an anchor point with attached globbed objects
66334 + */
66335 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66336 + if (obj->globbed == NULL)
66337 + return (obj->mode & GR_FIND) ? 1 : 0;
66338 +
66339 + is_not_root = ((obj->filename[0] == '/') &&
66340 + (obj->filename[1] == '\0')) ? 0 : 1;
66341 + bufsize = PAGE_SIZE - namelen - is_not_root;
66342 +
66343 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66344 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66345 + return 1;
66346 +
66347 + preempt_disable();
66348 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66349 + bufsize);
66350 +
66351 + bufsize = strlen(path);
66352 +
66353 + /* if base is "/", don't append an additional slash */
66354 + if (is_not_root)
66355 + *(path + bufsize) = '/';
66356 + memcpy(path + bufsize + is_not_root, name, namelen);
66357 + *(path + bufsize + namelen + is_not_root) = '\0';
66358 +
66359 + tmp = obj->globbed;
66360 + while (tmp) {
66361 + if (!glob_match(tmp->filename, path)) {
66362 + preempt_enable();
66363 + return (tmp->mode & GR_FIND) ? 1 : 0;
66364 + }
66365 + tmp = tmp->next;
66366 + }
66367 + preempt_enable();
66368 + return (obj->mode & GR_FIND) ? 1 : 0;
66369 +}
66370 +
66371 +void gr_put_exec_file(struct task_struct *task)
66372 +{
66373 + struct file *filp;
66374 +
66375 + write_lock(&grsec_exec_file_lock);
66376 + filp = task->exec_file;
66377 + task->exec_file = NULL;
66378 + write_unlock(&grsec_exec_file_lock);
66379 +
66380 + if (filp)
66381 + fput(filp);
66382 +
66383 + return;
66384 +}
66385 +
66386 +
66387 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66388 +EXPORT_SYMBOL(gr_acl_is_enabled);
66389 +#endif
66390 +EXPORT_SYMBOL(gr_set_kernel_label);
66391 +#ifdef CONFIG_SECURITY
66392 +EXPORT_SYMBOL(gr_check_user_change);
66393 +EXPORT_SYMBOL(gr_check_group_change);
66394 +#endif
66395 +
66396 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66397 new file mode 100644
66398 index 0000000..34fefda
66399 --- /dev/null
66400 +++ b/grsecurity/gracl_alloc.c
66401 @@ -0,0 +1,105 @@
66402 +#include <linux/kernel.h>
66403 +#include <linux/mm.h>
66404 +#include <linux/slab.h>
66405 +#include <linux/vmalloc.h>
66406 +#include <linux/gracl.h>
66407 +#include <linux/grsecurity.h>
66408 +
66409 +static unsigned long alloc_stack_next = 1;
66410 +static unsigned long alloc_stack_size = 1;
66411 +static void **alloc_stack;
66412 +
66413 +static __inline__ int
66414 +alloc_pop(void)
66415 +{
66416 + if (alloc_stack_next == 1)
66417 + return 0;
66418 +
66419 + kfree(alloc_stack[alloc_stack_next - 2]);
66420 +
66421 + alloc_stack_next--;
66422 +
66423 + return 1;
66424 +}
66425 +
66426 +static __inline__ int
66427 +alloc_push(void *buf)
66428 +{
66429 + if (alloc_stack_next >= alloc_stack_size)
66430 + return 1;
66431 +
66432 + alloc_stack[alloc_stack_next - 1] = buf;
66433 +
66434 + alloc_stack_next++;
66435 +
66436 + return 0;
66437 +}
66438 +
66439 +void *
66440 +acl_alloc(unsigned long len)
66441 +{
66442 + void *ret = NULL;
66443 +
66444 + if (!len || len > PAGE_SIZE)
66445 + goto out;
66446 +
66447 + ret = kmalloc(len, GFP_KERNEL);
66448 +
66449 + if (ret) {
66450 + if (alloc_push(ret)) {
66451 + kfree(ret);
66452 + ret = NULL;
66453 + }
66454 + }
66455 +
66456 +out:
66457 + return ret;
66458 +}
66459 +
66460 +void *
66461 +acl_alloc_num(unsigned long num, unsigned long len)
66462 +{
66463 + if (!len || (num > (PAGE_SIZE / len)))
66464 + return NULL;
66465 +
66466 + return acl_alloc(num * len);
66467 +}
66468 +
66469 +void
66470 +acl_free_all(void)
66471 +{
66472 + if (gr_acl_is_enabled() || !alloc_stack)
66473 + return;
66474 +
66475 + while (alloc_pop()) ;
66476 +
66477 + if (alloc_stack) {
66478 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66479 + kfree(alloc_stack);
66480 + else
66481 + vfree(alloc_stack);
66482 + }
66483 +
66484 + alloc_stack = NULL;
66485 + alloc_stack_size = 1;
66486 + alloc_stack_next = 1;
66487 +
66488 + return;
66489 +}
66490 +
66491 +int
66492 +acl_alloc_stack_init(unsigned long size)
66493 +{
66494 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66495 + alloc_stack =
66496 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66497 + else
66498 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66499 +
66500 + alloc_stack_size = size;
66501 +
66502 + if (!alloc_stack)
66503 + return 0;
66504 + else
66505 + return 1;
66506 +}
66507 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66508 new file mode 100644
66509 index 0000000..bdd51ea
66510 --- /dev/null
66511 +++ b/grsecurity/gracl_cap.c
66512 @@ -0,0 +1,110 @@
66513 +#include <linux/kernel.h>
66514 +#include <linux/module.h>
66515 +#include <linux/sched.h>
66516 +#include <linux/gracl.h>
66517 +#include <linux/grsecurity.h>
66518 +#include <linux/grinternal.h>
66519 +
66520 +extern const char *captab_log[];
66521 +extern int captab_log_entries;
66522 +
66523 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66524 +{
66525 + struct acl_subject_label *curracl;
66526 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66527 + kernel_cap_t cap_audit = __cap_empty_set;
66528 +
66529 + if (!gr_acl_is_enabled())
66530 + return 1;
66531 +
66532 + curracl = task->acl;
66533 +
66534 + cap_drop = curracl->cap_lower;
66535 + cap_mask = curracl->cap_mask;
66536 + cap_audit = curracl->cap_invert_audit;
66537 +
66538 + while ((curracl = curracl->parent_subject)) {
66539 + /* if the cap isn't specified in the current computed mask but is specified in the
66540 + current level subject, and is lowered in the current level subject, then add
66541 + it to the set of dropped capabilities
66542 + otherwise, add the current level subject's mask to the current computed mask
66543 + */
66544 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66545 + cap_raise(cap_mask, cap);
66546 + if (cap_raised(curracl->cap_lower, cap))
66547 + cap_raise(cap_drop, cap);
66548 + if (cap_raised(curracl->cap_invert_audit, cap))
66549 + cap_raise(cap_audit, cap);
66550 + }
66551 + }
66552 +
66553 + if (!cap_raised(cap_drop, cap)) {
66554 + if (cap_raised(cap_audit, cap))
66555 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66556 + return 1;
66557 + }
66558 +
66559 + curracl = task->acl;
66560 +
66561 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66562 + && cap_raised(cred->cap_effective, cap)) {
66563 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66564 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66565 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66566 + gr_to_filename(task->exec_file->f_path.dentry,
66567 + task->exec_file->f_path.mnt) : curracl->filename,
66568 + curracl->filename, 0UL,
66569 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66570 + return 1;
66571 + }
66572 +
66573 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66574 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66575 +
66576 + return 0;
66577 +}
66578 +
66579 +int
66580 +gr_acl_is_capable(const int cap)
66581 +{
66582 + return gr_task_acl_is_capable(current, current_cred(), cap);
66583 +}
66584 +
66585 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66586 +{
66587 + struct acl_subject_label *curracl;
66588 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66589 +
66590 + if (!gr_acl_is_enabled())
66591 + return 1;
66592 +
66593 + curracl = task->acl;
66594 +
66595 + cap_drop = curracl->cap_lower;
66596 + cap_mask = curracl->cap_mask;
66597 +
66598 + while ((curracl = curracl->parent_subject)) {
66599 + /* if the cap isn't specified in the current computed mask but is specified in the
66600 + current level subject, and is lowered in the current level subject, then add
66601 + it to the set of dropped capabilities
66602 + otherwise, add the current level subject's mask to the current computed mask
66603 + */
66604 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66605 + cap_raise(cap_mask, cap);
66606 + if (cap_raised(curracl->cap_lower, cap))
66607 + cap_raise(cap_drop, cap);
66608 + }
66609 + }
66610 +
66611 + if (!cap_raised(cap_drop, cap))
66612 + return 1;
66613 +
66614 + return 0;
66615 +}
66616 +
66617 +int
66618 +gr_acl_is_capable_nolog(const int cap)
66619 +{
66620 + return gr_task_acl_is_capable_nolog(current, cap);
66621 +}
66622 +
66623 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66624 new file mode 100644
66625 index 0000000..a43dd06
66626 --- /dev/null
66627 +++ b/grsecurity/gracl_compat.c
66628 @@ -0,0 +1,269 @@
66629 +#include <linux/kernel.h>
66630 +#include <linux/gracl.h>
66631 +#include <linux/compat.h>
66632 +#include <linux/gracl_compat.h>
66633 +
66634 +#include <asm/uaccess.h>
66635 +
66636 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66637 +{
66638 + struct gr_arg_wrapper_compat uwrapcompat;
66639 +
66640 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66641 + return -EFAULT;
66642 +
66643 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66644 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66645 + return -EINVAL;
66646 +
66647 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66648 + uwrap->version = uwrapcompat.version;
66649 + uwrap->size = sizeof(struct gr_arg);
66650 +
66651 + return 0;
66652 +}
66653 +
66654 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66655 +{
66656 + struct gr_arg_compat argcompat;
66657 +
66658 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66659 + return -EFAULT;
66660 +
66661 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66662 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66663 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66664 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66665 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66666 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66667 +
66668 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66669 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66670 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66671 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66672 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66673 + arg->segv_device = argcompat.segv_device;
66674 + arg->segv_inode = argcompat.segv_inode;
66675 + arg->segv_uid = argcompat.segv_uid;
66676 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66677 + arg->mode = argcompat.mode;
66678 +
66679 + return 0;
66680 +}
66681 +
66682 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66683 +{
66684 + struct acl_object_label_compat objcompat;
66685 +
66686 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66687 + return -EFAULT;
66688 +
66689 + obj->filename = compat_ptr(objcompat.filename);
66690 + obj->inode = objcompat.inode;
66691 + obj->device = objcompat.device;
66692 + obj->mode = objcompat.mode;
66693 +
66694 + obj->nested = compat_ptr(objcompat.nested);
66695 + obj->globbed = compat_ptr(objcompat.globbed);
66696 +
66697 + obj->prev = compat_ptr(objcompat.prev);
66698 + obj->next = compat_ptr(objcompat.next);
66699 +
66700 + return 0;
66701 +}
66702 +
66703 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66704 +{
66705 + unsigned int i;
66706 + struct acl_subject_label_compat subjcompat;
66707 +
66708 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66709 + return -EFAULT;
66710 +
66711 + subj->filename = compat_ptr(subjcompat.filename);
66712 + subj->inode = subjcompat.inode;
66713 + subj->device = subjcompat.device;
66714 + subj->mode = subjcompat.mode;
66715 + subj->cap_mask = subjcompat.cap_mask;
66716 + subj->cap_lower = subjcompat.cap_lower;
66717 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66718 +
66719 + for (i = 0; i < GR_NLIMITS; i++) {
66720 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66721 + subj->res[i].rlim_cur = RLIM_INFINITY;
66722 + else
66723 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66724 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66725 + subj->res[i].rlim_max = RLIM_INFINITY;
66726 + else
66727 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66728 + }
66729 + subj->resmask = subjcompat.resmask;
66730 +
66731 + subj->user_trans_type = subjcompat.user_trans_type;
66732 + subj->group_trans_type = subjcompat.group_trans_type;
66733 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66734 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66735 + subj->user_trans_num = subjcompat.user_trans_num;
66736 + subj->group_trans_num = subjcompat.group_trans_num;
66737 +
66738 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66739 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66740 + subj->ip_type = subjcompat.ip_type;
66741 + subj->ips = compat_ptr(subjcompat.ips);
66742 + subj->ip_num = subjcompat.ip_num;
66743 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66744 +
66745 + subj->crashes = subjcompat.crashes;
66746 + subj->expires = subjcompat.expires;
66747 +
66748 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66749 + subj->hash = compat_ptr(subjcompat.hash);
66750 + subj->prev = compat_ptr(subjcompat.prev);
66751 + subj->next = compat_ptr(subjcompat.next);
66752 +
66753 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66754 + subj->obj_hash_size = subjcompat.obj_hash_size;
66755 + subj->pax_flags = subjcompat.pax_flags;
66756 +
66757 + return 0;
66758 +}
66759 +
66760 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66761 +{
66762 + struct acl_role_label_compat rolecompat;
66763 +
66764 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66765 + return -EFAULT;
66766 +
66767 + role->rolename = compat_ptr(rolecompat.rolename);
66768 + role->uidgid = rolecompat.uidgid;
66769 + role->roletype = rolecompat.roletype;
66770 +
66771 + role->auth_attempts = rolecompat.auth_attempts;
66772 + role->expires = rolecompat.expires;
66773 +
66774 + role->root_label = compat_ptr(rolecompat.root_label);
66775 + role->hash = compat_ptr(rolecompat.hash);
66776 +
66777 + role->prev = compat_ptr(rolecompat.prev);
66778 + role->next = compat_ptr(rolecompat.next);
66779 +
66780 + role->transitions = compat_ptr(rolecompat.transitions);
66781 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66782 + role->domain_children = compat_ptr(rolecompat.domain_children);
66783 + role->domain_child_num = rolecompat.domain_child_num;
66784 +
66785 + role->umask = rolecompat.umask;
66786 +
66787 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66788 + role->subj_hash_size = rolecompat.subj_hash_size;
66789 +
66790 + return 0;
66791 +}
66792 +
66793 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66794 +{
66795 + struct role_allowed_ip_compat roleip_compat;
66796 +
66797 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66798 + return -EFAULT;
66799 +
66800 + roleip->addr = roleip_compat.addr;
66801 + roleip->netmask = roleip_compat.netmask;
66802 +
66803 + roleip->prev = compat_ptr(roleip_compat.prev);
66804 + roleip->next = compat_ptr(roleip_compat.next);
66805 +
66806 + return 0;
66807 +}
66808 +
66809 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66810 +{
66811 + struct role_transition_compat trans_compat;
66812 +
66813 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66814 + return -EFAULT;
66815 +
66816 + trans->rolename = compat_ptr(trans_compat.rolename);
66817 +
66818 + trans->prev = compat_ptr(trans_compat.prev);
66819 + trans->next = compat_ptr(trans_compat.next);
66820 +
66821 + return 0;
66822 +
66823 +}
66824 +
66825 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66826 +{
66827 + struct gr_hash_struct_compat hash_compat;
66828 +
66829 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66830 + return -EFAULT;
66831 +
66832 + hash->table = compat_ptr(hash_compat.table);
66833 + hash->nametable = compat_ptr(hash_compat.nametable);
66834 + hash->first = compat_ptr(hash_compat.first);
66835 +
66836 + hash->table_size = hash_compat.table_size;
66837 + hash->used_size = hash_compat.used_size;
66838 +
66839 + hash->type = hash_compat.type;
66840 +
66841 + return 0;
66842 +}
66843 +
66844 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66845 +{
66846 + compat_uptr_t ptrcompat;
66847 +
66848 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66849 + return -EFAULT;
66850 +
66851 + *(void **)ptr = compat_ptr(ptrcompat);
66852 +
66853 + return 0;
66854 +}
66855 +
66856 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66857 +{
66858 + struct acl_ip_label_compat ip_compat;
66859 +
66860 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66861 + return -EFAULT;
66862 +
66863 + ip->iface = compat_ptr(ip_compat.iface);
66864 + ip->addr = ip_compat.addr;
66865 + ip->netmask = ip_compat.netmask;
66866 + ip->low = ip_compat.low;
66867 + ip->high = ip_compat.high;
66868 + ip->mode = ip_compat.mode;
66869 + ip->type = ip_compat.type;
66870 +
66871 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66872 +
66873 + ip->prev = compat_ptr(ip_compat.prev);
66874 + ip->next = compat_ptr(ip_compat.next);
66875 +
66876 + return 0;
66877 +}
66878 +
66879 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66880 +{
66881 + struct sprole_pw_compat pw_compat;
66882 +
66883 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66884 + return -EFAULT;
66885 +
66886 + pw->rolename = compat_ptr(pw_compat.rolename);
66887 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66888 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66889 +
66890 + return 0;
66891 +}
66892 +
66893 +size_t get_gr_arg_wrapper_size_compat(void)
66894 +{
66895 + return sizeof(struct gr_arg_wrapper_compat);
66896 +}
66897 +
66898 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66899 new file mode 100644
66900 index 0000000..a340c17
66901 --- /dev/null
66902 +++ b/grsecurity/gracl_fs.c
66903 @@ -0,0 +1,431 @@
66904 +#include <linux/kernel.h>
66905 +#include <linux/sched.h>
66906 +#include <linux/types.h>
66907 +#include <linux/fs.h>
66908 +#include <linux/file.h>
66909 +#include <linux/stat.h>
66910 +#include <linux/grsecurity.h>
66911 +#include <linux/grinternal.h>
66912 +#include <linux/gracl.h>
66913 +
66914 +umode_t
66915 +gr_acl_umask(void)
66916 +{
66917 + if (unlikely(!gr_acl_is_enabled()))
66918 + return 0;
66919 +
66920 + return current->role->umask;
66921 +}
66922 +
66923 +__u32
66924 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66925 + const struct vfsmount * mnt)
66926 +{
66927 + __u32 mode;
66928 +
66929 + if (unlikely(!dentry->d_inode))
66930 + return GR_FIND;
66931 +
66932 + mode =
66933 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66934 +
66935 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66936 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66937 + return mode;
66938 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66939 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66940 + return 0;
66941 + } else if (unlikely(!(mode & GR_FIND)))
66942 + return 0;
66943 +
66944 + return GR_FIND;
66945 +}
66946 +
66947 +__u32
66948 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66949 + int acc_mode)
66950 +{
66951 + __u32 reqmode = GR_FIND;
66952 + __u32 mode;
66953 +
66954 + if (unlikely(!dentry->d_inode))
66955 + return reqmode;
66956 +
66957 + if (acc_mode & MAY_APPEND)
66958 + reqmode |= GR_APPEND;
66959 + else if (acc_mode & MAY_WRITE)
66960 + reqmode |= GR_WRITE;
66961 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66962 + reqmode |= GR_READ;
66963 +
66964 + mode =
66965 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66966 + mnt);
66967 +
66968 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66969 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66970 + reqmode & GR_READ ? " reading" : "",
66971 + reqmode & GR_WRITE ? " writing" : reqmode &
66972 + GR_APPEND ? " appending" : "");
66973 + return reqmode;
66974 + } else
66975 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66976 + {
66977 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66978 + reqmode & GR_READ ? " reading" : "",
66979 + reqmode & GR_WRITE ? " writing" : reqmode &
66980 + GR_APPEND ? " appending" : "");
66981 + return 0;
66982 + } else if (unlikely((mode & reqmode) != reqmode))
66983 + return 0;
66984 +
66985 + return reqmode;
66986 +}
66987 +
66988 +__u32
66989 +gr_acl_handle_creat(const struct dentry * dentry,
66990 + const struct dentry * p_dentry,
66991 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66992 + const int imode)
66993 +{
66994 + __u32 reqmode = GR_WRITE | GR_CREATE;
66995 + __u32 mode;
66996 +
66997 + if (acc_mode & MAY_APPEND)
66998 + reqmode |= GR_APPEND;
66999 + // if a directory was required or the directory already exists, then
67000 + // don't count this open as a read
67001 + if ((acc_mode & MAY_READ) &&
67002 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
67003 + reqmode |= GR_READ;
67004 + if ((open_flags & O_CREAT) &&
67005 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67006 + reqmode |= GR_SETID;
67007 +
67008 + mode =
67009 + gr_check_create(dentry, p_dentry, p_mnt,
67010 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67011 +
67012 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67013 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67014 + reqmode & GR_READ ? " reading" : "",
67015 + reqmode & GR_WRITE ? " writing" : reqmode &
67016 + GR_APPEND ? " appending" : "");
67017 + return reqmode;
67018 + } else
67019 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67020 + {
67021 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67022 + reqmode & GR_READ ? " reading" : "",
67023 + reqmode & GR_WRITE ? " writing" : reqmode &
67024 + GR_APPEND ? " appending" : "");
67025 + return 0;
67026 + } else if (unlikely((mode & reqmode) != reqmode))
67027 + return 0;
67028 +
67029 + return reqmode;
67030 +}
67031 +
67032 +__u32
67033 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67034 + const int fmode)
67035 +{
67036 + __u32 mode, reqmode = GR_FIND;
67037 +
67038 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67039 + reqmode |= GR_EXEC;
67040 + if (fmode & S_IWOTH)
67041 + reqmode |= GR_WRITE;
67042 + if (fmode & S_IROTH)
67043 + reqmode |= GR_READ;
67044 +
67045 + mode =
67046 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67047 + mnt);
67048 +
67049 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67050 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67051 + reqmode & GR_READ ? " reading" : "",
67052 + reqmode & GR_WRITE ? " writing" : "",
67053 + reqmode & GR_EXEC ? " executing" : "");
67054 + return reqmode;
67055 + } else
67056 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67057 + {
67058 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67059 + reqmode & GR_READ ? " reading" : "",
67060 + reqmode & GR_WRITE ? " writing" : "",
67061 + reqmode & GR_EXEC ? " executing" : "");
67062 + return 0;
67063 + } else if (unlikely((mode & reqmode) != reqmode))
67064 + return 0;
67065 +
67066 + return reqmode;
67067 +}
67068 +
67069 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67070 +{
67071 + __u32 mode;
67072 +
67073 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67074 +
67075 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67076 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67077 + return mode;
67078 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67079 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67080 + return 0;
67081 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67082 + return 0;
67083 +
67084 + return (reqmode);
67085 +}
67086 +
67087 +__u32
67088 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67089 +{
67090 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67091 +}
67092 +
67093 +__u32
67094 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67095 +{
67096 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67097 +}
67098 +
67099 +__u32
67100 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67101 +{
67102 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67103 +}
67104 +
67105 +__u32
67106 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67107 +{
67108 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67109 +}
67110 +
67111 +__u32
67112 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67113 + umode_t *modeptr)
67114 +{
67115 + umode_t mode;
67116 +
67117 + *modeptr &= ~gr_acl_umask();
67118 + mode = *modeptr;
67119 +
67120 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67121 + return 1;
67122 +
67123 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67124 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67125 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67126 + GR_CHMOD_ACL_MSG);
67127 + } else {
67128 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67129 + }
67130 +}
67131 +
67132 +__u32
67133 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67134 +{
67135 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67136 +}
67137 +
67138 +__u32
67139 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67140 +{
67141 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67142 +}
67143 +
67144 +__u32
67145 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67146 +{
67147 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67148 +}
67149 +
67150 +__u32
67151 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67152 +{
67153 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67154 + GR_UNIXCONNECT_ACL_MSG);
67155 +}
67156 +
67157 +/* hardlinks require at minimum create and link permission,
67158 + any additional privilege required is based on the
67159 + privilege of the file being linked to
67160 +*/
67161 +__u32
67162 +gr_acl_handle_link(const struct dentry * new_dentry,
67163 + const struct dentry * parent_dentry,
67164 + const struct vfsmount * parent_mnt,
67165 + const struct dentry * old_dentry,
67166 + const struct vfsmount * old_mnt, const struct filename *to)
67167 +{
67168 + __u32 mode;
67169 + __u32 needmode = GR_CREATE | GR_LINK;
67170 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67171 +
67172 + mode =
67173 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67174 + old_mnt);
67175 +
67176 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67177 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67178 + return mode;
67179 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67180 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67181 + return 0;
67182 + } else if (unlikely((mode & needmode) != needmode))
67183 + return 0;
67184 +
67185 + return 1;
67186 +}
67187 +
67188 +__u32
67189 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67190 + const struct dentry * parent_dentry,
67191 + const struct vfsmount * parent_mnt, const struct filename *from)
67192 +{
67193 + __u32 needmode = GR_WRITE | GR_CREATE;
67194 + __u32 mode;
67195 +
67196 + mode =
67197 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67198 + GR_CREATE | GR_AUDIT_CREATE |
67199 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67200 +
67201 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67202 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67203 + return mode;
67204 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67205 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67206 + return 0;
67207 + } else if (unlikely((mode & needmode) != needmode))
67208 + return 0;
67209 +
67210 + return (GR_WRITE | GR_CREATE);
67211 +}
67212 +
67213 +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)
67214 +{
67215 + __u32 mode;
67216 +
67217 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67218 +
67219 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67220 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67221 + return mode;
67222 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67223 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67224 + return 0;
67225 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67226 + return 0;
67227 +
67228 + return (reqmode);
67229 +}
67230 +
67231 +__u32
67232 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67233 + const struct dentry * parent_dentry,
67234 + const struct vfsmount * parent_mnt,
67235 + const int mode)
67236 +{
67237 + __u32 reqmode = GR_WRITE | GR_CREATE;
67238 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67239 + reqmode |= GR_SETID;
67240 +
67241 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67242 + reqmode, GR_MKNOD_ACL_MSG);
67243 +}
67244 +
67245 +__u32
67246 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67247 + const struct dentry *parent_dentry,
67248 + const struct vfsmount *parent_mnt)
67249 +{
67250 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67251 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67252 +}
67253 +
67254 +#define RENAME_CHECK_SUCCESS(old, new) \
67255 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67256 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67257 +
67258 +int
67259 +gr_acl_handle_rename(struct dentry *new_dentry,
67260 + struct dentry *parent_dentry,
67261 + const struct vfsmount *parent_mnt,
67262 + struct dentry *old_dentry,
67263 + struct inode *old_parent_inode,
67264 + struct vfsmount *old_mnt, const struct filename *newname)
67265 +{
67266 + __u32 comp1, comp2;
67267 + int error = 0;
67268 +
67269 + if (unlikely(!gr_acl_is_enabled()))
67270 + return 0;
67271 +
67272 + if (!new_dentry->d_inode) {
67273 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67274 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67275 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67276 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67277 + GR_DELETE | GR_AUDIT_DELETE |
67278 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67279 + GR_SUPPRESS, old_mnt);
67280 + } else {
67281 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67282 + GR_CREATE | GR_DELETE |
67283 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67284 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67285 + GR_SUPPRESS, parent_mnt);
67286 + comp2 =
67287 + gr_search_file(old_dentry,
67288 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67289 + GR_DELETE | GR_AUDIT_DELETE |
67290 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67291 + }
67292 +
67293 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67294 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67295 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67296 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67297 + && !(comp2 & GR_SUPPRESS)) {
67298 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67299 + error = -EACCES;
67300 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67301 + error = -EACCES;
67302 +
67303 + return error;
67304 +}
67305 +
67306 +void
67307 +gr_acl_handle_exit(void)
67308 +{
67309 + u16 id;
67310 + char *rolename;
67311 +
67312 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67313 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67314 + id = current->acl_role_id;
67315 + rolename = current->role->rolename;
67316 + gr_set_acls(1);
67317 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67318 + }
67319 +
67320 + gr_put_exec_file(current);
67321 + return;
67322 +}
67323 +
67324 +int
67325 +gr_acl_handle_procpidmem(const struct task_struct *task)
67326 +{
67327 + if (unlikely(!gr_acl_is_enabled()))
67328 + return 0;
67329 +
67330 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67331 + return -EACCES;
67332 +
67333 + return 0;
67334 +}
67335 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67336 new file mode 100644
67337 index 0000000..8132048
67338 --- /dev/null
67339 +++ b/grsecurity/gracl_ip.c
67340 @@ -0,0 +1,387 @@
67341 +#include <linux/kernel.h>
67342 +#include <asm/uaccess.h>
67343 +#include <asm/errno.h>
67344 +#include <net/sock.h>
67345 +#include <linux/file.h>
67346 +#include <linux/fs.h>
67347 +#include <linux/net.h>
67348 +#include <linux/in.h>
67349 +#include <linux/skbuff.h>
67350 +#include <linux/ip.h>
67351 +#include <linux/udp.h>
67352 +#include <linux/types.h>
67353 +#include <linux/sched.h>
67354 +#include <linux/netdevice.h>
67355 +#include <linux/inetdevice.h>
67356 +#include <linux/gracl.h>
67357 +#include <linux/grsecurity.h>
67358 +#include <linux/grinternal.h>
67359 +
67360 +#define GR_BIND 0x01
67361 +#define GR_CONNECT 0x02
67362 +#define GR_INVERT 0x04
67363 +#define GR_BINDOVERRIDE 0x08
67364 +#define GR_CONNECTOVERRIDE 0x10
67365 +#define GR_SOCK_FAMILY 0x20
67366 +
67367 +static const char * gr_protocols[IPPROTO_MAX] = {
67368 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67369 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67370 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67371 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67372 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67373 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67374 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67375 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67376 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67377 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67378 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67379 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67380 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67381 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67382 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67383 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67384 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67385 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67386 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67387 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67388 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67389 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67390 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67391 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67392 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67393 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67394 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67395 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67396 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67397 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67398 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67399 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67400 + };
67401 +
67402 +static const char * gr_socktypes[SOCK_MAX] = {
67403 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67404 + "unknown:7", "unknown:8", "unknown:9", "packet"
67405 + };
67406 +
67407 +static const char * gr_sockfamilies[AF_MAX+1] = {
67408 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67409 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67410 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67411 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67412 + };
67413 +
67414 +const char *
67415 +gr_proto_to_name(unsigned char proto)
67416 +{
67417 + return gr_protocols[proto];
67418 +}
67419 +
67420 +const char *
67421 +gr_socktype_to_name(unsigned char type)
67422 +{
67423 + return gr_socktypes[type];
67424 +}
67425 +
67426 +const char *
67427 +gr_sockfamily_to_name(unsigned char family)
67428 +{
67429 + return gr_sockfamilies[family];
67430 +}
67431 +
67432 +int
67433 +gr_search_socket(const int domain, const int type, const int protocol)
67434 +{
67435 + struct acl_subject_label *curr;
67436 + const struct cred *cred = current_cred();
67437 +
67438 + if (unlikely(!gr_acl_is_enabled()))
67439 + goto exit;
67440 +
67441 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67442 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67443 + goto exit; // let the kernel handle it
67444 +
67445 + curr = current->acl;
67446 +
67447 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67448 + /* the family is allowed, if this is PF_INET allow it only if
67449 + the extra sock type/protocol checks pass */
67450 + if (domain == PF_INET)
67451 + goto inet_check;
67452 + goto exit;
67453 + } else {
67454 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67455 + __u32 fakeip = 0;
67456 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67457 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67458 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67459 + gr_to_filename(current->exec_file->f_path.dentry,
67460 + current->exec_file->f_path.mnt) :
67461 + curr->filename, curr->filename,
67462 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67463 + &current->signal->saved_ip);
67464 + goto exit;
67465 + }
67466 + goto exit_fail;
67467 + }
67468 +
67469 +inet_check:
67470 + /* the rest of this checking is for IPv4 only */
67471 + if (!curr->ips)
67472 + goto exit;
67473 +
67474 + if ((curr->ip_type & (1U << type)) &&
67475 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67476 + goto exit;
67477 +
67478 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67479 + /* we don't place acls on raw sockets , and sometimes
67480 + dgram/ip sockets are opened for ioctl and not
67481 + bind/connect, so we'll fake a bind learn log */
67482 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67483 + __u32 fakeip = 0;
67484 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67485 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67486 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67487 + gr_to_filename(current->exec_file->f_path.dentry,
67488 + current->exec_file->f_path.mnt) :
67489 + curr->filename, curr->filename,
67490 + &fakeip, 0, type,
67491 + protocol, GR_CONNECT, &current->signal->saved_ip);
67492 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67493 + __u32 fakeip = 0;
67494 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67495 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67496 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67497 + gr_to_filename(current->exec_file->f_path.dentry,
67498 + current->exec_file->f_path.mnt) :
67499 + curr->filename, curr->filename,
67500 + &fakeip, 0, type,
67501 + protocol, GR_BIND, &current->signal->saved_ip);
67502 + }
67503 + /* we'll log when they use connect or bind */
67504 + goto exit;
67505 + }
67506 +
67507 +exit_fail:
67508 + if (domain == PF_INET)
67509 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67510 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67511 + else
67512 +#ifndef CONFIG_IPV6
67513 + if (domain != PF_INET6)
67514 +#endif
67515 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67516 + gr_socktype_to_name(type), protocol);
67517 +
67518 + return 0;
67519 +exit:
67520 + return 1;
67521 +}
67522 +
67523 +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)
67524 +{
67525 + if ((ip->mode & mode) &&
67526 + (ip_port >= ip->low) &&
67527 + (ip_port <= ip->high) &&
67528 + ((ntohl(ip_addr) & our_netmask) ==
67529 + (ntohl(our_addr) & our_netmask))
67530 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67531 + && (ip->type & (1U << type))) {
67532 + if (ip->mode & GR_INVERT)
67533 + return 2; // specifically denied
67534 + else
67535 + return 1; // allowed
67536 + }
67537 +
67538 + return 0; // not specifically allowed, may continue parsing
67539 +}
67540 +
67541 +static int
67542 +gr_search_connectbind(const int full_mode, struct sock *sk,
67543 + struct sockaddr_in *addr, const int type)
67544 +{
67545 + char iface[IFNAMSIZ] = {0};
67546 + struct acl_subject_label *curr;
67547 + struct acl_ip_label *ip;
67548 + struct inet_sock *isk;
67549 + struct net_device *dev;
67550 + struct in_device *idev;
67551 + unsigned long i;
67552 + int ret;
67553 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67554 + __u32 ip_addr = 0;
67555 + __u32 our_addr;
67556 + __u32 our_netmask;
67557 + char *p;
67558 + __u16 ip_port = 0;
67559 + const struct cred *cred = current_cred();
67560 +
67561 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67562 + return 0;
67563 +
67564 + curr = current->acl;
67565 + isk = inet_sk(sk);
67566 +
67567 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67568 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67569 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67570 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67571 + struct sockaddr_in saddr;
67572 + int err;
67573 +
67574 + saddr.sin_family = AF_INET;
67575 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67576 + saddr.sin_port = isk->inet_sport;
67577 +
67578 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67579 + if (err)
67580 + return err;
67581 +
67582 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67583 + if (err)
67584 + return err;
67585 + }
67586 +
67587 + if (!curr->ips)
67588 + return 0;
67589 +
67590 + ip_addr = addr->sin_addr.s_addr;
67591 + ip_port = ntohs(addr->sin_port);
67592 +
67593 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67594 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67595 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67596 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67597 + gr_to_filename(current->exec_file->f_path.dentry,
67598 + current->exec_file->f_path.mnt) :
67599 + curr->filename, curr->filename,
67600 + &ip_addr, ip_port, type,
67601 + sk->sk_protocol, mode, &current->signal->saved_ip);
67602 + return 0;
67603 + }
67604 +
67605 + for (i = 0; i < curr->ip_num; i++) {
67606 + ip = *(curr->ips + i);
67607 + if (ip->iface != NULL) {
67608 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67609 + p = strchr(iface, ':');
67610 + if (p != NULL)
67611 + *p = '\0';
67612 + dev = dev_get_by_name(sock_net(sk), iface);
67613 + if (dev == NULL)
67614 + continue;
67615 + idev = in_dev_get(dev);
67616 + if (idev == NULL) {
67617 + dev_put(dev);
67618 + continue;
67619 + }
67620 + rcu_read_lock();
67621 + for_ifa(idev) {
67622 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67623 + our_addr = ifa->ifa_address;
67624 + our_netmask = 0xffffffff;
67625 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67626 + if (ret == 1) {
67627 + rcu_read_unlock();
67628 + in_dev_put(idev);
67629 + dev_put(dev);
67630 + return 0;
67631 + } else if (ret == 2) {
67632 + rcu_read_unlock();
67633 + in_dev_put(idev);
67634 + dev_put(dev);
67635 + goto denied;
67636 + }
67637 + }
67638 + } endfor_ifa(idev);
67639 + rcu_read_unlock();
67640 + in_dev_put(idev);
67641 + dev_put(dev);
67642 + } else {
67643 + our_addr = ip->addr;
67644 + our_netmask = ip->netmask;
67645 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67646 + if (ret == 1)
67647 + return 0;
67648 + else if (ret == 2)
67649 + goto denied;
67650 + }
67651 + }
67652 +
67653 +denied:
67654 + if (mode == GR_BIND)
67655 + 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));
67656 + else if (mode == GR_CONNECT)
67657 + 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));
67658 +
67659 + return -EACCES;
67660 +}
67661 +
67662 +int
67663 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67664 +{
67665 + /* always allow disconnection of dgram sockets with connect */
67666 + if (addr->sin_family == AF_UNSPEC)
67667 + return 0;
67668 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67669 +}
67670 +
67671 +int
67672 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67673 +{
67674 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67675 +}
67676 +
67677 +int gr_search_listen(struct socket *sock)
67678 +{
67679 + struct sock *sk = sock->sk;
67680 + struct sockaddr_in addr;
67681 +
67682 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67683 + addr.sin_port = inet_sk(sk)->inet_sport;
67684 +
67685 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67686 +}
67687 +
67688 +int gr_search_accept(struct socket *sock)
67689 +{
67690 + struct sock *sk = sock->sk;
67691 + struct sockaddr_in addr;
67692 +
67693 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67694 + addr.sin_port = inet_sk(sk)->inet_sport;
67695 +
67696 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67697 +}
67698 +
67699 +int
67700 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67701 +{
67702 + if (addr)
67703 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67704 + else {
67705 + struct sockaddr_in sin;
67706 + const struct inet_sock *inet = inet_sk(sk);
67707 +
67708 + sin.sin_addr.s_addr = inet->inet_daddr;
67709 + sin.sin_port = inet->inet_dport;
67710 +
67711 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67712 + }
67713 +}
67714 +
67715 +int
67716 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67717 +{
67718 + struct sockaddr_in sin;
67719 +
67720 + if (unlikely(skb->len < sizeof (struct udphdr)))
67721 + return 0; // skip this packet
67722 +
67723 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67724 + sin.sin_port = udp_hdr(skb)->source;
67725 +
67726 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67727 +}
67728 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67729 new file mode 100644
67730 index 0000000..25f54ef
67731 --- /dev/null
67732 +++ b/grsecurity/gracl_learn.c
67733 @@ -0,0 +1,207 @@
67734 +#include <linux/kernel.h>
67735 +#include <linux/mm.h>
67736 +#include <linux/sched.h>
67737 +#include <linux/poll.h>
67738 +#include <linux/string.h>
67739 +#include <linux/file.h>
67740 +#include <linux/types.h>
67741 +#include <linux/vmalloc.h>
67742 +#include <linux/grinternal.h>
67743 +
67744 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67745 + size_t count, loff_t *ppos);
67746 +extern int gr_acl_is_enabled(void);
67747 +
67748 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67749 +static int gr_learn_attached;
67750 +
67751 +/* use a 512k buffer */
67752 +#define LEARN_BUFFER_SIZE (512 * 1024)
67753 +
67754 +static DEFINE_SPINLOCK(gr_learn_lock);
67755 +static DEFINE_MUTEX(gr_learn_user_mutex);
67756 +
67757 +/* we need to maintain two buffers, so that the kernel context of grlearn
67758 + uses a semaphore around the userspace copying, and the other kernel contexts
67759 + use a spinlock when copying into the buffer, since they cannot sleep
67760 +*/
67761 +static char *learn_buffer;
67762 +static char *learn_buffer_user;
67763 +static int learn_buffer_len;
67764 +static int learn_buffer_user_len;
67765 +
67766 +static ssize_t
67767 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67768 +{
67769 + DECLARE_WAITQUEUE(wait, current);
67770 + ssize_t retval = 0;
67771 +
67772 + add_wait_queue(&learn_wait, &wait);
67773 + set_current_state(TASK_INTERRUPTIBLE);
67774 + do {
67775 + mutex_lock(&gr_learn_user_mutex);
67776 + spin_lock(&gr_learn_lock);
67777 + if (learn_buffer_len)
67778 + break;
67779 + spin_unlock(&gr_learn_lock);
67780 + mutex_unlock(&gr_learn_user_mutex);
67781 + if (file->f_flags & O_NONBLOCK) {
67782 + retval = -EAGAIN;
67783 + goto out;
67784 + }
67785 + if (signal_pending(current)) {
67786 + retval = -ERESTARTSYS;
67787 + goto out;
67788 + }
67789 +
67790 + schedule();
67791 + } while (1);
67792 +
67793 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67794 + learn_buffer_user_len = learn_buffer_len;
67795 + retval = learn_buffer_len;
67796 + learn_buffer_len = 0;
67797 +
67798 + spin_unlock(&gr_learn_lock);
67799 +
67800 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67801 + retval = -EFAULT;
67802 +
67803 + mutex_unlock(&gr_learn_user_mutex);
67804 +out:
67805 + set_current_state(TASK_RUNNING);
67806 + remove_wait_queue(&learn_wait, &wait);
67807 + return retval;
67808 +}
67809 +
67810 +static unsigned int
67811 +poll_learn(struct file * file, poll_table * wait)
67812 +{
67813 + poll_wait(file, &learn_wait, wait);
67814 +
67815 + if (learn_buffer_len)
67816 + return (POLLIN | POLLRDNORM);
67817 +
67818 + return 0;
67819 +}
67820 +
67821 +void
67822 +gr_clear_learn_entries(void)
67823 +{
67824 + char *tmp;
67825 +
67826 + mutex_lock(&gr_learn_user_mutex);
67827 + spin_lock(&gr_learn_lock);
67828 + tmp = learn_buffer;
67829 + learn_buffer = NULL;
67830 + spin_unlock(&gr_learn_lock);
67831 + if (tmp)
67832 + vfree(tmp);
67833 + if (learn_buffer_user != NULL) {
67834 + vfree(learn_buffer_user);
67835 + learn_buffer_user = NULL;
67836 + }
67837 + learn_buffer_len = 0;
67838 + mutex_unlock(&gr_learn_user_mutex);
67839 +
67840 + return;
67841 +}
67842 +
67843 +void
67844 +gr_add_learn_entry(const char *fmt, ...)
67845 +{
67846 + va_list args;
67847 + unsigned int len;
67848 +
67849 + if (!gr_learn_attached)
67850 + return;
67851 +
67852 + spin_lock(&gr_learn_lock);
67853 +
67854 + /* leave a gap at the end so we know when it's "full" but don't have to
67855 + compute the exact length of the string we're trying to append
67856 + */
67857 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67858 + spin_unlock(&gr_learn_lock);
67859 + wake_up_interruptible(&learn_wait);
67860 + return;
67861 + }
67862 + if (learn_buffer == NULL) {
67863 + spin_unlock(&gr_learn_lock);
67864 + return;
67865 + }
67866 +
67867 + va_start(args, fmt);
67868 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67869 + va_end(args);
67870 +
67871 + learn_buffer_len += len + 1;
67872 +
67873 + spin_unlock(&gr_learn_lock);
67874 + wake_up_interruptible(&learn_wait);
67875 +
67876 + return;
67877 +}
67878 +
67879 +static int
67880 +open_learn(struct inode *inode, struct file *file)
67881 +{
67882 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67883 + return -EBUSY;
67884 + if (file->f_mode & FMODE_READ) {
67885 + int retval = 0;
67886 + mutex_lock(&gr_learn_user_mutex);
67887 + if (learn_buffer == NULL)
67888 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67889 + if (learn_buffer_user == NULL)
67890 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67891 + if (learn_buffer == NULL) {
67892 + retval = -ENOMEM;
67893 + goto out_error;
67894 + }
67895 + if (learn_buffer_user == NULL) {
67896 + retval = -ENOMEM;
67897 + goto out_error;
67898 + }
67899 + learn_buffer_len = 0;
67900 + learn_buffer_user_len = 0;
67901 + gr_learn_attached = 1;
67902 +out_error:
67903 + mutex_unlock(&gr_learn_user_mutex);
67904 + return retval;
67905 + }
67906 + return 0;
67907 +}
67908 +
67909 +static int
67910 +close_learn(struct inode *inode, struct file *file)
67911 +{
67912 + if (file->f_mode & FMODE_READ) {
67913 + char *tmp = NULL;
67914 + mutex_lock(&gr_learn_user_mutex);
67915 + spin_lock(&gr_learn_lock);
67916 + tmp = learn_buffer;
67917 + learn_buffer = NULL;
67918 + spin_unlock(&gr_learn_lock);
67919 + if (tmp)
67920 + vfree(tmp);
67921 + if (learn_buffer_user != NULL) {
67922 + vfree(learn_buffer_user);
67923 + learn_buffer_user = NULL;
67924 + }
67925 + learn_buffer_len = 0;
67926 + learn_buffer_user_len = 0;
67927 + gr_learn_attached = 0;
67928 + mutex_unlock(&gr_learn_user_mutex);
67929 + }
67930 +
67931 + return 0;
67932 +}
67933 +
67934 +const struct file_operations grsec_fops = {
67935 + .read = read_learn,
67936 + .write = write_grsec_handler,
67937 + .open = open_learn,
67938 + .release = close_learn,
67939 + .poll = poll_learn,
67940 +};
67941 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
67942 new file mode 100644
67943 index 0000000..39645c9
67944 --- /dev/null
67945 +++ b/grsecurity/gracl_res.c
67946 @@ -0,0 +1,68 @@
67947 +#include <linux/kernel.h>
67948 +#include <linux/sched.h>
67949 +#include <linux/gracl.h>
67950 +#include <linux/grinternal.h>
67951 +
67952 +static const char *restab_log[] = {
67953 + [RLIMIT_CPU] = "RLIMIT_CPU",
67954 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
67955 + [RLIMIT_DATA] = "RLIMIT_DATA",
67956 + [RLIMIT_STACK] = "RLIMIT_STACK",
67957 + [RLIMIT_CORE] = "RLIMIT_CORE",
67958 + [RLIMIT_RSS] = "RLIMIT_RSS",
67959 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
67960 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
67961 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
67962 + [RLIMIT_AS] = "RLIMIT_AS",
67963 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
67964 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
67965 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
67966 + [RLIMIT_NICE] = "RLIMIT_NICE",
67967 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
67968 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
67969 + [GR_CRASH_RES] = "RLIMIT_CRASH"
67970 +};
67971 +
67972 +void
67973 +gr_log_resource(const struct task_struct *task,
67974 + const int res, const unsigned long wanted, const int gt)
67975 +{
67976 + const struct cred *cred;
67977 + unsigned long rlim;
67978 +
67979 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
67980 + return;
67981 +
67982 + // not yet supported resource
67983 + if (unlikely(!restab_log[res]))
67984 + return;
67985 +
67986 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
67987 + rlim = task_rlimit_max(task, res);
67988 + else
67989 + rlim = task_rlimit(task, res);
67990 +
67991 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
67992 + return;
67993 +
67994 + rcu_read_lock();
67995 + cred = __task_cred(task);
67996 +
67997 + if (res == RLIMIT_NPROC &&
67998 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
67999 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68000 + goto out_rcu_unlock;
68001 + else if (res == RLIMIT_MEMLOCK &&
68002 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68003 + goto out_rcu_unlock;
68004 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68005 + goto out_rcu_unlock;
68006 + rcu_read_unlock();
68007 +
68008 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68009 +
68010 + return;
68011 +out_rcu_unlock:
68012 + rcu_read_unlock();
68013 + return;
68014 +}
68015 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68016 new file mode 100644
68017 index 0000000..3c38bfe
68018 --- /dev/null
68019 +++ b/grsecurity/gracl_segv.c
68020 @@ -0,0 +1,305 @@
68021 +#include <linux/kernel.h>
68022 +#include <linux/mm.h>
68023 +#include <asm/uaccess.h>
68024 +#include <asm/errno.h>
68025 +#include <asm/mman.h>
68026 +#include <net/sock.h>
68027 +#include <linux/file.h>
68028 +#include <linux/fs.h>
68029 +#include <linux/net.h>
68030 +#include <linux/in.h>
68031 +#include <linux/slab.h>
68032 +#include <linux/types.h>
68033 +#include <linux/sched.h>
68034 +#include <linux/timer.h>
68035 +#include <linux/gracl.h>
68036 +#include <linux/grsecurity.h>
68037 +#include <linux/grinternal.h>
68038 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68039 +#include <linux/magic.h>
68040 +#include <linux/pagemap.h>
68041 +#include "../fs/btrfs/async-thread.h"
68042 +#include "../fs/btrfs/ctree.h"
68043 +#include "../fs/btrfs/btrfs_inode.h"
68044 +#endif
68045 +
68046 +static struct crash_uid *uid_set;
68047 +static unsigned short uid_used;
68048 +static DEFINE_SPINLOCK(gr_uid_lock);
68049 +extern rwlock_t gr_inode_lock;
68050 +extern struct acl_subject_label *
68051 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68052 + struct acl_role_label *role);
68053 +
68054 +static inline dev_t __get_dev(const struct dentry *dentry)
68055 +{
68056 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68057 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68058 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68059 + else
68060 +#endif
68061 + return dentry->d_sb->s_dev;
68062 +}
68063 +
68064 +int
68065 +gr_init_uidset(void)
68066 +{
68067 + uid_set =
68068 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68069 + uid_used = 0;
68070 +
68071 + return uid_set ? 1 : 0;
68072 +}
68073 +
68074 +void
68075 +gr_free_uidset(void)
68076 +{
68077 + if (uid_set)
68078 + kfree(uid_set);
68079 +
68080 + return;
68081 +}
68082 +
68083 +int
68084 +gr_find_uid(const uid_t uid)
68085 +{
68086 + struct crash_uid *tmp = uid_set;
68087 + uid_t buid;
68088 + int low = 0, high = uid_used - 1, mid;
68089 +
68090 + while (high >= low) {
68091 + mid = (low + high) >> 1;
68092 + buid = tmp[mid].uid;
68093 + if (buid == uid)
68094 + return mid;
68095 + if (buid > uid)
68096 + high = mid - 1;
68097 + if (buid < uid)
68098 + low = mid + 1;
68099 + }
68100 +
68101 + return -1;
68102 +}
68103 +
68104 +static __inline__ void
68105 +gr_insertsort(void)
68106 +{
68107 + unsigned short i, j;
68108 + struct crash_uid index;
68109 +
68110 + for (i = 1; i < uid_used; i++) {
68111 + index = uid_set[i];
68112 + j = i;
68113 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68114 + uid_set[j] = uid_set[j - 1];
68115 + j--;
68116 + }
68117 + uid_set[j] = index;
68118 + }
68119 +
68120 + return;
68121 +}
68122 +
68123 +static __inline__ void
68124 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68125 +{
68126 + int loc;
68127 + uid_t uid = GR_GLOBAL_UID(kuid);
68128 +
68129 + if (uid_used == GR_UIDTABLE_MAX)
68130 + return;
68131 +
68132 + loc = gr_find_uid(uid);
68133 +
68134 + if (loc >= 0) {
68135 + uid_set[loc].expires = expires;
68136 + return;
68137 + }
68138 +
68139 + uid_set[uid_used].uid = uid;
68140 + uid_set[uid_used].expires = expires;
68141 + uid_used++;
68142 +
68143 + gr_insertsort();
68144 +
68145 + return;
68146 +}
68147 +
68148 +void
68149 +gr_remove_uid(const unsigned short loc)
68150 +{
68151 + unsigned short i;
68152 +
68153 + for (i = loc + 1; i < uid_used; i++)
68154 + uid_set[i - 1] = uid_set[i];
68155 +
68156 + uid_used--;
68157 +
68158 + return;
68159 +}
68160 +
68161 +int
68162 +gr_check_crash_uid(const kuid_t kuid)
68163 +{
68164 + int loc;
68165 + int ret = 0;
68166 + uid_t uid;
68167 +
68168 + if (unlikely(!gr_acl_is_enabled()))
68169 + return 0;
68170 +
68171 + uid = GR_GLOBAL_UID(kuid);
68172 +
68173 + spin_lock(&gr_uid_lock);
68174 + loc = gr_find_uid(uid);
68175 +
68176 + if (loc < 0)
68177 + goto out_unlock;
68178 +
68179 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68180 + gr_remove_uid(loc);
68181 + else
68182 + ret = 1;
68183 +
68184 +out_unlock:
68185 + spin_unlock(&gr_uid_lock);
68186 + return ret;
68187 +}
68188 +
68189 +static __inline__ int
68190 +proc_is_setxid(const struct cred *cred)
68191 +{
68192 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68193 + !uid_eq(cred->uid, cred->fsuid))
68194 + return 1;
68195 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68196 + !gid_eq(cred->gid, cred->fsgid))
68197 + return 1;
68198 +
68199 + return 0;
68200 +}
68201 +
68202 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68203 +
68204 +void
68205 +gr_handle_crash(struct task_struct *task, const int sig)
68206 +{
68207 + struct acl_subject_label *curr;
68208 + struct task_struct *tsk, *tsk2;
68209 + const struct cred *cred;
68210 + const struct cred *cred2;
68211 +
68212 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68213 + return;
68214 +
68215 + if (unlikely(!gr_acl_is_enabled()))
68216 + return;
68217 +
68218 + curr = task->acl;
68219 +
68220 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68221 + return;
68222 +
68223 + if (time_before_eq(curr->expires, get_seconds())) {
68224 + curr->expires = 0;
68225 + curr->crashes = 0;
68226 + }
68227 +
68228 + curr->crashes++;
68229 +
68230 + if (!curr->expires)
68231 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68232 +
68233 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68234 + time_after(curr->expires, get_seconds())) {
68235 + rcu_read_lock();
68236 + cred = __task_cred(task);
68237 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68238 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68239 + spin_lock(&gr_uid_lock);
68240 + gr_insert_uid(cred->uid, curr->expires);
68241 + spin_unlock(&gr_uid_lock);
68242 + curr->expires = 0;
68243 + curr->crashes = 0;
68244 + read_lock(&tasklist_lock);
68245 + do_each_thread(tsk2, tsk) {
68246 + cred2 = __task_cred(tsk);
68247 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68248 + gr_fake_force_sig(SIGKILL, tsk);
68249 + } while_each_thread(tsk2, tsk);
68250 + read_unlock(&tasklist_lock);
68251 + } else {
68252 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68253 + read_lock(&tasklist_lock);
68254 + read_lock(&grsec_exec_file_lock);
68255 + do_each_thread(tsk2, tsk) {
68256 + if (likely(tsk != task)) {
68257 + // if this thread has the same subject as the one that triggered
68258 + // RES_CRASH and it's the same binary, kill it
68259 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68260 + gr_fake_force_sig(SIGKILL, tsk);
68261 + }
68262 + } while_each_thread(tsk2, tsk);
68263 + read_unlock(&grsec_exec_file_lock);
68264 + read_unlock(&tasklist_lock);
68265 + }
68266 + rcu_read_unlock();
68267 + }
68268 +
68269 + return;
68270 +}
68271 +
68272 +int
68273 +gr_check_crash_exec(const struct file *filp)
68274 +{
68275 + struct acl_subject_label *curr;
68276 +
68277 + if (unlikely(!gr_acl_is_enabled()))
68278 + return 0;
68279 +
68280 + read_lock(&gr_inode_lock);
68281 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68282 + __get_dev(filp->f_path.dentry),
68283 + current->role);
68284 + read_unlock(&gr_inode_lock);
68285 +
68286 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68287 + (!curr->crashes && !curr->expires))
68288 + return 0;
68289 +
68290 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68291 + time_after(curr->expires, get_seconds()))
68292 + return 1;
68293 + else if (time_before_eq(curr->expires, get_seconds())) {
68294 + curr->crashes = 0;
68295 + curr->expires = 0;
68296 + }
68297 +
68298 + return 0;
68299 +}
68300 +
68301 +void
68302 +gr_handle_alertkill(struct task_struct *task)
68303 +{
68304 + struct acl_subject_label *curracl;
68305 + __u32 curr_ip;
68306 + struct task_struct *p, *p2;
68307 +
68308 + if (unlikely(!gr_acl_is_enabled()))
68309 + return;
68310 +
68311 + curracl = task->acl;
68312 + curr_ip = task->signal->curr_ip;
68313 +
68314 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68315 + read_lock(&tasklist_lock);
68316 + do_each_thread(p2, p) {
68317 + if (p->signal->curr_ip == curr_ip)
68318 + gr_fake_force_sig(SIGKILL, p);
68319 + } while_each_thread(p2, p);
68320 + read_unlock(&tasklist_lock);
68321 + } else if (curracl->mode & GR_KILLPROC)
68322 + gr_fake_force_sig(SIGKILL, task);
68323 +
68324 + return;
68325 +}
68326 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68327 new file mode 100644
68328 index 0000000..98011b0
68329 --- /dev/null
68330 +++ b/grsecurity/gracl_shm.c
68331 @@ -0,0 +1,40 @@
68332 +#include <linux/kernel.h>
68333 +#include <linux/mm.h>
68334 +#include <linux/sched.h>
68335 +#include <linux/file.h>
68336 +#include <linux/ipc.h>
68337 +#include <linux/gracl.h>
68338 +#include <linux/grsecurity.h>
68339 +#include <linux/grinternal.h>
68340 +
68341 +int
68342 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68343 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68344 +{
68345 + struct task_struct *task;
68346 +
68347 + if (!gr_acl_is_enabled())
68348 + return 1;
68349 +
68350 + rcu_read_lock();
68351 + read_lock(&tasklist_lock);
68352 +
68353 + task = find_task_by_vpid(shm_cprid);
68354 +
68355 + if (unlikely(!task))
68356 + task = find_task_by_vpid(shm_lapid);
68357 +
68358 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68359 + (task_pid_nr(task) == shm_lapid)) &&
68360 + (task->acl->mode & GR_PROTSHM) &&
68361 + (task->acl != current->acl))) {
68362 + read_unlock(&tasklist_lock);
68363 + rcu_read_unlock();
68364 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68365 + return 0;
68366 + }
68367 + read_unlock(&tasklist_lock);
68368 + rcu_read_unlock();
68369 +
68370 + return 1;
68371 +}
68372 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68373 new file mode 100644
68374 index 0000000..bc0be01
68375 --- /dev/null
68376 +++ b/grsecurity/grsec_chdir.c
68377 @@ -0,0 +1,19 @@
68378 +#include <linux/kernel.h>
68379 +#include <linux/sched.h>
68380 +#include <linux/fs.h>
68381 +#include <linux/file.h>
68382 +#include <linux/grsecurity.h>
68383 +#include <linux/grinternal.h>
68384 +
68385 +void
68386 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68387 +{
68388 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68389 + if ((grsec_enable_chdir && grsec_enable_group &&
68390 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68391 + !grsec_enable_group)) {
68392 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68393 + }
68394 +#endif
68395 + return;
68396 +}
68397 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68398 new file mode 100644
68399 index 0000000..bd6e105
68400 --- /dev/null
68401 +++ b/grsecurity/grsec_chroot.c
68402 @@ -0,0 +1,370 @@
68403 +#include <linux/kernel.h>
68404 +#include <linux/module.h>
68405 +#include <linux/sched.h>
68406 +#include <linux/file.h>
68407 +#include <linux/fs.h>
68408 +#include <linux/mount.h>
68409 +#include <linux/types.h>
68410 +#include "../fs/mount.h"
68411 +#include <linux/grsecurity.h>
68412 +#include <linux/grinternal.h>
68413 +
68414 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68415 +static int gr_init_ran;
68416 +#endif
68417 +
68418 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68419 +{
68420 +#ifdef CONFIG_GRKERNSEC
68421 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68422 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68423 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68424 + && gr_init_ran
68425 +#endif
68426 + )
68427 + task->gr_is_chrooted = 1;
68428 + else {
68429 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68430 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68431 + gr_init_ran = 1;
68432 +#endif
68433 + task->gr_is_chrooted = 0;
68434 + }
68435 +
68436 + task->gr_chroot_dentry = path->dentry;
68437 +#endif
68438 + return;
68439 +}
68440 +
68441 +void gr_clear_chroot_entries(struct task_struct *task)
68442 +{
68443 +#ifdef CONFIG_GRKERNSEC
68444 + task->gr_is_chrooted = 0;
68445 + task->gr_chroot_dentry = NULL;
68446 +#endif
68447 + return;
68448 +}
68449 +
68450 +int
68451 +gr_handle_chroot_unix(const pid_t pid)
68452 +{
68453 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68454 + struct task_struct *p;
68455 +
68456 + if (unlikely(!grsec_enable_chroot_unix))
68457 + return 1;
68458 +
68459 + if (likely(!proc_is_chrooted(current)))
68460 + return 1;
68461 +
68462 + rcu_read_lock();
68463 + read_lock(&tasklist_lock);
68464 + p = find_task_by_vpid_unrestricted(pid);
68465 + if (unlikely(p && !have_same_root(current, p))) {
68466 + read_unlock(&tasklist_lock);
68467 + rcu_read_unlock();
68468 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68469 + return 0;
68470 + }
68471 + read_unlock(&tasklist_lock);
68472 + rcu_read_unlock();
68473 +#endif
68474 + return 1;
68475 +}
68476 +
68477 +int
68478 +gr_handle_chroot_nice(void)
68479 +{
68480 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68481 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68482 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68483 + return -EPERM;
68484 + }
68485 +#endif
68486 + return 0;
68487 +}
68488 +
68489 +int
68490 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68491 +{
68492 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68493 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68494 + && proc_is_chrooted(current)) {
68495 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68496 + return -EACCES;
68497 + }
68498 +#endif
68499 + return 0;
68500 +}
68501 +
68502 +int
68503 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68504 +{
68505 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68506 + struct task_struct *p;
68507 + int ret = 0;
68508 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68509 + return ret;
68510 +
68511 + read_lock(&tasklist_lock);
68512 + do_each_pid_task(pid, type, p) {
68513 + if (!have_same_root(current, p)) {
68514 + ret = 1;
68515 + goto out;
68516 + }
68517 + } while_each_pid_task(pid, type, p);
68518 +out:
68519 + read_unlock(&tasklist_lock);
68520 + return ret;
68521 +#endif
68522 + return 0;
68523 +}
68524 +
68525 +int
68526 +gr_pid_is_chrooted(struct task_struct *p)
68527 +{
68528 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68529 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68530 + return 0;
68531 +
68532 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68533 + !have_same_root(current, p)) {
68534 + return 1;
68535 + }
68536 +#endif
68537 + return 0;
68538 +}
68539 +
68540 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68541 +
68542 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68543 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68544 +{
68545 + struct path path, currentroot;
68546 + int ret = 0;
68547 +
68548 + path.dentry = (struct dentry *)u_dentry;
68549 + path.mnt = (struct vfsmount *)u_mnt;
68550 + get_fs_root(current->fs, &currentroot);
68551 + if (path_is_under(&path, &currentroot))
68552 + ret = 1;
68553 + path_put(&currentroot);
68554 +
68555 + return ret;
68556 +}
68557 +#endif
68558 +
68559 +int
68560 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68561 +{
68562 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68563 + if (!grsec_enable_chroot_fchdir)
68564 + return 1;
68565 +
68566 + if (!proc_is_chrooted(current))
68567 + return 1;
68568 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68569 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68570 + return 0;
68571 + }
68572 +#endif
68573 + return 1;
68574 +}
68575 +
68576 +int
68577 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68578 + const time_t shm_createtime)
68579 +{
68580 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68581 + struct task_struct *p;
68582 + time_t starttime;
68583 +
68584 + if (unlikely(!grsec_enable_chroot_shmat))
68585 + return 1;
68586 +
68587 + if (likely(!proc_is_chrooted(current)))
68588 + return 1;
68589 +
68590 + rcu_read_lock();
68591 + read_lock(&tasklist_lock);
68592 +
68593 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68594 + starttime = p->start_time.tv_sec;
68595 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68596 + if (have_same_root(current, p)) {
68597 + goto allow;
68598 + } else {
68599 + read_unlock(&tasklist_lock);
68600 + rcu_read_unlock();
68601 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68602 + return 0;
68603 + }
68604 + }
68605 + /* creator exited, pid reuse, fall through to next check */
68606 + }
68607 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68608 + if (unlikely(!have_same_root(current, p))) {
68609 + read_unlock(&tasklist_lock);
68610 + rcu_read_unlock();
68611 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68612 + return 0;
68613 + }
68614 + }
68615 +
68616 +allow:
68617 + read_unlock(&tasklist_lock);
68618 + rcu_read_unlock();
68619 +#endif
68620 + return 1;
68621 +}
68622 +
68623 +void
68624 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68625 +{
68626 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68627 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68628 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68629 +#endif
68630 + return;
68631 +}
68632 +
68633 +int
68634 +gr_handle_chroot_mknod(const struct dentry *dentry,
68635 + const struct vfsmount *mnt, const int mode)
68636 +{
68637 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68638 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68639 + proc_is_chrooted(current)) {
68640 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68641 + return -EPERM;
68642 + }
68643 +#endif
68644 + return 0;
68645 +}
68646 +
68647 +int
68648 +gr_handle_chroot_mount(const struct dentry *dentry,
68649 + const struct vfsmount *mnt, const char *dev_name)
68650 +{
68651 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68652 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68653 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68654 + return -EPERM;
68655 + }
68656 +#endif
68657 + return 0;
68658 +}
68659 +
68660 +int
68661 +gr_handle_chroot_pivot(void)
68662 +{
68663 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68664 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68665 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68666 + return -EPERM;
68667 + }
68668 +#endif
68669 + return 0;
68670 +}
68671 +
68672 +int
68673 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68674 +{
68675 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68676 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68677 + !gr_is_outside_chroot(dentry, mnt)) {
68678 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68679 + return -EPERM;
68680 + }
68681 +#endif
68682 + return 0;
68683 +}
68684 +
68685 +extern const char *captab_log[];
68686 +extern int captab_log_entries;
68687 +
68688 +int
68689 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68690 +{
68691 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68692 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68693 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68694 + if (cap_raised(chroot_caps, cap)) {
68695 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68696 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68697 + }
68698 + return 0;
68699 + }
68700 + }
68701 +#endif
68702 + return 1;
68703 +}
68704 +
68705 +int
68706 +gr_chroot_is_capable(const int cap)
68707 +{
68708 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68709 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68710 +#endif
68711 + return 1;
68712 +}
68713 +
68714 +int
68715 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68716 +{
68717 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68718 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68719 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68720 + if (cap_raised(chroot_caps, cap)) {
68721 + return 0;
68722 + }
68723 + }
68724 +#endif
68725 + return 1;
68726 +}
68727 +
68728 +int
68729 +gr_chroot_is_capable_nolog(const int cap)
68730 +{
68731 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68732 + return gr_task_chroot_is_capable_nolog(current, cap);
68733 +#endif
68734 + return 1;
68735 +}
68736 +
68737 +int
68738 +gr_handle_chroot_sysctl(const int op)
68739 +{
68740 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68741 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68742 + proc_is_chrooted(current))
68743 + return -EACCES;
68744 +#endif
68745 + return 0;
68746 +}
68747 +
68748 +void
68749 +gr_handle_chroot_chdir(const struct path *path)
68750 +{
68751 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68752 + if (grsec_enable_chroot_chdir)
68753 + set_fs_pwd(current->fs, path);
68754 +#endif
68755 + return;
68756 +}
68757 +
68758 +int
68759 +gr_handle_chroot_chmod(const struct dentry *dentry,
68760 + const struct vfsmount *mnt, const int mode)
68761 +{
68762 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68763 + /* allow chmod +s on directories, but not files */
68764 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68765 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68766 + proc_is_chrooted(current)) {
68767 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68768 + return -EPERM;
68769 + }
68770 +#endif
68771 + return 0;
68772 +}
68773 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68774 new file mode 100644
68775 index 0000000..ce65ceb
68776 --- /dev/null
68777 +++ b/grsecurity/grsec_disabled.c
68778 @@ -0,0 +1,434 @@
68779 +#include <linux/kernel.h>
68780 +#include <linux/module.h>
68781 +#include <linux/sched.h>
68782 +#include <linux/file.h>
68783 +#include <linux/fs.h>
68784 +#include <linux/kdev_t.h>
68785 +#include <linux/net.h>
68786 +#include <linux/in.h>
68787 +#include <linux/ip.h>
68788 +#include <linux/skbuff.h>
68789 +#include <linux/sysctl.h>
68790 +
68791 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68792 +void
68793 +pax_set_initial_flags(struct linux_binprm *bprm)
68794 +{
68795 + return;
68796 +}
68797 +#endif
68798 +
68799 +#ifdef CONFIG_SYSCTL
68800 +__u32
68801 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68802 +{
68803 + return 0;
68804 +}
68805 +#endif
68806 +
68807 +#ifdef CONFIG_TASKSTATS
68808 +int gr_is_taskstats_denied(int pid)
68809 +{
68810 + return 0;
68811 +}
68812 +#endif
68813 +
68814 +int
68815 +gr_acl_is_enabled(void)
68816 +{
68817 + return 0;
68818 +}
68819 +
68820 +void
68821 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68822 +{
68823 + return;
68824 +}
68825 +
68826 +int
68827 +gr_handle_rawio(const struct inode *inode)
68828 +{
68829 + return 0;
68830 +}
68831 +
68832 +void
68833 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68834 +{
68835 + return;
68836 +}
68837 +
68838 +int
68839 +gr_handle_ptrace(struct task_struct *task, const long request)
68840 +{
68841 + return 0;
68842 +}
68843 +
68844 +int
68845 +gr_handle_proc_ptrace(struct task_struct *task)
68846 +{
68847 + return 0;
68848 +}
68849 +
68850 +int
68851 +gr_set_acls(const int type)
68852 +{
68853 + return 0;
68854 +}
68855 +
68856 +int
68857 +gr_check_hidden_task(const struct task_struct *tsk)
68858 +{
68859 + return 0;
68860 +}
68861 +
68862 +int
68863 +gr_check_protected_task(const struct task_struct *task)
68864 +{
68865 + return 0;
68866 +}
68867 +
68868 +int
68869 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68870 +{
68871 + return 0;
68872 +}
68873 +
68874 +void
68875 +gr_copy_label(struct task_struct *tsk)
68876 +{
68877 + return;
68878 +}
68879 +
68880 +void
68881 +gr_set_pax_flags(struct task_struct *task)
68882 +{
68883 + return;
68884 +}
68885 +
68886 +int
68887 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68888 + const int unsafe_share)
68889 +{
68890 + return 0;
68891 +}
68892 +
68893 +void
68894 +gr_handle_delete(const ino_t ino, const dev_t dev)
68895 +{
68896 + return;
68897 +}
68898 +
68899 +void
68900 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68901 +{
68902 + return;
68903 +}
68904 +
68905 +void
68906 +gr_handle_crash(struct task_struct *task, const int sig)
68907 +{
68908 + return;
68909 +}
68910 +
68911 +int
68912 +gr_check_crash_exec(const struct file *filp)
68913 +{
68914 + return 0;
68915 +}
68916 +
68917 +int
68918 +gr_check_crash_uid(const kuid_t uid)
68919 +{
68920 + return 0;
68921 +}
68922 +
68923 +void
68924 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68925 + struct dentry *old_dentry,
68926 + struct dentry *new_dentry,
68927 + struct vfsmount *mnt, const __u8 replace)
68928 +{
68929 + return;
68930 +}
68931 +
68932 +int
68933 +gr_search_socket(const int family, const int type, const int protocol)
68934 +{
68935 + return 1;
68936 +}
68937 +
68938 +int
68939 +gr_search_connectbind(const int mode, const struct socket *sock,
68940 + const struct sockaddr_in *addr)
68941 +{
68942 + return 0;
68943 +}
68944 +
68945 +void
68946 +gr_handle_alertkill(struct task_struct *task)
68947 +{
68948 + return;
68949 +}
68950 +
68951 +__u32
68952 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
68953 +{
68954 + return 1;
68955 +}
68956 +
68957 +__u32
68958 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68959 + const struct vfsmount * mnt)
68960 +{
68961 + return 1;
68962 +}
68963 +
68964 +__u32
68965 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68966 + int acc_mode)
68967 +{
68968 + return 1;
68969 +}
68970 +
68971 +__u32
68972 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68973 +{
68974 + return 1;
68975 +}
68976 +
68977 +__u32
68978 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
68979 +{
68980 + return 1;
68981 +}
68982 +
68983 +int
68984 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
68985 + unsigned int *vm_flags)
68986 +{
68987 + return 1;
68988 +}
68989 +
68990 +__u32
68991 +gr_acl_handle_truncate(const struct dentry * dentry,
68992 + const struct vfsmount * mnt)
68993 +{
68994 + return 1;
68995 +}
68996 +
68997 +__u32
68998 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
68999 +{
69000 + return 1;
69001 +}
69002 +
69003 +__u32
69004 +gr_acl_handle_access(const struct dentry * dentry,
69005 + const struct vfsmount * mnt, const int fmode)
69006 +{
69007 + return 1;
69008 +}
69009 +
69010 +__u32
69011 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69012 + umode_t *mode)
69013 +{
69014 + return 1;
69015 +}
69016 +
69017 +__u32
69018 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69019 +{
69020 + return 1;
69021 +}
69022 +
69023 +__u32
69024 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69025 +{
69026 + return 1;
69027 +}
69028 +
69029 +void
69030 +grsecurity_init(void)
69031 +{
69032 + return;
69033 +}
69034 +
69035 +umode_t gr_acl_umask(void)
69036 +{
69037 + return 0;
69038 +}
69039 +
69040 +__u32
69041 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69042 + const struct dentry * parent_dentry,
69043 + const struct vfsmount * parent_mnt,
69044 + const int mode)
69045 +{
69046 + return 1;
69047 +}
69048 +
69049 +__u32
69050 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69051 + const struct dentry * parent_dentry,
69052 + const struct vfsmount * parent_mnt)
69053 +{
69054 + return 1;
69055 +}
69056 +
69057 +__u32
69058 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69059 + const struct dentry * parent_dentry,
69060 + const struct vfsmount * parent_mnt, const struct filename *from)
69061 +{
69062 + return 1;
69063 +}
69064 +
69065 +__u32
69066 +gr_acl_handle_link(const struct dentry * new_dentry,
69067 + const struct dentry * parent_dentry,
69068 + const struct vfsmount * parent_mnt,
69069 + const struct dentry * old_dentry,
69070 + const struct vfsmount * old_mnt, const struct filename *to)
69071 +{
69072 + return 1;
69073 +}
69074 +
69075 +int
69076 +gr_acl_handle_rename(const struct dentry *new_dentry,
69077 + const struct dentry *parent_dentry,
69078 + const struct vfsmount *parent_mnt,
69079 + const struct dentry *old_dentry,
69080 + const struct inode *old_parent_inode,
69081 + const struct vfsmount *old_mnt, const struct filename *newname)
69082 +{
69083 + return 0;
69084 +}
69085 +
69086 +int
69087 +gr_acl_handle_filldir(const struct file *file, const char *name,
69088 + const int namelen, const ino_t ino)
69089 +{
69090 + return 1;
69091 +}
69092 +
69093 +int
69094 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69095 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69096 +{
69097 + return 1;
69098 +}
69099 +
69100 +int
69101 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69102 +{
69103 + return 0;
69104 +}
69105 +
69106 +int
69107 +gr_search_accept(const struct socket *sock)
69108 +{
69109 + return 0;
69110 +}
69111 +
69112 +int
69113 +gr_search_listen(const struct socket *sock)
69114 +{
69115 + return 0;
69116 +}
69117 +
69118 +int
69119 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69120 +{
69121 + return 0;
69122 +}
69123 +
69124 +__u32
69125 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69126 +{
69127 + return 1;
69128 +}
69129 +
69130 +__u32
69131 +gr_acl_handle_creat(const struct dentry * dentry,
69132 + const struct dentry * p_dentry,
69133 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69134 + const int imode)
69135 +{
69136 + return 1;
69137 +}
69138 +
69139 +void
69140 +gr_acl_handle_exit(void)
69141 +{
69142 + return;
69143 +}
69144 +
69145 +int
69146 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69147 +{
69148 + return 1;
69149 +}
69150 +
69151 +void
69152 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69153 +{
69154 + return;
69155 +}
69156 +
69157 +int
69158 +gr_acl_handle_procpidmem(const struct task_struct *task)
69159 +{
69160 + return 0;
69161 +}
69162 +
69163 +int
69164 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69165 +{
69166 + return 0;
69167 +}
69168 +
69169 +int
69170 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69171 +{
69172 + return 0;
69173 +}
69174 +
69175 +void
69176 +gr_set_kernel_label(struct task_struct *task)
69177 +{
69178 + return;
69179 +}
69180 +
69181 +int
69182 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69183 +{
69184 + return 0;
69185 +}
69186 +
69187 +int
69188 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69189 +{
69190 + return 0;
69191 +}
69192 +
69193 +int gr_acl_enable_at_secure(void)
69194 +{
69195 + return 0;
69196 +}
69197 +
69198 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69199 +{
69200 + return dentry->d_sb->s_dev;
69201 +}
69202 +
69203 +void gr_put_exec_file(struct task_struct *task)
69204 +{
69205 + return;
69206 +}
69207 +
69208 +EXPORT_SYMBOL(gr_set_kernel_label);
69209 +#ifdef CONFIG_SECURITY
69210 +EXPORT_SYMBOL(gr_check_user_change);
69211 +EXPORT_SYMBOL(gr_check_group_change);
69212 +#endif
69213 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69214 new file mode 100644
69215 index 0000000..387032b
69216 --- /dev/null
69217 +++ b/grsecurity/grsec_exec.c
69218 @@ -0,0 +1,187 @@
69219 +#include <linux/kernel.h>
69220 +#include <linux/sched.h>
69221 +#include <linux/file.h>
69222 +#include <linux/binfmts.h>
69223 +#include <linux/fs.h>
69224 +#include <linux/types.h>
69225 +#include <linux/grdefs.h>
69226 +#include <linux/grsecurity.h>
69227 +#include <linux/grinternal.h>
69228 +#include <linux/capability.h>
69229 +#include <linux/module.h>
69230 +#include <linux/compat.h>
69231 +
69232 +#include <asm/uaccess.h>
69233 +
69234 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69235 +static char gr_exec_arg_buf[132];
69236 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69237 +#endif
69238 +
69239 +struct user_arg_ptr {
69240 +#ifdef CONFIG_COMPAT
69241 + bool is_compat;
69242 +#endif
69243 + union {
69244 + const char __user *const __user *native;
69245 +#ifdef CONFIG_COMPAT
69246 + const compat_uptr_t __user *compat;
69247 +#endif
69248 + } ptr;
69249 +};
69250 +
69251 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69252 +
69253 +void
69254 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69255 +{
69256 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69257 + char *grarg = gr_exec_arg_buf;
69258 + unsigned int i, x, execlen = 0;
69259 + char c;
69260 +
69261 + if (!((grsec_enable_execlog && grsec_enable_group &&
69262 + in_group_p(grsec_audit_gid))
69263 + || (grsec_enable_execlog && !grsec_enable_group)))
69264 + return;
69265 +
69266 + mutex_lock(&gr_exec_arg_mutex);
69267 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69268 +
69269 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69270 + const char __user *p;
69271 + unsigned int len;
69272 +
69273 + p = get_user_arg_ptr(argv, i);
69274 + if (IS_ERR(p))
69275 + goto log;
69276 +
69277 + len = strnlen_user(p, 128 - execlen);
69278 + if (len > 128 - execlen)
69279 + len = 128 - execlen;
69280 + else if (len > 0)
69281 + len--;
69282 + if (copy_from_user(grarg + execlen, p, len))
69283 + goto log;
69284 +
69285 + /* rewrite unprintable characters */
69286 + for (x = 0; x < len; x++) {
69287 + c = *(grarg + execlen + x);
69288 + if (c < 32 || c > 126)
69289 + *(grarg + execlen + x) = ' ';
69290 + }
69291 +
69292 + execlen += len;
69293 + *(grarg + execlen) = ' ';
69294 + *(grarg + execlen + 1) = '\0';
69295 + execlen++;
69296 + }
69297 +
69298 + log:
69299 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69300 + bprm->file->f_path.mnt, grarg);
69301 + mutex_unlock(&gr_exec_arg_mutex);
69302 +#endif
69303 + return;
69304 +}
69305 +
69306 +#ifdef CONFIG_GRKERNSEC
69307 +extern int gr_acl_is_capable(const int cap);
69308 +extern int gr_acl_is_capable_nolog(const int cap);
69309 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69310 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69311 +extern int gr_chroot_is_capable(const int cap);
69312 +extern int gr_chroot_is_capable_nolog(const int cap);
69313 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69314 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69315 +#endif
69316 +
69317 +const char *captab_log[] = {
69318 + "CAP_CHOWN",
69319 + "CAP_DAC_OVERRIDE",
69320 + "CAP_DAC_READ_SEARCH",
69321 + "CAP_FOWNER",
69322 + "CAP_FSETID",
69323 + "CAP_KILL",
69324 + "CAP_SETGID",
69325 + "CAP_SETUID",
69326 + "CAP_SETPCAP",
69327 + "CAP_LINUX_IMMUTABLE",
69328 + "CAP_NET_BIND_SERVICE",
69329 + "CAP_NET_BROADCAST",
69330 + "CAP_NET_ADMIN",
69331 + "CAP_NET_RAW",
69332 + "CAP_IPC_LOCK",
69333 + "CAP_IPC_OWNER",
69334 + "CAP_SYS_MODULE",
69335 + "CAP_SYS_RAWIO",
69336 + "CAP_SYS_CHROOT",
69337 + "CAP_SYS_PTRACE",
69338 + "CAP_SYS_PACCT",
69339 + "CAP_SYS_ADMIN",
69340 + "CAP_SYS_BOOT",
69341 + "CAP_SYS_NICE",
69342 + "CAP_SYS_RESOURCE",
69343 + "CAP_SYS_TIME",
69344 + "CAP_SYS_TTY_CONFIG",
69345 + "CAP_MKNOD",
69346 + "CAP_LEASE",
69347 + "CAP_AUDIT_WRITE",
69348 + "CAP_AUDIT_CONTROL",
69349 + "CAP_SETFCAP",
69350 + "CAP_MAC_OVERRIDE",
69351 + "CAP_MAC_ADMIN",
69352 + "CAP_SYSLOG",
69353 + "CAP_WAKE_ALARM"
69354 +};
69355 +
69356 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69357 +
69358 +int gr_is_capable(const int cap)
69359 +{
69360 +#ifdef CONFIG_GRKERNSEC
69361 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69362 + return 1;
69363 + return 0;
69364 +#else
69365 + return 1;
69366 +#endif
69367 +}
69368 +
69369 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69370 +{
69371 +#ifdef CONFIG_GRKERNSEC
69372 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69373 + return 1;
69374 + return 0;
69375 +#else
69376 + return 1;
69377 +#endif
69378 +}
69379 +
69380 +int gr_is_capable_nolog(const int cap)
69381 +{
69382 +#ifdef CONFIG_GRKERNSEC
69383 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69384 + return 1;
69385 + return 0;
69386 +#else
69387 + return 1;
69388 +#endif
69389 +}
69390 +
69391 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69392 +{
69393 +#ifdef CONFIG_GRKERNSEC
69394 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69395 + return 1;
69396 + return 0;
69397 +#else
69398 + return 1;
69399 +#endif
69400 +}
69401 +
69402 +EXPORT_SYMBOL(gr_is_capable);
69403 +EXPORT_SYMBOL(gr_is_capable_nolog);
69404 +EXPORT_SYMBOL(gr_task_is_capable);
69405 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69406 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69407 new file mode 100644
69408 index 0000000..06cc6ea
69409 --- /dev/null
69410 +++ b/grsecurity/grsec_fifo.c
69411 @@ -0,0 +1,24 @@
69412 +#include <linux/kernel.h>
69413 +#include <linux/sched.h>
69414 +#include <linux/fs.h>
69415 +#include <linux/file.h>
69416 +#include <linux/grinternal.h>
69417 +
69418 +int
69419 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69420 + const struct dentry *dir, const int flag, const int acc_mode)
69421 +{
69422 +#ifdef CONFIG_GRKERNSEC_FIFO
69423 + const struct cred *cred = current_cred();
69424 +
69425 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69426 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69427 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69428 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69429 + if (!inode_permission(dentry->d_inode, acc_mode))
69430 + 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));
69431 + return -EACCES;
69432 + }
69433 +#endif
69434 + return 0;
69435 +}
69436 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69437 new file mode 100644
69438 index 0000000..8ca18bf
69439 --- /dev/null
69440 +++ b/grsecurity/grsec_fork.c
69441 @@ -0,0 +1,23 @@
69442 +#include <linux/kernel.h>
69443 +#include <linux/sched.h>
69444 +#include <linux/grsecurity.h>
69445 +#include <linux/grinternal.h>
69446 +#include <linux/errno.h>
69447 +
69448 +void
69449 +gr_log_forkfail(const int retval)
69450 +{
69451 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69452 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69453 + switch (retval) {
69454 + case -EAGAIN:
69455 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69456 + break;
69457 + case -ENOMEM:
69458 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69459 + break;
69460 + }
69461 + }
69462 +#endif
69463 + return;
69464 +}
69465 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69466 new file mode 100644
69467 index 0000000..99a0cb9
69468 --- /dev/null
69469 +++ b/grsecurity/grsec_init.c
69470 @@ -0,0 +1,283 @@
69471 +#include <linux/kernel.h>
69472 +#include <linux/sched.h>
69473 +#include <linux/mm.h>
69474 +#include <linux/gracl.h>
69475 +#include <linux/slab.h>
69476 +#include <linux/vmalloc.h>
69477 +#include <linux/percpu.h>
69478 +#include <linux/module.h>
69479 +
69480 +int grsec_enable_ptrace_readexec;
69481 +int grsec_enable_setxid;
69482 +int grsec_enable_symlinkown;
69483 +kgid_t grsec_symlinkown_gid;
69484 +int grsec_enable_brute;
69485 +int grsec_enable_link;
69486 +int grsec_enable_dmesg;
69487 +int grsec_enable_harden_ptrace;
69488 +int grsec_enable_fifo;
69489 +int grsec_enable_execlog;
69490 +int grsec_enable_signal;
69491 +int grsec_enable_forkfail;
69492 +int grsec_enable_audit_ptrace;
69493 +int grsec_enable_time;
69494 +int grsec_enable_group;
69495 +kgid_t grsec_audit_gid;
69496 +int grsec_enable_chdir;
69497 +int grsec_enable_mount;
69498 +int grsec_enable_rofs;
69499 +int grsec_deny_new_usb;
69500 +int grsec_enable_chroot_findtask;
69501 +int grsec_enable_chroot_mount;
69502 +int grsec_enable_chroot_shmat;
69503 +int grsec_enable_chroot_fchdir;
69504 +int grsec_enable_chroot_double;
69505 +int grsec_enable_chroot_pivot;
69506 +int grsec_enable_chroot_chdir;
69507 +int grsec_enable_chroot_chmod;
69508 +int grsec_enable_chroot_mknod;
69509 +int grsec_enable_chroot_nice;
69510 +int grsec_enable_chroot_execlog;
69511 +int grsec_enable_chroot_caps;
69512 +int grsec_enable_chroot_sysctl;
69513 +int grsec_enable_chroot_unix;
69514 +int grsec_enable_tpe;
69515 +kgid_t grsec_tpe_gid;
69516 +int grsec_enable_blackhole;
69517 +#ifdef CONFIG_IPV6_MODULE
69518 +EXPORT_SYMBOL(grsec_enable_blackhole);
69519 +#endif
69520 +int grsec_lastack_retries;
69521 +int grsec_enable_tpe_all;
69522 +int grsec_enable_tpe_invert;
69523 +int grsec_enable_socket_all;
69524 +kgid_t grsec_socket_all_gid;
69525 +int grsec_enable_socket_client;
69526 +kgid_t grsec_socket_client_gid;
69527 +int grsec_enable_socket_server;
69528 +kgid_t grsec_socket_server_gid;
69529 +int grsec_resource_logging;
69530 +int grsec_disable_privio;
69531 +int grsec_enable_log_rwxmaps;
69532 +int grsec_lock;
69533 +
69534 +DEFINE_SPINLOCK(grsec_alert_lock);
69535 +unsigned long grsec_alert_wtime = 0;
69536 +unsigned long grsec_alert_fyet = 0;
69537 +
69538 +DEFINE_SPINLOCK(grsec_audit_lock);
69539 +
69540 +DEFINE_RWLOCK(grsec_exec_file_lock);
69541 +
69542 +char *gr_shared_page[4];
69543 +
69544 +char *gr_alert_log_fmt;
69545 +char *gr_audit_log_fmt;
69546 +char *gr_alert_log_buf;
69547 +char *gr_audit_log_buf;
69548 +
69549 +extern struct gr_arg *gr_usermode;
69550 +extern unsigned char *gr_system_salt;
69551 +extern unsigned char *gr_system_sum;
69552 +
69553 +void __init
69554 +grsecurity_init(void)
69555 +{
69556 + int j;
69557 + /* create the per-cpu shared pages */
69558 +
69559 +#ifdef CONFIG_X86
69560 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69561 +#endif
69562 +
69563 + for (j = 0; j < 4; j++) {
69564 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69565 + if (gr_shared_page[j] == NULL) {
69566 + panic("Unable to allocate grsecurity shared page");
69567 + return;
69568 + }
69569 + }
69570 +
69571 + /* allocate log buffers */
69572 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69573 + if (!gr_alert_log_fmt) {
69574 + panic("Unable to allocate grsecurity alert log format buffer");
69575 + return;
69576 + }
69577 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69578 + if (!gr_audit_log_fmt) {
69579 + panic("Unable to allocate grsecurity audit log format buffer");
69580 + return;
69581 + }
69582 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69583 + if (!gr_alert_log_buf) {
69584 + panic("Unable to allocate grsecurity alert log buffer");
69585 + return;
69586 + }
69587 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69588 + if (!gr_audit_log_buf) {
69589 + panic("Unable to allocate grsecurity audit log buffer");
69590 + return;
69591 + }
69592 +
69593 + /* allocate memory for authentication structure */
69594 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69595 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69596 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69597 +
69598 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69599 + panic("Unable to allocate grsecurity authentication structure");
69600 + return;
69601 + }
69602 +
69603 +
69604 +#ifdef CONFIG_GRKERNSEC_IO
69605 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69606 + grsec_disable_privio = 1;
69607 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69608 + grsec_disable_privio = 1;
69609 +#else
69610 + grsec_disable_privio = 0;
69611 +#endif
69612 +#endif
69613 +
69614 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69615 + /* for backward compatibility, tpe_invert always defaults to on if
69616 + enabled in the kernel
69617 + */
69618 + grsec_enable_tpe_invert = 1;
69619 +#endif
69620 +
69621 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69622 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69623 + grsec_lock = 1;
69624 +#endif
69625 +
69626 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69627 + grsec_enable_log_rwxmaps = 1;
69628 +#endif
69629 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69630 + grsec_enable_group = 1;
69631 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69632 +#endif
69633 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69634 + grsec_enable_ptrace_readexec = 1;
69635 +#endif
69636 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69637 + grsec_enable_chdir = 1;
69638 +#endif
69639 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69640 + grsec_enable_harden_ptrace = 1;
69641 +#endif
69642 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69643 + grsec_enable_mount = 1;
69644 +#endif
69645 +#ifdef CONFIG_GRKERNSEC_LINK
69646 + grsec_enable_link = 1;
69647 +#endif
69648 +#ifdef CONFIG_GRKERNSEC_BRUTE
69649 + grsec_enable_brute = 1;
69650 +#endif
69651 +#ifdef CONFIG_GRKERNSEC_DMESG
69652 + grsec_enable_dmesg = 1;
69653 +#endif
69654 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69655 + grsec_enable_blackhole = 1;
69656 + grsec_lastack_retries = 4;
69657 +#endif
69658 +#ifdef CONFIG_GRKERNSEC_FIFO
69659 + grsec_enable_fifo = 1;
69660 +#endif
69661 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69662 + grsec_enable_execlog = 1;
69663 +#endif
69664 +#ifdef CONFIG_GRKERNSEC_SETXID
69665 + grsec_enable_setxid = 1;
69666 +#endif
69667 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69668 + grsec_enable_signal = 1;
69669 +#endif
69670 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69671 + grsec_enable_forkfail = 1;
69672 +#endif
69673 +#ifdef CONFIG_GRKERNSEC_TIME
69674 + grsec_enable_time = 1;
69675 +#endif
69676 +#ifdef CONFIG_GRKERNSEC_RESLOG
69677 + grsec_resource_logging = 1;
69678 +#endif
69679 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69680 + grsec_enable_chroot_findtask = 1;
69681 +#endif
69682 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69683 + grsec_enable_chroot_unix = 1;
69684 +#endif
69685 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69686 + grsec_enable_chroot_mount = 1;
69687 +#endif
69688 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69689 + grsec_enable_chroot_fchdir = 1;
69690 +#endif
69691 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69692 + grsec_enable_chroot_shmat = 1;
69693 +#endif
69694 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69695 + grsec_enable_audit_ptrace = 1;
69696 +#endif
69697 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69698 + grsec_enable_chroot_double = 1;
69699 +#endif
69700 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69701 + grsec_enable_chroot_pivot = 1;
69702 +#endif
69703 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69704 + grsec_enable_chroot_chdir = 1;
69705 +#endif
69706 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69707 + grsec_enable_chroot_chmod = 1;
69708 +#endif
69709 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69710 + grsec_enable_chroot_mknod = 1;
69711 +#endif
69712 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69713 + grsec_enable_chroot_nice = 1;
69714 +#endif
69715 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69716 + grsec_enable_chroot_execlog = 1;
69717 +#endif
69718 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69719 + grsec_enable_chroot_caps = 1;
69720 +#endif
69721 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69722 + grsec_enable_chroot_sysctl = 1;
69723 +#endif
69724 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69725 + grsec_enable_symlinkown = 1;
69726 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69727 +#endif
69728 +#ifdef CONFIG_GRKERNSEC_TPE
69729 + grsec_enable_tpe = 1;
69730 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69731 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69732 + grsec_enable_tpe_all = 1;
69733 +#endif
69734 +#endif
69735 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69736 + grsec_enable_socket_all = 1;
69737 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69738 +#endif
69739 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69740 + grsec_enable_socket_client = 1;
69741 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69742 +#endif
69743 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69744 + grsec_enable_socket_server = 1;
69745 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69746 +#endif
69747 +#endif
69748 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69749 + grsec_deny_new_usb = 1;
69750 +#endif
69751 +
69752 + return;
69753 +}
69754 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69755 new file mode 100644
69756 index 0000000..5e05e20
69757 --- /dev/null
69758 +++ b/grsecurity/grsec_link.c
69759 @@ -0,0 +1,58 @@
69760 +#include <linux/kernel.h>
69761 +#include <linux/sched.h>
69762 +#include <linux/fs.h>
69763 +#include <linux/file.h>
69764 +#include <linux/grinternal.h>
69765 +
69766 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69767 +{
69768 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69769 + const struct inode *link_inode = link->dentry->d_inode;
69770 +
69771 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69772 + /* ignore root-owned links, e.g. /proc/self */
69773 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69774 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69775 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69776 + return 1;
69777 + }
69778 +#endif
69779 + return 0;
69780 +}
69781 +
69782 +int
69783 +gr_handle_follow_link(const struct inode *parent,
69784 + const struct inode *inode,
69785 + const struct dentry *dentry, const struct vfsmount *mnt)
69786 +{
69787 +#ifdef CONFIG_GRKERNSEC_LINK
69788 + const struct cred *cred = current_cred();
69789 +
69790 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69791 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69792 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69793 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69794 + return -EACCES;
69795 + }
69796 +#endif
69797 + return 0;
69798 +}
69799 +
69800 +int
69801 +gr_handle_hardlink(const struct dentry *dentry,
69802 + const struct vfsmount *mnt,
69803 + struct inode *inode, const int mode, const struct filename *to)
69804 +{
69805 +#ifdef CONFIG_GRKERNSEC_LINK
69806 + const struct cred *cred = current_cred();
69807 +
69808 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69809 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69810 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69811 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69812 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69813 + return -EPERM;
69814 + }
69815 +#endif
69816 + return 0;
69817 +}
69818 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69819 new file mode 100644
69820 index 0000000..dbe0a6b
69821 --- /dev/null
69822 +++ b/grsecurity/grsec_log.c
69823 @@ -0,0 +1,341 @@
69824 +#include <linux/kernel.h>
69825 +#include <linux/sched.h>
69826 +#include <linux/file.h>
69827 +#include <linux/tty.h>
69828 +#include <linux/fs.h>
69829 +#include <linux/mm.h>
69830 +#include <linux/grinternal.h>
69831 +
69832 +#ifdef CONFIG_TREE_PREEMPT_RCU
69833 +#define DISABLE_PREEMPT() preempt_disable()
69834 +#define ENABLE_PREEMPT() preempt_enable()
69835 +#else
69836 +#define DISABLE_PREEMPT()
69837 +#define ENABLE_PREEMPT()
69838 +#endif
69839 +
69840 +#define BEGIN_LOCKS(x) \
69841 + DISABLE_PREEMPT(); \
69842 + rcu_read_lock(); \
69843 + read_lock(&tasklist_lock); \
69844 + read_lock(&grsec_exec_file_lock); \
69845 + if (x != GR_DO_AUDIT) \
69846 + spin_lock(&grsec_alert_lock); \
69847 + else \
69848 + spin_lock(&grsec_audit_lock)
69849 +
69850 +#define END_LOCKS(x) \
69851 + if (x != GR_DO_AUDIT) \
69852 + spin_unlock(&grsec_alert_lock); \
69853 + else \
69854 + spin_unlock(&grsec_audit_lock); \
69855 + read_unlock(&grsec_exec_file_lock); \
69856 + read_unlock(&tasklist_lock); \
69857 + rcu_read_unlock(); \
69858 + ENABLE_PREEMPT(); \
69859 + if (x == GR_DONT_AUDIT) \
69860 + gr_handle_alertkill(current)
69861 +
69862 +enum {
69863 + FLOODING,
69864 + NO_FLOODING
69865 +};
69866 +
69867 +extern char *gr_alert_log_fmt;
69868 +extern char *gr_audit_log_fmt;
69869 +extern char *gr_alert_log_buf;
69870 +extern char *gr_audit_log_buf;
69871 +
69872 +static int gr_log_start(int audit)
69873 +{
69874 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
69875 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
69876 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69877 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
69878 + unsigned long curr_secs = get_seconds();
69879 +
69880 + if (audit == GR_DO_AUDIT)
69881 + goto set_fmt;
69882 +
69883 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
69884 + grsec_alert_wtime = curr_secs;
69885 + grsec_alert_fyet = 0;
69886 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
69887 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
69888 + grsec_alert_fyet++;
69889 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
69890 + grsec_alert_wtime = curr_secs;
69891 + grsec_alert_fyet++;
69892 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
69893 + return FLOODING;
69894 + }
69895 + else return FLOODING;
69896 +
69897 +set_fmt:
69898 +#endif
69899 + memset(buf, 0, PAGE_SIZE);
69900 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
69901 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
69902 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69903 + } else if (current->signal->curr_ip) {
69904 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
69905 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
69906 + } else if (gr_acl_is_enabled()) {
69907 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
69908 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69909 + } else {
69910 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
69911 + strcpy(buf, fmt);
69912 + }
69913 +
69914 + return NO_FLOODING;
69915 +}
69916 +
69917 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69918 + __attribute__ ((format (printf, 2, 0)));
69919 +
69920 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69921 +{
69922 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69923 + unsigned int len = strlen(buf);
69924 +
69925 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69926 +
69927 + return;
69928 +}
69929 +
69930 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69931 + __attribute__ ((format (printf, 2, 3)));
69932 +
69933 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69934 +{
69935 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69936 + unsigned int len = strlen(buf);
69937 + va_list ap;
69938 +
69939 + va_start(ap, msg);
69940 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69941 + va_end(ap);
69942 +
69943 + return;
69944 +}
69945 +
69946 +static void gr_log_end(int audit, int append_default)
69947 +{
69948 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69949 + if (append_default) {
69950 + struct task_struct *task = current;
69951 + struct task_struct *parent = task->real_parent;
69952 + const struct cred *cred = __task_cred(task);
69953 + const struct cred *pcred = __task_cred(parent);
69954 + unsigned int len = strlen(buf);
69955 +
69956 + 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));
69957 + }
69958 +
69959 + printk("%s\n", buf);
69960 +
69961 + return;
69962 +}
69963 +
69964 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
69965 +{
69966 + int logtype;
69967 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
69968 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
69969 + void *voidptr = NULL;
69970 + int num1 = 0, num2 = 0;
69971 + unsigned long ulong1 = 0, ulong2 = 0;
69972 + struct dentry *dentry = NULL;
69973 + struct vfsmount *mnt = NULL;
69974 + struct file *file = NULL;
69975 + struct task_struct *task = NULL;
69976 + struct vm_area_struct *vma = NULL;
69977 + const struct cred *cred, *pcred;
69978 + va_list ap;
69979 +
69980 + BEGIN_LOCKS(audit);
69981 + logtype = gr_log_start(audit);
69982 + if (logtype == FLOODING) {
69983 + END_LOCKS(audit);
69984 + return;
69985 + }
69986 + va_start(ap, argtypes);
69987 + switch (argtypes) {
69988 + case GR_TTYSNIFF:
69989 + task = va_arg(ap, struct task_struct *);
69990 + 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));
69991 + break;
69992 + case GR_SYSCTL_HIDDEN:
69993 + str1 = va_arg(ap, char *);
69994 + gr_log_middle_varargs(audit, msg, result, str1);
69995 + break;
69996 + case GR_RBAC:
69997 + dentry = va_arg(ap, struct dentry *);
69998 + mnt = va_arg(ap, struct vfsmount *);
69999 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70000 + break;
70001 + case GR_RBAC_STR:
70002 + dentry = va_arg(ap, struct dentry *);
70003 + mnt = va_arg(ap, struct vfsmount *);
70004 + str1 = va_arg(ap, char *);
70005 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70006 + break;
70007 + case GR_STR_RBAC:
70008 + str1 = va_arg(ap, char *);
70009 + dentry = va_arg(ap, struct dentry *);
70010 + mnt = va_arg(ap, struct vfsmount *);
70011 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70012 + break;
70013 + case GR_RBAC_MODE2:
70014 + dentry = va_arg(ap, struct dentry *);
70015 + mnt = va_arg(ap, struct vfsmount *);
70016 + str1 = va_arg(ap, char *);
70017 + str2 = va_arg(ap, char *);
70018 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70019 + break;
70020 + case GR_RBAC_MODE3:
70021 + dentry = va_arg(ap, struct dentry *);
70022 + mnt = va_arg(ap, struct vfsmount *);
70023 + str1 = va_arg(ap, char *);
70024 + str2 = va_arg(ap, char *);
70025 + str3 = va_arg(ap, char *);
70026 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70027 + break;
70028 + case GR_FILENAME:
70029 + dentry = va_arg(ap, struct dentry *);
70030 + mnt = va_arg(ap, struct vfsmount *);
70031 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70032 + break;
70033 + case GR_STR_FILENAME:
70034 + str1 = va_arg(ap, char *);
70035 + dentry = va_arg(ap, struct dentry *);
70036 + mnt = va_arg(ap, struct vfsmount *);
70037 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70038 + break;
70039 + case GR_FILENAME_STR:
70040 + dentry = va_arg(ap, struct dentry *);
70041 + mnt = va_arg(ap, struct vfsmount *);
70042 + str1 = va_arg(ap, char *);
70043 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70044 + break;
70045 + case GR_FILENAME_TWO_INT:
70046 + dentry = va_arg(ap, struct dentry *);
70047 + mnt = va_arg(ap, struct vfsmount *);
70048 + num1 = va_arg(ap, int);
70049 + num2 = va_arg(ap, int);
70050 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70051 + break;
70052 + case GR_FILENAME_TWO_INT_STR:
70053 + dentry = va_arg(ap, struct dentry *);
70054 + mnt = va_arg(ap, struct vfsmount *);
70055 + num1 = va_arg(ap, int);
70056 + num2 = va_arg(ap, int);
70057 + str1 = va_arg(ap, char *);
70058 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70059 + break;
70060 + case GR_TEXTREL:
70061 + file = va_arg(ap, struct file *);
70062 + ulong1 = va_arg(ap, unsigned long);
70063 + ulong2 = va_arg(ap, unsigned long);
70064 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70065 + break;
70066 + case GR_PTRACE:
70067 + task = va_arg(ap, struct task_struct *);
70068 + 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));
70069 + break;
70070 + case GR_RESOURCE:
70071 + task = va_arg(ap, struct task_struct *);
70072 + cred = __task_cred(task);
70073 + pcred = __task_cred(task->real_parent);
70074 + ulong1 = va_arg(ap, unsigned long);
70075 + str1 = va_arg(ap, char *);
70076 + ulong2 = va_arg(ap, unsigned long);
70077 + 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));
70078 + break;
70079 + case GR_CAP:
70080 + task = va_arg(ap, struct task_struct *);
70081 + cred = __task_cred(task);
70082 + pcred = __task_cred(task->real_parent);
70083 + str1 = va_arg(ap, char *);
70084 + 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));
70085 + break;
70086 + case GR_SIG:
70087 + str1 = va_arg(ap, char *);
70088 + voidptr = va_arg(ap, void *);
70089 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70090 + break;
70091 + case GR_SIG2:
70092 + task = va_arg(ap, struct task_struct *);
70093 + cred = __task_cred(task);
70094 + pcred = __task_cred(task->real_parent);
70095 + num1 = va_arg(ap, int);
70096 + 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));
70097 + break;
70098 + case GR_CRASH1:
70099 + task = va_arg(ap, struct task_struct *);
70100 + cred = __task_cred(task);
70101 + pcred = __task_cred(task->real_parent);
70102 + ulong1 = va_arg(ap, unsigned long);
70103 + 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);
70104 + break;
70105 + case GR_CRASH2:
70106 + task = va_arg(ap, struct task_struct *);
70107 + cred = __task_cred(task);
70108 + pcred = __task_cred(task->real_parent);
70109 + ulong1 = va_arg(ap, unsigned long);
70110 + 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);
70111 + break;
70112 + case GR_RWXMAP:
70113 + file = va_arg(ap, struct file *);
70114 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70115 + break;
70116 + case GR_RWXMAPVMA:
70117 + vma = va_arg(ap, struct vm_area_struct *);
70118 + if (vma->vm_file)
70119 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70120 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70121 + str1 = "<stack>";
70122 + else if (vma->vm_start <= current->mm->brk &&
70123 + vma->vm_end >= current->mm->start_brk)
70124 + str1 = "<heap>";
70125 + else
70126 + str1 = "<anonymous mapping>";
70127 + gr_log_middle_varargs(audit, msg, str1);
70128 + break;
70129 + case GR_PSACCT:
70130 + {
70131 + unsigned int wday, cday;
70132 + __u8 whr, chr;
70133 + __u8 wmin, cmin;
70134 + __u8 wsec, csec;
70135 + char cur_tty[64] = { 0 };
70136 + char parent_tty[64] = { 0 };
70137 +
70138 + task = va_arg(ap, struct task_struct *);
70139 + wday = va_arg(ap, unsigned int);
70140 + cday = va_arg(ap, unsigned int);
70141 + whr = va_arg(ap, int);
70142 + chr = va_arg(ap, int);
70143 + wmin = va_arg(ap, int);
70144 + cmin = va_arg(ap, int);
70145 + wsec = va_arg(ap, int);
70146 + csec = va_arg(ap, int);
70147 + ulong1 = va_arg(ap, unsigned long);
70148 + cred = __task_cred(task);
70149 + pcred = __task_cred(task->real_parent);
70150 +
70151 + 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));
70152 + }
70153 + break;
70154 + default:
70155 + gr_log_middle(audit, msg, ap);
70156 + }
70157 + va_end(ap);
70158 + // these don't need DEFAULTSECARGS printed on the end
70159 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70160 + gr_log_end(audit, 0);
70161 + else
70162 + gr_log_end(audit, 1);
70163 + END_LOCKS(audit);
70164 +}
70165 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70166 new file mode 100644
70167 index 0000000..f536303
70168 --- /dev/null
70169 +++ b/grsecurity/grsec_mem.c
70170 @@ -0,0 +1,40 @@
70171 +#include <linux/kernel.h>
70172 +#include <linux/sched.h>
70173 +#include <linux/mm.h>
70174 +#include <linux/mman.h>
70175 +#include <linux/grinternal.h>
70176 +
70177 +void
70178 +gr_handle_ioperm(void)
70179 +{
70180 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70181 + return;
70182 +}
70183 +
70184 +void
70185 +gr_handle_iopl(void)
70186 +{
70187 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70188 + return;
70189 +}
70190 +
70191 +void
70192 +gr_handle_mem_readwrite(u64 from, u64 to)
70193 +{
70194 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70195 + return;
70196 +}
70197 +
70198 +void
70199 +gr_handle_vm86(void)
70200 +{
70201 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70202 + return;
70203 +}
70204 +
70205 +void
70206 +gr_log_badprocpid(const char *entry)
70207 +{
70208 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70209 + return;
70210 +}
70211 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70212 new file mode 100644
70213 index 0000000..2131422
70214 --- /dev/null
70215 +++ b/grsecurity/grsec_mount.c
70216 @@ -0,0 +1,62 @@
70217 +#include <linux/kernel.h>
70218 +#include <linux/sched.h>
70219 +#include <linux/mount.h>
70220 +#include <linux/grsecurity.h>
70221 +#include <linux/grinternal.h>
70222 +
70223 +void
70224 +gr_log_remount(const char *devname, const int retval)
70225 +{
70226 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70227 + if (grsec_enable_mount && (retval >= 0))
70228 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70229 +#endif
70230 + return;
70231 +}
70232 +
70233 +void
70234 +gr_log_unmount(const char *devname, const int retval)
70235 +{
70236 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70237 + if (grsec_enable_mount && (retval >= 0))
70238 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70239 +#endif
70240 + return;
70241 +}
70242 +
70243 +void
70244 +gr_log_mount(const char *from, const char *to, const int retval)
70245 +{
70246 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70247 + if (grsec_enable_mount && (retval >= 0))
70248 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70249 +#endif
70250 + return;
70251 +}
70252 +
70253 +int
70254 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70255 +{
70256 +#ifdef CONFIG_GRKERNSEC_ROFS
70257 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70258 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70259 + return -EPERM;
70260 + } else
70261 + return 0;
70262 +#endif
70263 + return 0;
70264 +}
70265 +
70266 +int
70267 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70268 +{
70269 +#ifdef CONFIG_GRKERNSEC_ROFS
70270 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70271 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70272 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70273 + return -EPERM;
70274 + } else
70275 + return 0;
70276 +#endif
70277 + return 0;
70278 +}
70279 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70280 new file mode 100644
70281 index 0000000..6ee9d50
70282 --- /dev/null
70283 +++ b/grsecurity/grsec_pax.c
70284 @@ -0,0 +1,45 @@
70285 +#include <linux/kernel.h>
70286 +#include <linux/sched.h>
70287 +#include <linux/mm.h>
70288 +#include <linux/file.h>
70289 +#include <linux/grinternal.h>
70290 +#include <linux/grsecurity.h>
70291 +
70292 +void
70293 +gr_log_textrel(struct vm_area_struct * vma)
70294 +{
70295 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70296 + if (grsec_enable_log_rwxmaps)
70297 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70298 +#endif
70299 + return;
70300 +}
70301 +
70302 +void gr_log_ptgnustack(struct file *file)
70303 +{
70304 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70305 + if (grsec_enable_log_rwxmaps)
70306 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70307 +#endif
70308 + return;
70309 +}
70310 +
70311 +void
70312 +gr_log_rwxmmap(struct file *file)
70313 +{
70314 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70315 + if (grsec_enable_log_rwxmaps)
70316 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70317 +#endif
70318 + return;
70319 +}
70320 +
70321 +void
70322 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70323 +{
70324 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70325 + if (grsec_enable_log_rwxmaps)
70326 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70327 +#endif
70328 + return;
70329 +}
70330 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70331 new file mode 100644
70332 index 0000000..f7f29aa
70333 --- /dev/null
70334 +++ b/grsecurity/grsec_ptrace.c
70335 @@ -0,0 +1,30 @@
70336 +#include <linux/kernel.h>
70337 +#include <linux/sched.h>
70338 +#include <linux/grinternal.h>
70339 +#include <linux/security.h>
70340 +
70341 +void
70342 +gr_audit_ptrace(struct task_struct *task)
70343 +{
70344 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70345 + if (grsec_enable_audit_ptrace)
70346 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70347 +#endif
70348 + return;
70349 +}
70350 +
70351 +int
70352 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70353 +{
70354 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70355 + const struct dentry *dentry = file->f_path.dentry;
70356 + const struct vfsmount *mnt = file->f_path.mnt;
70357 +
70358 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70359 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70360 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70361 + return -EACCES;
70362 + }
70363 +#endif
70364 + return 0;
70365 +}
70366 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70367 new file mode 100644
70368 index 0000000..4e29cc7
70369 --- /dev/null
70370 +++ b/grsecurity/grsec_sig.c
70371 @@ -0,0 +1,246 @@
70372 +#include <linux/kernel.h>
70373 +#include <linux/sched.h>
70374 +#include <linux/fs.h>
70375 +#include <linux/delay.h>
70376 +#include <linux/grsecurity.h>
70377 +#include <linux/grinternal.h>
70378 +#include <linux/hardirq.h>
70379 +
70380 +char *signames[] = {
70381 + [SIGSEGV] = "Segmentation fault",
70382 + [SIGILL] = "Illegal instruction",
70383 + [SIGABRT] = "Abort",
70384 + [SIGBUS] = "Invalid alignment/Bus error"
70385 +};
70386 +
70387 +void
70388 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70389 +{
70390 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70391 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70392 + (sig == SIGABRT) || (sig == SIGBUS))) {
70393 + if (task_pid_nr(t) == task_pid_nr(current)) {
70394 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70395 + } else {
70396 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70397 + }
70398 + }
70399 +#endif
70400 + return;
70401 +}
70402 +
70403 +int
70404 +gr_handle_signal(const struct task_struct *p, const int sig)
70405 +{
70406 +#ifdef CONFIG_GRKERNSEC
70407 + /* ignore the 0 signal for protected task checks */
70408 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70409 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70410 + return -EPERM;
70411 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70412 + return -EPERM;
70413 + }
70414 +#endif
70415 + return 0;
70416 +}
70417 +
70418 +#ifdef CONFIG_GRKERNSEC
70419 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70420 +
70421 +int gr_fake_force_sig(int sig, struct task_struct *t)
70422 +{
70423 + unsigned long int flags;
70424 + int ret, blocked, ignored;
70425 + struct k_sigaction *action;
70426 +
70427 + spin_lock_irqsave(&t->sighand->siglock, flags);
70428 + action = &t->sighand->action[sig-1];
70429 + ignored = action->sa.sa_handler == SIG_IGN;
70430 + blocked = sigismember(&t->blocked, sig);
70431 + if (blocked || ignored) {
70432 + action->sa.sa_handler = SIG_DFL;
70433 + if (blocked) {
70434 + sigdelset(&t->blocked, sig);
70435 + recalc_sigpending_and_wake(t);
70436 + }
70437 + }
70438 + if (action->sa.sa_handler == SIG_DFL)
70439 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70440 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70441 +
70442 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70443 +
70444 + return ret;
70445 +}
70446 +#endif
70447 +
70448 +#ifdef CONFIG_GRKERNSEC_BRUTE
70449 +#define GR_USER_BAN_TIME (15 * 60)
70450 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70451 +
70452 +static int __get_dumpable(unsigned long mm_flags)
70453 +{
70454 + int ret;
70455 +
70456 + ret = mm_flags & MMF_DUMPABLE_MASK;
70457 + return (ret >= 2) ? 2 : ret;
70458 +}
70459 +#endif
70460 +
70461 +void gr_handle_brute_attach(unsigned long mm_flags)
70462 +{
70463 +#ifdef CONFIG_GRKERNSEC_BRUTE
70464 + struct task_struct *p = current;
70465 + kuid_t uid = GLOBAL_ROOT_UID;
70466 + int daemon = 0;
70467 +
70468 + if (!grsec_enable_brute)
70469 + return;
70470 +
70471 + rcu_read_lock();
70472 + read_lock(&tasklist_lock);
70473 + read_lock(&grsec_exec_file_lock);
70474 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70475 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70476 + p->real_parent->brute = 1;
70477 + daemon = 1;
70478 + } else {
70479 + const struct cred *cred = __task_cred(p), *cred2;
70480 + struct task_struct *tsk, *tsk2;
70481 +
70482 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70483 + struct user_struct *user;
70484 +
70485 + uid = cred->uid;
70486 +
70487 + /* this is put upon execution past expiration */
70488 + user = find_user(uid);
70489 + if (user == NULL)
70490 + goto unlock;
70491 + user->suid_banned = 1;
70492 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70493 + if (user->suid_ban_expires == ~0UL)
70494 + user->suid_ban_expires--;
70495 +
70496 + /* only kill other threads of the same binary, from the same user */
70497 + do_each_thread(tsk2, tsk) {
70498 + cred2 = __task_cred(tsk);
70499 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70500 + gr_fake_force_sig(SIGKILL, tsk);
70501 + } while_each_thread(tsk2, tsk);
70502 + }
70503 + }
70504 +unlock:
70505 + read_unlock(&grsec_exec_file_lock);
70506 + read_unlock(&tasklist_lock);
70507 + rcu_read_unlock();
70508 +
70509 + if (gr_is_global_nonroot(uid))
70510 + 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);
70511 + else if (daemon)
70512 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70513 +
70514 +#endif
70515 + return;
70516 +}
70517 +
70518 +void gr_handle_brute_check(void)
70519 +{
70520 +#ifdef CONFIG_GRKERNSEC_BRUTE
70521 + struct task_struct *p = current;
70522 +
70523 + if (unlikely(p->brute)) {
70524 + if (!grsec_enable_brute)
70525 + p->brute = 0;
70526 + else if (time_before(get_seconds(), p->brute_expires))
70527 + msleep(30 * 1000);
70528 + }
70529 +#endif
70530 + return;
70531 +}
70532 +
70533 +void gr_handle_kernel_exploit(void)
70534 +{
70535 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70536 + const struct cred *cred;
70537 + struct task_struct *tsk, *tsk2;
70538 + struct user_struct *user;
70539 + kuid_t uid;
70540 +
70541 + if (in_irq() || in_serving_softirq() || in_nmi())
70542 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70543 +
70544 + uid = current_uid();
70545 +
70546 + if (gr_is_global_root(uid))
70547 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70548 + else {
70549 + /* kill all the processes of this user, hold a reference
70550 + to their creds struct, and prevent them from creating
70551 + another process until system reset
70552 + */
70553 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70554 + GR_GLOBAL_UID(uid));
70555 + /* we intentionally leak this ref */
70556 + user = get_uid(current->cred->user);
70557 + if (user)
70558 + user->kernel_banned = 1;
70559 +
70560 + /* kill all processes of this user */
70561 + read_lock(&tasklist_lock);
70562 + do_each_thread(tsk2, tsk) {
70563 + cred = __task_cred(tsk);
70564 + if (uid_eq(cred->uid, uid))
70565 + gr_fake_force_sig(SIGKILL, tsk);
70566 + } while_each_thread(tsk2, tsk);
70567 + read_unlock(&tasklist_lock);
70568 + }
70569 +#endif
70570 +}
70571 +
70572 +#ifdef CONFIG_GRKERNSEC_BRUTE
70573 +static bool suid_ban_expired(struct user_struct *user)
70574 +{
70575 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70576 + user->suid_banned = 0;
70577 + user->suid_ban_expires = 0;
70578 + free_uid(user);
70579 + return true;
70580 + }
70581 +
70582 + return false;
70583 +}
70584 +#endif
70585 +
70586 +int gr_process_kernel_exec_ban(void)
70587 +{
70588 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70589 + if (unlikely(current->cred->user->kernel_banned))
70590 + return -EPERM;
70591 +#endif
70592 + return 0;
70593 +}
70594 +
70595 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70596 +{
70597 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70598 + if (unlikely(user->kernel_banned))
70599 + gr_fake_force_sig(SIGKILL, current);
70600 +#endif
70601 + return 0;
70602 +}
70603 +
70604 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70605 +{
70606 +#ifdef CONFIG_GRKERNSEC_BRUTE
70607 + struct user_struct *user = current->cred->user;
70608 + if (unlikely(user->suid_banned)) {
70609 + if (suid_ban_expired(user))
70610 + return 0;
70611 + /* disallow execution of suid binaries only */
70612 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70613 + return -EPERM;
70614 + }
70615 +#endif
70616 + return 0;
70617 +}
70618 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70619 new file mode 100644
70620 index 0000000..4030d57
70621 --- /dev/null
70622 +++ b/grsecurity/grsec_sock.c
70623 @@ -0,0 +1,244 @@
70624 +#include <linux/kernel.h>
70625 +#include <linux/module.h>
70626 +#include <linux/sched.h>
70627 +#include <linux/file.h>
70628 +#include <linux/net.h>
70629 +#include <linux/in.h>
70630 +#include <linux/ip.h>
70631 +#include <net/sock.h>
70632 +#include <net/inet_sock.h>
70633 +#include <linux/grsecurity.h>
70634 +#include <linux/grinternal.h>
70635 +#include <linux/gracl.h>
70636 +
70637 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70638 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70639 +
70640 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70641 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70642 +
70643 +#ifdef CONFIG_UNIX_MODULE
70644 +EXPORT_SYMBOL(gr_acl_handle_unix);
70645 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70646 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70647 +EXPORT_SYMBOL(gr_handle_create);
70648 +#endif
70649 +
70650 +#ifdef CONFIG_GRKERNSEC
70651 +#define gr_conn_table_size 32749
70652 +struct conn_table_entry {
70653 + struct conn_table_entry *next;
70654 + struct signal_struct *sig;
70655 +};
70656 +
70657 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70658 +DEFINE_SPINLOCK(gr_conn_table_lock);
70659 +
70660 +extern const char * gr_socktype_to_name(unsigned char type);
70661 +extern const char * gr_proto_to_name(unsigned char proto);
70662 +extern const char * gr_sockfamily_to_name(unsigned char family);
70663 +
70664 +static __inline__ int
70665 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70666 +{
70667 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70668 +}
70669 +
70670 +static __inline__ int
70671 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70672 + __u16 sport, __u16 dport)
70673 +{
70674 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70675 + sig->gr_sport == sport && sig->gr_dport == dport))
70676 + return 1;
70677 + else
70678 + return 0;
70679 +}
70680 +
70681 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70682 +{
70683 + struct conn_table_entry **match;
70684 + unsigned int index;
70685 +
70686 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70687 + sig->gr_sport, sig->gr_dport,
70688 + gr_conn_table_size);
70689 +
70690 + newent->sig = sig;
70691 +
70692 + match = &gr_conn_table[index];
70693 + newent->next = *match;
70694 + *match = newent;
70695 +
70696 + return;
70697 +}
70698 +
70699 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70700 +{
70701 + struct conn_table_entry *match, *last = NULL;
70702 + unsigned int index;
70703 +
70704 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70705 + sig->gr_sport, sig->gr_dport,
70706 + gr_conn_table_size);
70707 +
70708 + match = gr_conn_table[index];
70709 + while (match && !conn_match(match->sig,
70710 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70711 + sig->gr_dport)) {
70712 + last = match;
70713 + match = match->next;
70714 + }
70715 +
70716 + if (match) {
70717 + if (last)
70718 + last->next = match->next;
70719 + else
70720 + gr_conn_table[index] = NULL;
70721 + kfree(match);
70722 + }
70723 +
70724 + return;
70725 +}
70726 +
70727 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70728 + __u16 sport, __u16 dport)
70729 +{
70730 + struct conn_table_entry *match;
70731 + unsigned int index;
70732 +
70733 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70734 +
70735 + match = gr_conn_table[index];
70736 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70737 + match = match->next;
70738 +
70739 + if (match)
70740 + return match->sig;
70741 + else
70742 + return NULL;
70743 +}
70744 +
70745 +#endif
70746 +
70747 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70748 +{
70749 +#ifdef CONFIG_GRKERNSEC
70750 + struct signal_struct *sig = task->signal;
70751 + struct conn_table_entry *newent;
70752 +
70753 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70754 + if (newent == NULL)
70755 + return;
70756 + /* no bh lock needed since we are called with bh disabled */
70757 + spin_lock(&gr_conn_table_lock);
70758 + gr_del_task_from_ip_table_nolock(sig);
70759 + sig->gr_saddr = inet->inet_rcv_saddr;
70760 + sig->gr_daddr = inet->inet_daddr;
70761 + sig->gr_sport = inet->inet_sport;
70762 + sig->gr_dport = inet->inet_dport;
70763 + gr_add_to_task_ip_table_nolock(sig, newent);
70764 + spin_unlock(&gr_conn_table_lock);
70765 +#endif
70766 + return;
70767 +}
70768 +
70769 +void gr_del_task_from_ip_table(struct task_struct *task)
70770 +{
70771 +#ifdef CONFIG_GRKERNSEC
70772 + spin_lock_bh(&gr_conn_table_lock);
70773 + gr_del_task_from_ip_table_nolock(task->signal);
70774 + spin_unlock_bh(&gr_conn_table_lock);
70775 +#endif
70776 + return;
70777 +}
70778 +
70779 +void
70780 +gr_attach_curr_ip(const struct sock *sk)
70781 +{
70782 +#ifdef CONFIG_GRKERNSEC
70783 + struct signal_struct *p, *set;
70784 + const struct inet_sock *inet = inet_sk(sk);
70785 +
70786 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70787 + return;
70788 +
70789 + set = current->signal;
70790 +
70791 + spin_lock_bh(&gr_conn_table_lock);
70792 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70793 + inet->inet_dport, inet->inet_sport);
70794 + if (unlikely(p != NULL)) {
70795 + set->curr_ip = p->curr_ip;
70796 + set->used_accept = 1;
70797 + gr_del_task_from_ip_table_nolock(p);
70798 + spin_unlock_bh(&gr_conn_table_lock);
70799 + return;
70800 + }
70801 + spin_unlock_bh(&gr_conn_table_lock);
70802 +
70803 + set->curr_ip = inet->inet_daddr;
70804 + set->used_accept = 1;
70805 +#endif
70806 + return;
70807 +}
70808 +
70809 +int
70810 +gr_handle_sock_all(const int family, const int type, const int protocol)
70811 +{
70812 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70813 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70814 + (family != AF_UNIX)) {
70815 + if (family == AF_INET)
70816 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70817 + else
70818 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70819 + return -EACCES;
70820 + }
70821 +#endif
70822 + return 0;
70823 +}
70824 +
70825 +int
70826 +gr_handle_sock_server(const struct sockaddr *sck)
70827 +{
70828 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70829 + if (grsec_enable_socket_server &&
70830 + in_group_p(grsec_socket_server_gid) &&
70831 + sck && (sck->sa_family != AF_UNIX) &&
70832 + (sck->sa_family != AF_LOCAL)) {
70833 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70834 + return -EACCES;
70835 + }
70836 +#endif
70837 + return 0;
70838 +}
70839 +
70840 +int
70841 +gr_handle_sock_server_other(const struct sock *sck)
70842 +{
70843 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70844 + if (grsec_enable_socket_server &&
70845 + in_group_p(grsec_socket_server_gid) &&
70846 + sck && (sck->sk_family != AF_UNIX) &&
70847 + (sck->sk_family != AF_LOCAL)) {
70848 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70849 + return -EACCES;
70850 + }
70851 +#endif
70852 + return 0;
70853 +}
70854 +
70855 +int
70856 +gr_handle_sock_client(const struct sockaddr *sck)
70857 +{
70858 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70859 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70860 + sck && (sck->sa_family != AF_UNIX) &&
70861 + (sck->sa_family != AF_LOCAL)) {
70862 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
70863 + return -EACCES;
70864 + }
70865 +#endif
70866 + return 0;
70867 +}
70868 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
70869 new file mode 100644
70870 index 0000000..a147ae7
70871 --- /dev/null
70872 +++ b/grsecurity/grsec_sysctl.c
70873 @@ -0,0 +1,470 @@
70874 +#include <linux/kernel.h>
70875 +#include <linux/sched.h>
70876 +#include <linux/sysctl.h>
70877 +#include <linux/grsecurity.h>
70878 +#include <linux/grinternal.h>
70879 +
70880 +int
70881 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
70882 +{
70883 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70884 + if (dirname == NULL || name == NULL)
70885 + return 0;
70886 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
70887 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
70888 + return -EACCES;
70889 + }
70890 +#endif
70891 + return 0;
70892 +}
70893 +
70894 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
70895 +static int __maybe_unused __read_only one = 1;
70896 +#endif
70897 +
70898 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
70899 + defined(CONFIG_GRKERNSEC_DENYUSB)
70900 +struct ctl_table grsecurity_table[] = {
70901 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70902 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
70903 +#ifdef CONFIG_GRKERNSEC_IO
70904 + {
70905 + .procname = "disable_priv_io",
70906 + .data = &grsec_disable_privio,
70907 + .maxlen = sizeof(int),
70908 + .mode = 0600,
70909 + .proc_handler = &proc_dointvec,
70910 + },
70911 +#endif
70912 +#endif
70913 +#ifdef CONFIG_GRKERNSEC_LINK
70914 + {
70915 + .procname = "linking_restrictions",
70916 + .data = &grsec_enable_link,
70917 + .maxlen = sizeof(int),
70918 + .mode = 0600,
70919 + .proc_handler = &proc_dointvec,
70920 + },
70921 +#endif
70922 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70923 + {
70924 + .procname = "enforce_symlinksifowner",
70925 + .data = &grsec_enable_symlinkown,
70926 + .maxlen = sizeof(int),
70927 + .mode = 0600,
70928 + .proc_handler = &proc_dointvec,
70929 + },
70930 + {
70931 + .procname = "symlinkown_gid",
70932 + .data = &grsec_symlinkown_gid,
70933 + .maxlen = sizeof(int),
70934 + .mode = 0600,
70935 + .proc_handler = &proc_dointvec,
70936 + },
70937 +#endif
70938 +#ifdef CONFIG_GRKERNSEC_BRUTE
70939 + {
70940 + .procname = "deter_bruteforce",
70941 + .data = &grsec_enable_brute,
70942 + .maxlen = sizeof(int),
70943 + .mode = 0600,
70944 + .proc_handler = &proc_dointvec,
70945 + },
70946 +#endif
70947 +#ifdef CONFIG_GRKERNSEC_FIFO
70948 + {
70949 + .procname = "fifo_restrictions",
70950 + .data = &grsec_enable_fifo,
70951 + .maxlen = sizeof(int),
70952 + .mode = 0600,
70953 + .proc_handler = &proc_dointvec,
70954 + },
70955 +#endif
70956 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70957 + {
70958 + .procname = "ptrace_readexec",
70959 + .data = &grsec_enable_ptrace_readexec,
70960 + .maxlen = sizeof(int),
70961 + .mode = 0600,
70962 + .proc_handler = &proc_dointvec,
70963 + },
70964 +#endif
70965 +#ifdef CONFIG_GRKERNSEC_SETXID
70966 + {
70967 + .procname = "consistent_setxid",
70968 + .data = &grsec_enable_setxid,
70969 + .maxlen = sizeof(int),
70970 + .mode = 0600,
70971 + .proc_handler = &proc_dointvec,
70972 + },
70973 +#endif
70974 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70975 + {
70976 + .procname = "ip_blackhole",
70977 + .data = &grsec_enable_blackhole,
70978 + .maxlen = sizeof(int),
70979 + .mode = 0600,
70980 + .proc_handler = &proc_dointvec,
70981 + },
70982 + {
70983 + .procname = "lastack_retries",
70984 + .data = &grsec_lastack_retries,
70985 + .maxlen = sizeof(int),
70986 + .mode = 0600,
70987 + .proc_handler = &proc_dointvec,
70988 + },
70989 +#endif
70990 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70991 + {
70992 + .procname = "exec_logging",
70993 + .data = &grsec_enable_execlog,
70994 + .maxlen = sizeof(int),
70995 + .mode = 0600,
70996 + .proc_handler = &proc_dointvec,
70997 + },
70998 +#endif
70999 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71000 + {
71001 + .procname = "rwxmap_logging",
71002 + .data = &grsec_enable_log_rwxmaps,
71003 + .maxlen = sizeof(int),
71004 + .mode = 0600,
71005 + .proc_handler = &proc_dointvec,
71006 + },
71007 +#endif
71008 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71009 + {
71010 + .procname = "signal_logging",
71011 + .data = &grsec_enable_signal,
71012 + .maxlen = sizeof(int),
71013 + .mode = 0600,
71014 + .proc_handler = &proc_dointvec,
71015 + },
71016 +#endif
71017 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71018 + {
71019 + .procname = "forkfail_logging",
71020 + .data = &grsec_enable_forkfail,
71021 + .maxlen = sizeof(int),
71022 + .mode = 0600,
71023 + .proc_handler = &proc_dointvec,
71024 + },
71025 +#endif
71026 +#ifdef CONFIG_GRKERNSEC_TIME
71027 + {
71028 + .procname = "timechange_logging",
71029 + .data = &grsec_enable_time,
71030 + .maxlen = sizeof(int),
71031 + .mode = 0600,
71032 + .proc_handler = &proc_dointvec,
71033 + },
71034 +#endif
71035 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71036 + {
71037 + .procname = "chroot_deny_shmat",
71038 + .data = &grsec_enable_chroot_shmat,
71039 + .maxlen = sizeof(int),
71040 + .mode = 0600,
71041 + .proc_handler = &proc_dointvec,
71042 + },
71043 +#endif
71044 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71045 + {
71046 + .procname = "chroot_deny_unix",
71047 + .data = &grsec_enable_chroot_unix,
71048 + .maxlen = sizeof(int),
71049 + .mode = 0600,
71050 + .proc_handler = &proc_dointvec,
71051 + },
71052 +#endif
71053 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71054 + {
71055 + .procname = "chroot_deny_mount",
71056 + .data = &grsec_enable_chroot_mount,
71057 + .maxlen = sizeof(int),
71058 + .mode = 0600,
71059 + .proc_handler = &proc_dointvec,
71060 + },
71061 +#endif
71062 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71063 + {
71064 + .procname = "chroot_deny_fchdir",
71065 + .data = &grsec_enable_chroot_fchdir,
71066 + .maxlen = sizeof(int),
71067 + .mode = 0600,
71068 + .proc_handler = &proc_dointvec,
71069 + },
71070 +#endif
71071 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71072 + {
71073 + .procname = "chroot_deny_chroot",
71074 + .data = &grsec_enable_chroot_double,
71075 + .maxlen = sizeof(int),
71076 + .mode = 0600,
71077 + .proc_handler = &proc_dointvec,
71078 + },
71079 +#endif
71080 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71081 + {
71082 + .procname = "chroot_deny_pivot",
71083 + .data = &grsec_enable_chroot_pivot,
71084 + .maxlen = sizeof(int),
71085 + .mode = 0600,
71086 + .proc_handler = &proc_dointvec,
71087 + },
71088 +#endif
71089 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71090 + {
71091 + .procname = "chroot_enforce_chdir",
71092 + .data = &grsec_enable_chroot_chdir,
71093 + .maxlen = sizeof(int),
71094 + .mode = 0600,
71095 + .proc_handler = &proc_dointvec,
71096 + },
71097 +#endif
71098 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71099 + {
71100 + .procname = "chroot_deny_chmod",
71101 + .data = &grsec_enable_chroot_chmod,
71102 + .maxlen = sizeof(int),
71103 + .mode = 0600,
71104 + .proc_handler = &proc_dointvec,
71105 + },
71106 +#endif
71107 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71108 + {
71109 + .procname = "chroot_deny_mknod",
71110 + .data = &grsec_enable_chroot_mknod,
71111 + .maxlen = sizeof(int),
71112 + .mode = 0600,
71113 + .proc_handler = &proc_dointvec,
71114 + },
71115 +#endif
71116 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71117 + {
71118 + .procname = "chroot_restrict_nice",
71119 + .data = &grsec_enable_chroot_nice,
71120 + .maxlen = sizeof(int),
71121 + .mode = 0600,
71122 + .proc_handler = &proc_dointvec,
71123 + },
71124 +#endif
71125 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71126 + {
71127 + .procname = "chroot_execlog",
71128 + .data = &grsec_enable_chroot_execlog,
71129 + .maxlen = sizeof(int),
71130 + .mode = 0600,
71131 + .proc_handler = &proc_dointvec,
71132 + },
71133 +#endif
71134 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71135 + {
71136 + .procname = "chroot_caps",
71137 + .data = &grsec_enable_chroot_caps,
71138 + .maxlen = sizeof(int),
71139 + .mode = 0600,
71140 + .proc_handler = &proc_dointvec,
71141 + },
71142 +#endif
71143 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71144 + {
71145 + .procname = "chroot_deny_sysctl",
71146 + .data = &grsec_enable_chroot_sysctl,
71147 + .maxlen = sizeof(int),
71148 + .mode = 0600,
71149 + .proc_handler = &proc_dointvec,
71150 + },
71151 +#endif
71152 +#ifdef CONFIG_GRKERNSEC_TPE
71153 + {
71154 + .procname = "tpe",
71155 + .data = &grsec_enable_tpe,
71156 + .maxlen = sizeof(int),
71157 + .mode = 0600,
71158 + .proc_handler = &proc_dointvec,
71159 + },
71160 + {
71161 + .procname = "tpe_gid",
71162 + .data = &grsec_tpe_gid,
71163 + .maxlen = sizeof(int),
71164 + .mode = 0600,
71165 + .proc_handler = &proc_dointvec,
71166 + },
71167 +#endif
71168 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71169 + {
71170 + .procname = "tpe_invert",
71171 + .data = &grsec_enable_tpe_invert,
71172 + .maxlen = sizeof(int),
71173 + .mode = 0600,
71174 + .proc_handler = &proc_dointvec,
71175 + },
71176 +#endif
71177 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71178 + {
71179 + .procname = "tpe_restrict_all",
71180 + .data = &grsec_enable_tpe_all,
71181 + .maxlen = sizeof(int),
71182 + .mode = 0600,
71183 + .proc_handler = &proc_dointvec,
71184 + },
71185 +#endif
71186 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71187 + {
71188 + .procname = "socket_all",
71189 + .data = &grsec_enable_socket_all,
71190 + .maxlen = sizeof(int),
71191 + .mode = 0600,
71192 + .proc_handler = &proc_dointvec,
71193 + },
71194 + {
71195 + .procname = "socket_all_gid",
71196 + .data = &grsec_socket_all_gid,
71197 + .maxlen = sizeof(int),
71198 + .mode = 0600,
71199 + .proc_handler = &proc_dointvec,
71200 + },
71201 +#endif
71202 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71203 + {
71204 + .procname = "socket_client",
71205 + .data = &grsec_enable_socket_client,
71206 + .maxlen = sizeof(int),
71207 + .mode = 0600,
71208 + .proc_handler = &proc_dointvec,
71209 + },
71210 + {
71211 + .procname = "socket_client_gid",
71212 + .data = &grsec_socket_client_gid,
71213 + .maxlen = sizeof(int),
71214 + .mode = 0600,
71215 + .proc_handler = &proc_dointvec,
71216 + },
71217 +#endif
71218 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71219 + {
71220 + .procname = "socket_server",
71221 + .data = &grsec_enable_socket_server,
71222 + .maxlen = sizeof(int),
71223 + .mode = 0600,
71224 + .proc_handler = &proc_dointvec,
71225 + },
71226 + {
71227 + .procname = "socket_server_gid",
71228 + .data = &grsec_socket_server_gid,
71229 + .maxlen = sizeof(int),
71230 + .mode = 0600,
71231 + .proc_handler = &proc_dointvec,
71232 + },
71233 +#endif
71234 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71235 + {
71236 + .procname = "audit_group",
71237 + .data = &grsec_enable_group,
71238 + .maxlen = sizeof(int),
71239 + .mode = 0600,
71240 + .proc_handler = &proc_dointvec,
71241 + },
71242 + {
71243 + .procname = "audit_gid",
71244 + .data = &grsec_audit_gid,
71245 + .maxlen = sizeof(int),
71246 + .mode = 0600,
71247 + .proc_handler = &proc_dointvec,
71248 + },
71249 +#endif
71250 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71251 + {
71252 + .procname = "audit_chdir",
71253 + .data = &grsec_enable_chdir,
71254 + .maxlen = sizeof(int),
71255 + .mode = 0600,
71256 + .proc_handler = &proc_dointvec,
71257 + },
71258 +#endif
71259 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71260 + {
71261 + .procname = "audit_mount",
71262 + .data = &grsec_enable_mount,
71263 + .maxlen = sizeof(int),
71264 + .mode = 0600,
71265 + .proc_handler = &proc_dointvec,
71266 + },
71267 +#endif
71268 +#ifdef CONFIG_GRKERNSEC_DMESG
71269 + {
71270 + .procname = "dmesg",
71271 + .data = &grsec_enable_dmesg,
71272 + .maxlen = sizeof(int),
71273 + .mode = 0600,
71274 + .proc_handler = &proc_dointvec,
71275 + },
71276 +#endif
71277 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71278 + {
71279 + .procname = "chroot_findtask",
71280 + .data = &grsec_enable_chroot_findtask,
71281 + .maxlen = sizeof(int),
71282 + .mode = 0600,
71283 + .proc_handler = &proc_dointvec,
71284 + },
71285 +#endif
71286 +#ifdef CONFIG_GRKERNSEC_RESLOG
71287 + {
71288 + .procname = "resource_logging",
71289 + .data = &grsec_resource_logging,
71290 + .maxlen = sizeof(int),
71291 + .mode = 0600,
71292 + .proc_handler = &proc_dointvec,
71293 + },
71294 +#endif
71295 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71296 + {
71297 + .procname = "audit_ptrace",
71298 + .data = &grsec_enable_audit_ptrace,
71299 + .maxlen = sizeof(int),
71300 + .mode = 0600,
71301 + .proc_handler = &proc_dointvec,
71302 + },
71303 +#endif
71304 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71305 + {
71306 + .procname = "harden_ptrace",
71307 + .data = &grsec_enable_harden_ptrace,
71308 + .maxlen = sizeof(int),
71309 + .mode = 0600,
71310 + .proc_handler = &proc_dointvec,
71311 + },
71312 +#endif
71313 + {
71314 + .procname = "grsec_lock",
71315 + .data = &grsec_lock,
71316 + .maxlen = sizeof(int),
71317 + .mode = 0600,
71318 + .proc_handler = &proc_dointvec,
71319 + },
71320 +#endif
71321 +#ifdef CONFIG_GRKERNSEC_ROFS
71322 + {
71323 + .procname = "romount_protect",
71324 + .data = &grsec_enable_rofs,
71325 + .maxlen = sizeof(int),
71326 + .mode = 0600,
71327 + .proc_handler = &proc_dointvec_minmax,
71328 + .extra1 = &one,
71329 + .extra2 = &one,
71330 + },
71331 +#endif
71332 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71333 + {
71334 + .procname = "deny_new_usb",
71335 + .data = &grsec_deny_new_usb,
71336 + .maxlen = sizeof(int),
71337 + .mode = 0600,
71338 + .proc_handler = &proc_dointvec,
71339 + },
71340 +#endif
71341 + { }
71342 +};
71343 +#endif
71344 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71345 new file mode 100644
71346 index 0000000..0dc13c3
71347 --- /dev/null
71348 +++ b/grsecurity/grsec_time.c
71349 @@ -0,0 +1,16 @@
71350 +#include <linux/kernel.h>
71351 +#include <linux/sched.h>
71352 +#include <linux/grinternal.h>
71353 +#include <linux/module.h>
71354 +
71355 +void
71356 +gr_log_timechange(void)
71357 +{
71358 +#ifdef CONFIG_GRKERNSEC_TIME
71359 + if (grsec_enable_time)
71360 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71361 +#endif
71362 + return;
71363 +}
71364 +
71365 +EXPORT_SYMBOL(gr_log_timechange);
71366 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71367 new file mode 100644
71368 index 0000000..ee57dcf
71369 --- /dev/null
71370 +++ b/grsecurity/grsec_tpe.c
71371 @@ -0,0 +1,73 @@
71372 +#include <linux/kernel.h>
71373 +#include <linux/sched.h>
71374 +#include <linux/file.h>
71375 +#include <linux/fs.h>
71376 +#include <linux/grinternal.h>
71377 +
71378 +extern int gr_acl_tpe_check(void);
71379 +
71380 +int
71381 +gr_tpe_allow(const struct file *file)
71382 +{
71383 +#ifdef CONFIG_GRKERNSEC
71384 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71385 + const struct cred *cred = current_cred();
71386 + char *msg = NULL;
71387 + char *msg2 = NULL;
71388 +
71389 + // never restrict root
71390 + if (gr_is_global_root(cred->uid))
71391 + return 1;
71392 +
71393 + if (grsec_enable_tpe) {
71394 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71395 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71396 + msg = "not being in trusted group";
71397 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71398 + msg = "being in untrusted group";
71399 +#else
71400 + if (in_group_p(grsec_tpe_gid))
71401 + msg = "being in untrusted group";
71402 +#endif
71403 + }
71404 + if (!msg && gr_acl_tpe_check())
71405 + msg = "being in untrusted role";
71406 +
71407 + // not in any affected group/role
71408 + if (!msg)
71409 + goto next_check;
71410 +
71411 + if (gr_is_global_nonroot(inode->i_uid))
71412 + msg2 = "file in non-root-owned directory";
71413 + else if (inode->i_mode & S_IWOTH)
71414 + msg2 = "file in world-writable directory";
71415 + else if (inode->i_mode & S_IWGRP)
71416 + msg2 = "file in group-writable directory";
71417 +
71418 + if (msg && msg2) {
71419 + char fullmsg[70] = {0};
71420 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71421 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71422 + return 0;
71423 + }
71424 + msg = NULL;
71425 +next_check:
71426 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71427 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71428 + return 1;
71429 +
71430 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71431 + msg = "directory not owned by user";
71432 + else if (inode->i_mode & S_IWOTH)
71433 + msg = "file in world-writable directory";
71434 + else if (inode->i_mode & S_IWGRP)
71435 + msg = "file in group-writable directory";
71436 +
71437 + if (msg) {
71438 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71439 + return 0;
71440 + }
71441 +#endif
71442 +#endif
71443 + return 1;
71444 +}
71445 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71446 new file mode 100644
71447 index 0000000..ae02d8e
71448 --- /dev/null
71449 +++ b/grsecurity/grsec_usb.c
71450 @@ -0,0 +1,15 @@
71451 +#include <linux/kernel.h>
71452 +#include <linux/grinternal.h>
71453 +#include <linux/module.h>
71454 +
71455 +int gr_handle_new_usb(void)
71456 +{
71457 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71458 + if (grsec_deny_new_usb) {
71459 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71460 + return 1;
71461 + }
71462 +#endif
71463 + return 0;
71464 +}
71465 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71466 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71467 new file mode 100644
71468 index 0000000..9f7b1ac
71469 --- /dev/null
71470 +++ b/grsecurity/grsum.c
71471 @@ -0,0 +1,61 @@
71472 +#include <linux/err.h>
71473 +#include <linux/kernel.h>
71474 +#include <linux/sched.h>
71475 +#include <linux/mm.h>
71476 +#include <linux/scatterlist.h>
71477 +#include <linux/crypto.h>
71478 +#include <linux/gracl.h>
71479 +
71480 +
71481 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71482 +#error "crypto and sha256 must be built into the kernel"
71483 +#endif
71484 +
71485 +int
71486 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71487 +{
71488 + char *p;
71489 + struct crypto_hash *tfm;
71490 + struct hash_desc desc;
71491 + struct scatterlist sg;
71492 + unsigned char temp_sum[GR_SHA_LEN];
71493 + volatile int retval = 0;
71494 + volatile int dummy = 0;
71495 + unsigned int i;
71496 +
71497 + sg_init_table(&sg, 1);
71498 +
71499 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71500 + if (IS_ERR(tfm)) {
71501 + /* should never happen, since sha256 should be built in */
71502 + return 1;
71503 + }
71504 +
71505 + desc.tfm = tfm;
71506 + desc.flags = 0;
71507 +
71508 + crypto_hash_init(&desc);
71509 +
71510 + p = salt;
71511 + sg_set_buf(&sg, p, GR_SALT_LEN);
71512 + crypto_hash_update(&desc, &sg, sg.length);
71513 +
71514 + p = entry->pw;
71515 + sg_set_buf(&sg, p, strlen(p));
71516 +
71517 + crypto_hash_update(&desc, &sg, sg.length);
71518 +
71519 + crypto_hash_final(&desc, temp_sum);
71520 +
71521 + memset(entry->pw, 0, GR_PW_LEN);
71522 +
71523 + for (i = 0; i < GR_SHA_LEN; i++)
71524 + if (sum[i] != temp_sum[i])
71525 + retval = 1;
71526 + else
71527 + dummy = 1; // waste a cycle
71528 +
71529 + crypto_free_hash(tfm);
71530 +
71531 + return retval;
71532 +}
71533 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71534 index 77ff547..181834f 100644
71535 --- a/include/asm-generic/4level-fixup.h
71536 +++ b/include/asm-generic/4level-fixup.h
71537 @@ -13,8 +13,10 @@
71538 #define pmd_alloc(mm, pud, address) \
71539 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71540 NULL: pmd_offset(pud, address))
71541 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71542
71543 #define pud_alloc(mm, pgd, address) (pgd)
71544 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71545 #define pud_offset(pgd, start) (pgd)
71546 #define pud_none(pud) 0
71547 #define pud_bad(pud) 0
71548 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71549 index b7babf0..04ad282 100644
71550 --- a/include/asm-generic/atomic-long.h
71551 +++ b/include/asm-generic/atomic-long.h
71552 @@ -22,6 +22,12 @@
71553
71554 typedef atomic64_t atomic_long_t;
71555
71556 +#ifdef CONFIG_PAX_REFCOUNT
71557 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71558 +#else
71559 +typedef atomic64_t atomic_long_unchecked_t;
71560 +#endif
71561 +
71562 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71563
71564 static inline long atomic_long_read(atomic_long_t *l)
71565 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71566 return (long)atomic64_read(v);
71567 }
71568
71569 +#ifdef CONFIG_PAX_REFCOUNT
71570 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71571 +{
71572 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71573 +
71574 + return (long)atomic64_read_unchecked(v);
71575 +}
71576 +#endif
71577 +
71578 static inline void atomic_long_set(atomic_long_t *l, long i)
71579 {
71580 atomic64_t *v = (atomic64_t *)l;
71581 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71582 atomic64_set(v, i);
71583 }
71584
71585 +#ifdef CONFIG_PAX_REFCOUNT
71586 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71587 +{
71588 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71589 +
71590 + atomic64_set_unchecked(v, i);
71591 +}
71592 +#endif
71593 +
71594 static inline void atomic_long_inc(atomic_long_t *l)
71595 {
71596 atomic64_t *v = (atomic64_t *)l;
71597 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71598 atomic64_inc(v);
71599 }
71600
71601 +#ifdef CONFIG_PAX_REFCOUNT
71602 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71603 +{
71604 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71605 +
71606 + atomic64_inc_unchecked(v);
71607 +}
71608 +#endif
71609 +
71610 static inline void atomic_long_dec(atomic_long_t *l)
71611 {
71612 atomic64_t *v = (atomic64_t *)l;
71613 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71614 atomic64_dec(v);
71615 }
71616
71617 +#ifdef CONFIG_PAX_REFCOUNT
71618 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71619 +{
71620 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71621 +
71622 + atomic64_dec_unchecked(v);
71623 +}
71624 +#endif
71625 +
71626 static inline void atomic_long_add(long i, atomic_long_t *l)
71627 {
71628 atomic64_t *v = (atomic64_t *)l;
71629 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71630 atomic64_add(i, v);
71631 }
71632
71633 +#ifdef CONFIG_PAX_REFCOUNT
71634 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71635 +{
71636 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71637 +
71638 + atomic64_add_unchecked(i, v);
71639 +}
71640 +#endif
71641 +
71642 static inline void atomic_long_sub(long i, atomic_long_t *l)
71643 {
71644 atomic64_t *v = (atomic64_t *)l;
71645 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71646 atomic64_sub(i, v);
71647 }
71648
71649 +#ifdef CONFIG_PAX_REFCOUNT
71650 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71651 +{
71652 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71653 +
71654 + atomic64_sub_unchecked(i, v);
71655 +}
71656 +#endif
71657 +
71658 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71659 {
71660 atomic64_t *v = (atomic64_t *)l;
71661 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71662 return (long)atomic64_add_return(i, v);
71663 }
71664
71665 +#ifdef CONFIG_PAX_REFCOUNT
71666 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71667 +{
71668 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71669 +
71670 + return (long)atomic64_add_return_unchecked(i, v);
71671 +}
71672 +#endif
71673 +
71674 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71675 {
71676 atomic64_t *v = (atomic64_t *)l;
71677 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71678 return (long)atomic64_inc_return(v);
71679 }
71680
71681 +#ifdef CONFIG_PAX_REFCOUNT
71682 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71683 +{
71684 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71685 +
71686 + return (long)atomic64_inc_return_unchecked(v);
71687 +}
71688 +#endif
71689 +
71690 static inline long atomic_long_dec_return(atomic_long_t *l)
71691 {
71692 atomic64_t *v = (atomic64_t *)l;
71693 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71694
71695 typedef atomic_t atomic_long_t;
71696
71697 +#ifdef CONFIG_PAX_REFCOUNT
71698 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71699 +#else
71700 +typedef atomic_t atomic_long_unchecked_t;
71701 +#endif
71702 +
71703 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71704 static inline long atomic_long_read(atomic_long_t *l)
71705 {
71706 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71707 return (long)atomic_read(v);
71708 }
71709
71710 +#ifdef CONFIG_PAX_REFCOUNT
71711 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71712 +{
71713 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71714 +
71715 + return (long)atomic_read_unchecked(v);
71716 +}
71717 +#endif
71718 +
71719 static inline void atomic_long_set(atomic_long_t *l, long i)
71720 {
71721 atomic_t *v = (atomic_t *)l;
71722 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71723 atomic_set(v, i);
71724 }
71725
71726 +#ifdef CONFIG_PAX_REFCOUNT
71727 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71728 +{
71729 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71730 +
71731 + atomic_set_unchecked(v, i);
71732 +}
71733 +#endif
71734 +
71735 static inline void atomic_long_inc(atomic_long_t *l)
71736 {
71737 atomic_t *v = (atomic_t *)l;
71738 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71739 atomic_inc(v);
71740 }
71741
71742 +#ifdef CONFIG_PAX_REFCOUNT
71743 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71744 +{
71745 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71746 +
71747 + atomic_inc_unchecked(v);
71748 +}
71749 +#endif
71750 +
71751 static inline void atomic_long_dec(atomic_long_t *l)
71752 {
71753 atomic_t *v = (atomic_t *)l;
71754 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71755 atomic_dec(v);
71756 }
71757
71758 +#ifdef CONFIG_PAX_REFCOUNT
71759 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71760 +{
71761 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71762 +
71763 + atomic_dec_unchecked(v);
71764 +}
71765 +#endif
71766 +
71767 static inline void atomic_long_add(long i, atomic_long_t *l)
71768 {
71769 atomic_t *v = (atomic_t *)l;
71770 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71771 atomic_add(i, v);
71772 }
71773
71774 +#ifdef CONFIG_PAX_REFCOUNT
71775 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71776 +{
71777 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71778 +
71779 + atomic_add_unchecked(i, v);
71780 +}
71781 +#endif
71782 +
71783 static inline void atomic_long_sub(long i, atomic_long_t *l)
71784 {
71785 atomic_t *v = (atomic_t *)l;
71786 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71787 atomic_sub(i, v);
71788 }
71789
71790 +#ifdef CONFIG_PAX_REFCOUNT
71791 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71792 +{
71793 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71794 +
71795 + atomic_sub_unchecked(i, v);
71796 +}
71797 +#endif
71798 +
71799 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71800 {
71801 atomic_t *v = (atomic_t *)l;
71802 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71803 return (long)atomic_add_return(i, v);
71804 }
71805
71806 +#ifdef CONFIG_PAX_REFCOUNT
71807 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71808 +{
71809 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71810 +
71811 + return (long)atomic_add_return_unchecked(i, v);
71812 +}
71813 +
71814 +#endif
71815 +
71816 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71817 {
71818 atomic_t *v = (atomic_t *)l;
71819 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71820 return (long)atomic_inc_return(v);
71821 }
71822
71823 +#ifdef CONFIG_PAX_REFCOUNT
71824 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71825 +{
71826 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71827 +
71828 + return (long)atomic_inc_return_unchecked(v);
71829 +}
71830 +#endif
71831 +
71832 static inline long atomic_long_dec_return(atomic_long_t *l)
71833 {
71834 atomic_t *v = (atomic_t *)l;
71835 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71836
71837 #endif /* BITS_PER_LONG == 64 */
71838
71839 +#ifdef CONFIG_PAX_REFCOUNT
71840 +static inline void pax_refcount_needs_these_functions(void)
71841 +{
71842 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71843 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71844 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71845 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71846 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71847 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71848 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71849 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71850 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71851 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71852 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71853 +#ifdef CONFIG_X86
71854 + atomic_clear_mask_unchecked(0, NULL);
71855 + atomic_set_mask_unchecked(0, NULL);
71856 +#endif
71857 +
71858 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71859 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71860 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71861 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
71862 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
71863 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
71864 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
71865 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
71866 +}
71867 +#else
71868 +#define atomic_read_unchecked(v) atomic_read(v)
71869 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
71870 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
71871 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
71872 +#define atomic_inc_unchecked(v) atomic_inc(v)
71873 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
71874 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
71875 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
71876 +#define atomic_dec_unchecked(v) atomic_dec(v)
71877 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
71878 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
71879 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
71880 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
71881 +
71882 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
71883 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
71884 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
71885 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
71886 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
71887 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
71888 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
71889 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
71890 +#endif
71891 +
71892 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
71893 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
71894 index 33bd2de..f31bff97 100644
71895 --- a/include/asm-generic/atomic.h
71896 +++ b/include/asm-generic/atomic.h
71897 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
71898 * Atomically clears the bits set in @mask from @v
71899 */
71900 #ifndef atomic_clear_mask
71901 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
71902 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
71903 {
71904 unsigned long flags;
71905
71906 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
71907 index b18ce4f..2ee2843 100644
71908 --- a/include/asm-generic/atomic64.h
71909 +++ b/include/asm-generic/atomic64.h
71910 @@ -16,6 +16,8 @@ typedef struct {
71911 long long counter;
71912 } atomic64_t;
71913
71914 +typedef atomic64_t atomic64_unchecked_t;
71915 +
71916 #define ATOMIC64_INIT(i) { (i) }
71917
71918 extern long long atomic64_read(const atomic64_t *v);
71919 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
71920 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
71921 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
71922
71923 +#define atomic64_read_unchecked(v) atomic64_read(v)
71924 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
71925 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
71926 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
71927 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
71928 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
71929 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
71930 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
71931 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
71932 +
71933 #endif /* _ASM_GENERIC_ATOMIC64_H */
71934 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
71935 index 1bfcfe5..e04c5c9 100644
71936 --- a/include/asm-generic/cache.h
71937 +++ b/include/asm-generic/cache.h
71938 @@ -6,7 +6,7 @@
71939 * cache lines need to provide their own cache.h.
71940 */
71941
71942 -#define L1_CACHE_SHIFT 5
71943 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
71944 +#define L1_CACHE_SHIFT 5UL
71945 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
71946
71947 #endif /* __ASM_GENERIC_CACHE_H */
71948 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
71949 index 0d68a1e..b74a761 100644
71950 --- a/include/asm-generic/emergency-restart.h
71951 +++ b/include/asm-generic/emergency-restart.h
71952 @@ -1,7 +1,7 @@
71953 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
71954 #define _ASM_GENERIC_EMERGENCY_RESTART_H
71955
71956 -static inline void machine_emergency_restart(void)
71957 +static inline __noreturn void machine_emergency_restart(void)
71958 {
71959 machine_restart(NULL);
71960 }
71961 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
71962 index 90f99c7..00ce236 100644
71963 --- a/include/asm-generic/kmap_types.h
71964 +++ b/include/asm-generic/kmap_types.h
71965 @@ -2,9 +2,9 @@
71966 #define _ASM_GENERIC_KMAP_TYPES_H
71967
71968 #ifdef __WITH_KM_FENCE
71969 -# define KM_TYPE_NR 41
71970 +# define KM_TYPE_NR 42
71971 #else
71972 -# define KM_TYPE_NR 20
71973 +# define KM_TYPE_NR 21
71974 #endif
71975
71976 #endif
71977 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
71978 index 9ceb03b..62b0b8f 100644
71979 --- a/include/asm-generic/local.h
71980 +++ b/include/asm-generic/local.h
71981 @@ -23,24 +23,37 @@ typedef struct
71982 atomic_long_t a;
71983 } local_t;
71984
71985 +typedef struct {
71986 + atomic_long_unchecked_t a;
71987 +} local_unchecked_t;
71988 +
71989 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
71990
71991 #define local_read(l) atomic_long_read(&(l)->a)
71992 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
71993 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
71994 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
71995 #define local_inc(l) atomic_long_inc(&(l)->a)
71996 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
71997 #define local_dec(l) atomic_long_dec(&(l)->a)
71998 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
71999 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72000 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72001 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72002 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72003
72004 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72005 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72006 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72007 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72008 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72009 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72010 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72011 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72012 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72013
72014 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72015 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72016 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72017 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72018 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72019 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72020 index 725612b..9cc513a 100644
72021 --- a/include/asm-generic/pgtable-nopmd.h
72022 +++ b/include/asm-generic/pgtable-nopmd.h
72023 @@ -1,14 +1,19 @@
72024 #ifndef _PGTABLE_NOPMD_H
72025 #define _PGTABLE_NOPMD_H
72026
72027 -#ifndef __ASSEMBLY__
72028 -
72029 #include <asm-generic/pgtable-nopud.h>
72030
72031 -struct mm_struct;
72032 -
72033 #define __PAGETABLE_PMD_FOLDED
72034
72035 +#define PMD_SHIFT PUD_SHIFT
72036 +#define PTRS_PER_PMD 1
72037 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72038 +#define PMD_MASK (~(PMD_SIZE-1))
72039 +
72040 +#ifndef __ASSEMBLY__
72041 +
72042 +struct mm_struct;
72043 +
72044 /*
72045 * Having the pmd type consist of a pud gets the size right, and allows
72046 * us to conceptually access the pud entry that this pmd is folded into
72047 @@ -16,11 +21,6 @@ struct mm_struct;
72048 */
72049 typedef struct { pud_t pud; } pmd_t;
72050
72051 -#define PMD_SHIFT PUD_SHIFT
72052 -#define PTRS_PER_PMD 1
72053 -#define PMD_SIZE (1UL << PMD_SHIFT)
72054 -#define PMD_MASK (~(PMD_SIZE-1))
72055 -
72056 /*
72057 * The "pud_xxx()" functions here are trivial for a folded two-level
72058 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72059 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72060 index 810431d..0ec4804f 100644
72061 --- a/include/asm-generic/pgtable-nopud.h
72062 +++ b/include/asm-generic/pgtable-nopud.h
72063 @@ -1,10 +1,15 @@
72064 #ifndef _PGTABLE_NOPUD_H
72065 #define _PGTABLE_NOPUD_H
72066
72067 -#ifndef __ASSEMBLY__
72068 -
72069 #define __PAGETABLE_PUD_FOLDED
72070
72071 +#define PUD_SHIFT PGDIR_SHIFT
72072 +#define PTRS_PER_PUD 1
72073 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72074 +#define PUD_MASK (~(PUD_SIZE-1))
72075 +
72076 +#ifndef __ASSEMBLY__
72077 +
72078 /*
72079 * Having the pud type consist of a pgd gets the size right, and allows
72080 * us to conceptually access the pgd entry that this pud is folded into
72081 @@ -12,11 +17,6 @@
72082 */
72083 typedef struct { pgd_t pgd; } pud_t;
72084
72085 -#define PUD_SHIFT PGDIR_SHIFT
72086 -#define PTRS_PER_PUD 1
72087 -#define PUD_SIZE (1UL << PUD_SHIFT)
72088 -#define PUD_MASK (~(PUD_SIZE-1))
72089 -
72090 /*
72091 * The "pgd_xxx()" functions here are trivial for a folded two-level
72092 * setup: the pud is never bad, and a pud always exists (as it's folded
72093 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72094 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72095
72096 #define pgd_populate(mm, pgd, pud) do { } while (0)
72097 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72098 /*
72099 * (puds are folded into pgds so this doesn't get actually called,
72100 * but the define is needed for a generic inline function.)
72101 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72102 index 0807ddf..cd67747 100644
72103 --- a/include/asm-generic/pgtable.h
72104 +++ b/include/asm-generic/pgtable.h
72105 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72106 }
72107 #endif /* CONFIG_NUMA_BALANCING */
72108
72109 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72110 +#ifdef CONFIG_PAX_KERNEXEC
72111 +#error KERNEXEC requires pax_open_kernel
72112 +#else
72113 +static inline unsigned long pax_open_kernel(void) { return 0; }
72114 +#endif
72115 +#endif
72116 +
72117 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72118 +#ifdef CONFIG_PAX_KERNEXEC
72119 +#error KERNEXEC requires pax_close_kernel
72120 +#else
72121 +static inline unsigned long pax_close_kernel(void) { return 0; }
72122 +#endif
72123 +#endif
72124 +
72125 #endif /* CONFIG_MMU */
72126
72127 #endif /* !__ASSEMBLY__ */
72128 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72129 index dc1269c..48a4f51 100644
72130 --- a/include/asm-generic/uaccess.h
72131 +++ b/include/asm-generic/uaccess.h
72132 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72133 return __clear_user(to, n);
72134 }
72135
72136 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72137 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72138 +#error UDEREF requires pax_open_userland
72139 +#else
72140 +static inline unsigned long pax_open_userland(void) { return 0; }
72141 +#endif
72142 +#endif
72143 +
72144 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72145 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72146 +#error UDEREF requires pax_close_userland
72147 +#else
72148 +static inline unsigned long pax_close_userland(void) { return 0; }
72149 +#endif
72150 +#endif
72151 +
72152 #endif /* __ASM_GENERIC_UACCESS_H */
72153 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72154 index 69732d2..cbe16d9 100644
72155 --- a/include/asm-generic/vmlinux.lds.h
72156 +++ b/include/asm-generic/vmlinux.lds.h
72157 @@ -227,6 +227,7 @@
72158 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72159 VMLINUX_SYMBOL(__start_rodata) = .; \
72160 *(.rodata) *(.rodata.*) \
72161 + *(.data..read_only) \
72162 *(__vermagic) /* Kernel version magic */ \
72163 . = ALIGN(8); \
72164 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72165 @@ -710,17 +711,18 @@
72166 * section in the linker script will go there too. @phdr should have
72167 * a leading colon.
72168 *
72169 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72170 + * Note that this macros defines per_cpu_load as an absolute symbol.
72171 * If there is no need to put the percpu section at a predetermined
72172 * address, use PERCPU_SECTION.
72173 */
72174 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72175 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
72176 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
72177 + per_cpu_load = .; \
72178 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
72179 - LOAD_OFFSET) { \
72180 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
72181 PERCPU_INPUT(cacheline) \
72182 } phdr \
72183 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
72184 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72185
72186 /**
72187 * PERCPU_SECTION - define output section for percpu area, simple version
72188 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72189 index 418d270..bfd2794 100644
72190 --- a/include/crypto/algapi.h
72191 +++ b/include/crypto/algapi.h
72192 @@ -34,7 +34,7 @@ struct crypto_type {
72193 unsigned int maskclear;
72194 unsigned int maskset;
72195 unsigned int tfmsize;
72196 -};
72197 +} __do_const;
72198
72199 struct crypto_instance {
72200 struct crypto_alg alg;
72201 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72202 index 12083dc..39740ec 100644
72203 --- a/include/drm/drmP.h
72204 +++ b/include/drm/drmP.h
72205 @@ -69,6 +69,7 @@
72206 #include <linux/workqueue.h>
72207 #include <linux/poll.h>
72208 #include <asm/pgalloc.h>
72209 +#include <asm/local.h>
72210 #include <drm/drm.h>
72211 #include <drm/drm_sarea.h>
72212
72213 @@ -293,10 +294,12 @@ do { \
72214 * \param cmd command.
72215 * \param arg argument.
72216 */
72217 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72218 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72219 + struct drm_file *file_priv);
72220 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72221 struct drm_file *file_priv);
72222
72223 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72224 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72225 unsigned long arg);
72226
72227 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72228 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72229 struct drm_ioctl_desc {
72230 unsigned int cmd;
72231 int flags;
72232 - drm_ioctl_t *func;
72233 + drm_ioctl_t func;
72234 unsigned int cmd_drv;
72235 const char *name;
72236 -};
72237 +} __do_const;
72238
72239 /**
72240 * Creates a driver or general drm_ioctl_desc array entry for the given
72241 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72242 int (*show)(struct seq_file*, void*); /** show callback */
72243 u32 driver_features; /**< Required driver features for this entry */
72244 void *data;
72245 -};
72246 +} __do_const;
72247
72248 /**
72249 * debugfs node structure. This structure represents a debugfs file.
72250 @@ -1088,7 +1091,7 @@ struct drm_device {
72251
72252 /** \name Usage Counters */
72253 /*@{ */
72254 - int open_count; /**< Outstanding files open */
72255 + local_t open_count; /**< Outstanding files open */
72256 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72257 atomic_t vma_count; /**< Outstanding vma areas open */
72258 int buf_use; /**< Buffers in use -- cannot alloc */
72259 @@ -1099,7 +1102,7 @@ struct drm_device {
72260 /*@{ */
72261 unsigned long counters;
72262 enum drm_stat_type types[15];
72263 - atomic_t counts[15];
72264 + atomic_unchecked_t counts[15];
72265 /*@} */
72266
72267 struct list_head filelist;
72268 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72269 index f43d556..94d9343 100644
72270 --- a/include/drm/drm_crtc_helper.h
72271 +++ b/include/drm/drm_crtc_helper.h
72272 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72273 struct drm_connector *connector);
72274 /* disable encoder when not in use - more explicit than dpms off */
72275 void (*disable)(struct drm_encoder *encoder);
72276 -};
72277 +} __no_const;
72278
72279 /**
72280 * drm_connector_helper_funcs - helper operations for connectors
72281 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72282 index 72dcbe8..8db58d7 100644
72283 --- a/include/drm/ttm/ttm_memory.h
72284 +++ b/include/drm/ttm/ttm_memory.h
72285 @@ -48,7 +48,7 @@
72286
72287 struct ttm_mem_shrink {
72288 int (*do_shrink) (struct ttm_mem_shrink *);
72289 -};
72290 +} __no_const;
72291
72292 /**
72293 * struct ttm_mem_global - Global memory accounting structure.
72294 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72295 index 4b840e8..155d235 100644
72296 --- a/include/keys/asymmetric-subtype.h
72297 +++ b/include/keys/asymmetric-subtype.h
72298 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72299 /* Verify the signature on a key of this subtype (optional) */
72300 int (*verify_signature)(const struct key *key,
72301 const struct public_key_signature *sig);
72302 -};
72303 +} __do_const;
72304
72305 /**
72306 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72307 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72308 index c1da539..1dcec55 100644
72309 --- a/include/linux/atmdev.h
72310 +++ b/include/linux/atmdev.h
72311 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72312 #endif
72313
72314 struct k_atm_aal_stats {
72315 -#define __HANDLE_ITEM(i) atomic_t i
72316 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72317 __AAL_STAT_ITEMS
72318 #undef __HANDLE_ITEM
72319 };
72320 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72321 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72322 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72323 struct module *owner;
72324 -};
72325 +} __do_const ;
72326
72327 struct atmphy_ops {
72328 int (*start)(struct atm_dev *dev);
72329 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72330 index 70cf138..0418ee2 100644
72331 --- a/include/linux/binfmts.h
72332 +++ b/include/linux/binfmts.h
72333 @@ -73,8 +73,10 @@ struct linux_binfmt {
72334 int (*load_binary)(struct linux_binprm *);
72335 int (*load_shlib)(struct file *);
72336 int (*core_dump)(struct coredump_params *cprm);
72337 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72338 + void (*handle_mmap)(struct file *);
72339 unsigned long min_coredump; /* minimal dump size */
72340 -};
72341 +} __do_const;
72342
72343 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72344
72345 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72346 index 2fdb4a4..54aad7e 100644
72347 --- a/include/linux/blkdev.h
72348 +++ b/include/linux/blkdev.h
72349 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72350 /* this callback is with swap_lock and sometimes page table lock held */
72351 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72352 struct module *owner;
72353 -};
72354 +} __do_const;
72355
72356 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72357 unsigned long);
72358 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72359 index 7c2e030..b72475d 100644
72360 --- a/include/linux/blktrace_api.h
72361 +++ b/include/linux/blktrace_api.h
72362 @@ -23,7 +23,7 @@ struct blk_trace {
72363 struct dentry *dir;
72364 struct dentry *dropped_file;
72365 struct dentry *msg_file;
72366 - atomic_t dropped;
72367 + atomic_unchecked_t dropped;
72368 };
72369
72370 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72371 diff --git a/include/linux/cache.h b/include/linux/cache.h
72372 index 4c57065..4307975 100644
72373 --- a/include/linux/cache.h
72374 +++ b/include/linux/cache.h
72375 @@ -16,6 +16,10 @@
72376 #define __read_mostly
72377 #endif
72378
72379 +#ifndef __read_only
72380 +#define __read_only __read_mostly
72381 +#endif
72382 +
72383 #ifndef ____cacheline_aligned
72384 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72385 #endif
72386 diff --git a/include/linux/capability.h b/include/linux/capability.h
72387 index d9a4f7f4..19f77d6 100644
72388 --- a/include/linux/capability.h
72389 +++ b/include/linux/capability.h
72390 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72391 extern bool nsown_capable(int cap);
72392 extern bool inode_capable(const struct inode *inode, int cap);
72393 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72394 +extern bool capable_nolog(int cap);
72395 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72396 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72397
72398 /* audit system wants to get cap info from files as well */
72399 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72400
72401 +extern int is_privileged_binary(const struct dentry *dentry);
72402 +
72403 #endif /* !_LINUX_CAPABILITY_H */
72404 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72405 index 8609d57..86e4d79 100644
72406 --- a/include/linux/cdrom.h
72407 +++ b/include/linux/cdrom.h
72408 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72409
72410 /* driver specifications */
72411 const int capability; /* capability flags */
72412 - int n_minors; /* number of active minor devices */
72413 /* handle uniform packets for scsi type devices (scsi,atapi) */
72414 int (*generic_packet) (struct cdrom_device_info *,
72415 struct packet_command *);
72416 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72417 index 4ce9056..86caac6 100644
72418 --- a/include/linux/cleancache.h
72419 +++ b/include/linux/cleancache.h
72420 @@ -31,7 +31,7 @@ struct cleancache_ops {
72421 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72422 void (*invalidate_inode)(int, struct cleancache_filekey);
72423 void (*invalidate_fs)(int);
72424 -};
72425 +} __no_const;
72426
72427 extern struct cleancache_ops *
72428 cleancache_register_ops(struct cleancache_ops *ops);
72429 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72430 index 1ec14a7..d0654a2 100644
72431 --- a/include/linux/clk-provider.h
72432 +++ b/include/linux/clk-provider.h
72433 @@ -132,6 +132,7 @@ struct clk_ops {
72434 unsigned long);
72435 void (*init)(struct clk_hw *hw);
72436 };
72437 +typedef struct clk_ops __no_const clk_ops_no_const;
72438
72439 /**
72440 * struct clk_init_data - holds init data that's common to all clocks and is
72441 diff --git a/include/linux/compat.h b/include/linux/compat.h
72442 index 7f0c1dd..206ac34 100644
72443 --- a/include/linux/compat.h
72444 +++ b/include/linux/compat.h
72445 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72446 compat_size_t __user *len_ptr);
72447
72448 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72449 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72450 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72451 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72452 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72453 compat_ssize_t msgsz, int msgflg);
72454 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72455 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72456 compat_ulong_t addr, compat_ulong_t data);
72457 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72458 - compat_long_t addr, compat_long_t data);
72459 + compat_ulong_t addr, compat_ulong_t data);
72460
72461 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72462 /*
72463 @@ -669,6 +669,7 @@ asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
72464
72465 int compat_restore_altstack(const compat_stack_t __user *uss);
72466 int __compat_save_altstack(compat_stack_t __user *, unsigned long);
72467 +void __compat_save_altstack_ex(compat_stack_t __user *, unsigned long);
72468
72469 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
72470 struct compat_timespec __user *interval);
72471 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72472 index 842de22..7f3a41f 100644
72473 --- a/include/linux/compiler-gcc4.h
72474 +++ b/include/linux/compiler-gcc4.h
72475 @@ -39,9 +39,29 @@
72476 # define __compiletime_warning(message) __attribute__((warning(message)))
72477 # define __compiletime_error(message) __attribute__((error(message)))
72478 #endif /* __CHECKER__ */
72479 +
72480 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72481 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72482 +#define __bos0(ptr) __bos((ptr), 0)
72483 +#define __bos1(ptr) __bos((ptr), 1)
72484 #endif /* GCC_VERSION >= 40300 */
72485
72486 #if GCC_VERSION >= 40500
72487 +
72488 +#ifdef CONSTIFY_PLUGIN
72489 +#define __no_const __attribute__((no_const))
72490 +#define __do_const __attribute__((do_const))
72491 +#endif
72492 +
72493 +#ifdef SIZE_OVERFLOW_PLUGIN
72494 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72495 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72496 +#endif
72497 +
72498 +#ifdef LATENT_ENTROPY_PLUGIN
72499 +#define __latent_entropy __attribute__((latent_entropy))
72500 +#endif
72501 +
72502 /*
72503 * Mark a position in code as unreachable. This can be used to
72504 * suppress control flow warnings after asm blocks that transfer
72505 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72506 index 92669cd..1771a15 100644
72507 --- a/include/linux/compiler.h
72508 +++ b/include/linux/compiler.h
72509 @@ -5,11 +5,14 @@
72510
72511 #ifdef __CHECKER__
72512 # define __user __attribute__((noderef, address_space(1)))
72513 +# define __force_user __force __user
72514 # define __kernel __attribute__((address_space(0)))
72515 +# define __force_kernel __force __kernel
72516 # define __safe __attribute__((safe))
72517 # define __force __attribute__((force))
72518 # define __nocast __attribute__((nocast))
72519 # define __iomem __attribute__((noderef, address_space(2)))
72520 +# define __force_iomem __force __iomem
72521 # define __must_hold(x) __attribute__((context(x,1,1)))
72522 # define __acquires(x) __attribute__((context(x,0,1)))
72523 # define __releases(x) __attribute__((context(x,1,0)))
72524 @@ -17,20 +20,37 @@
72525 # define __release(x) __context__(x,-1)
72526 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72527 # define __percpu __attribute__((noderef, address_space(3)))
72528 +# define __force_percpu __force __percpu
72529 #ifdef CONFIG_SPARSE_RCU_POINTER
72530 # define __rcu __attribute__((noderef, address_space(4)))
72531 +# define __force_rcu __force __rcu
72532 #else
72533 # define __rcu
72534 +# define __force_rcu
72535 #endif
72536 extern void __chk_user_ptr(const volatile void __user *);
72537 extern void __chk_io_ptr(const volatile void __iomem *);
72538 #else
72539 -# define __user
72540 -# define __kernel
72541 +# ifdef CHECKER_PLUGIN
72542 +//# define __user
72543 +//# define __force_user
72544 +//# define __kernel
72545 +//# define __force_kernel
72546 +# else
72547 +# ifdef STRUCTLEAK_PLUGIN
72548 +# define __user __attribute__((user))
72549 +# else
72550 +# define __user
72551 +# endif
72552 +# define __force_user
72553 +# define __kernel
72554 +# define __force_kernel
72555 +# endif
72556 # define __safe
72557 # define __force
72558 # define __nocast
72559 # define __iomem
72560 +# define __force_iomem
72561 # define __chk_user_ptr(x) (void)0
72562 # define __chk_io_ptr(x) (void)0
72563 # define __builtin_warning(x, y...) (1)
72564 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72565 # define __release(x) (void)0
72566 # define __cond_lock(x,c) (c)
72567 # define __percpu
72568 +# define __force_percpu
72569 # define __rcu
72570 +# define __force_rcu
72571 #endif
72572
72573 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72574 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72575 # define __attribute_const__ /* unimplemented */
72576 #endif
72577
72578 +#ifndef __no_const
72579 +# define __no_const
72580 +#endif
72581 +
72582 +#ifndef __do_const
72583 +# define __do_const
72584 +#endif
72585 +
72586 +#ifndef __size_overflow
72587 +# define __size_overflow(...)
72588 +#endif
72589 +
72590 +#ifndef __intentional_overflow
72591 +# define __intentional_overflow(...)
72592 +#endif
72593 +
72594 +#ifndef __latent_entropy
72595 +# define __latent_entropy
72596 +#endif
72597 +
72598 /*
72599 * Tell gcc if a function is cold. The compiler will assume any path
72600 * directly leading to the call is unlikely.
72601 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72602 #define __cold
72603 #endif
72604
72605 +#ifndef __alloc_size
72606 +#define __alloc_size(...)
72607 +#endif
72608 +
72609 +#ifndef __bos
72610 +#define __bos(ptr, arg)
72611 +#endif
72612 +
72613 +#ifndef __bos0
72614 +#define __bos0(ptr)
72615 +#endif
72616 +
72617 +#ifndef __bos1
72618 +#define __bos1(ptr)
72619 +#endif
72620 +
72621 /* Simple shorthand for a section definition */
72622 #ifndef __section
72623 # define __section(S) __attribute__ ((__section__(#S)))
72624 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72625 * use is to mediate communication between process-level code and irq/NMI
72626 * handlers, all running on the same CPU.
72627 */
72628 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72629 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72630 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72631
72632 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72633 #ifdef CONFIG_KPROBES
72634 diff --git a/include/linux/completion.h b/include/linux/completion.h
72635 index 3cd574d..adce5fa 100644
72636 --- a/include/linux/completion.h
72637 +++ b/include/linux/completion.h
72638 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72639 extern void wait_for_completion(struct completion *);
72640 extern void wait_for_completion_io(struct completion *);
72641 extern int wait_for_completion_interruptible(struct completion *x);
72642 -extern int wait_for_completion_killable(struct completion *x);
72643 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72644 extern unsigned long wait_for_completion_timeout(struct completion *x,
72645 unsigned long timeout);
72646 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72647 unsigned long timeout);
72648 extern long wait_for_completion_interruptible_timeout(
72649 - struct completion *x, unsigned long timeout);
72650 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72651 extern long wait_for_completion_killable_timeout(
72652 - struct completion *x, unsigned long timeout);
72653 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72654 extern bool try_wait_for_completion(struct completion *x);
72655 extern bool completion_done(struct completion *x);
72656
72657 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72658 index 34025df..d94bbbc 100644
72659 --- a/include/linux/configfs.h
72660 +++ b/include/linux/configfs.h
72661 @@ -125,7 +125,7 @@ struct configfs_attribute {
72662 const char *ca_name;
72663 struct module *ca_owner;
72664 umode_t ca_mode;
72665 -};
72666 +} __do_const;
72667
72668 /*
72669 * Users often need to create attribute structures for their configurable
72670 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72671 index 90d5a15..950cb80 100644
72672 --- a/include/linux/cpufreq.h
72673 +++ b/include/linux/cpufreq.h
72674 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72675 int (*suspend) (struct cpufreq_policy *policy);
72676 int (*resume) (struct cpufreq_policy *policy);
72677 struct freq_attr **attr;
72678 -};
72679 +} __do_const;
72680
72681 /* flags */
72682
72683 @@ -325,6 +325,7 @@ struct global_attr {
72684 ssize_t (*store)(struct kobject *a, struct attribute *b,
72685 const char *c, size_t count);
72686 };
72687 +typedef struct global_attr __no_const global_attr_no_const;
72688
72689 #define define_one_global_ro(_name) \
72690 static struct global_attr _name = \
72691 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72692 index 0bc4b74..973b368 100644
72693 --- a/include/linux/cpuidle.h
72694 +++ b/include/linux/cpuidle.h
72695 @@ -52,7 +52,8 @@ struct cpuidle_state {
72696 int index);
72697
72698 int (*enter_dead) (struct cpuidle_device *dev, int index);
72699 -};
72700 +} __do_const;
72701 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72702
72703 /* Idle State Flags */
72704 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72705 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72706 void (*reflect) (struct cpuidle_device *dev, int index);
72707
72708 struct module *owner;
72709 -};
72710 +} __do_const;
72711
72712 #ifdef CONFIG_CPU_IDLE
72713
72714 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72715 index d08e4d2..95fad61 100644
72716 --- a/include/linux/cpumask.h
72717 +++ b/include/linux/cpumask.h
72718 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72719 }
72720
72721 /* Valid inputs for n are -1 and 0. */
72722 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72723 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72724 {
72725 return n+1;
72726 }
72727
72728 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72729 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72730 {
72731 return n+1;
72732 }
72733
72734 -static inline unsigned int cpumask_next_and(int n,
72735 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72736 const struct cpumask *srcp,
72737 const struct cpumask *andp)
72738 {
72739 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72740 *
72741 * Returns >= nr_cpu_ids if no further cpus set.
72742 */
72743 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72744 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72745 {
72746 /* -1 is a legal arg here. */
72747 if (n != -1)
72748 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72749 *
72750 * Returns >= nr_cpu_ids if no further cpus unset.
72751 */
72752 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72753 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72754 {
72755 /* -1 is a legal arg here. */
72756 if (n != -1)
72757 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72758 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72759 }
72760
72761 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72762 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72763 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72764
72765 /**
72766 diff --git a/include/linux/cred.h b/include/linux/cred.h
72767 index 04421e8..6bce4ef 100644
72768 --- a/include/linux/cred.h
72769 +++ b/include/linux/cred.h
72770 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72771 static inline void validate_process_creds(void)
72772 {
72773 }
72774 +static inline void validate_task_creds(struct task_struct *task)
72775 +{
72776 +}
72777 #endif
72778
72779 /**
72780 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72781 index b92eadf..b4ecdc1 100644
72782 --- a/include/linux/crypto.h
72783 +++ b/include/linux/crypto.h
72784 @@ -373,7 +373,7 @@ struct cipher_tfm {
72785 const u8 *key, unsigned int keylen);
72786 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72787 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72788 -};
72789 +} __no_const;
72790
72791 struct hash_tfm {
72792 int (*init)(struct hash_desc *desc);
72793 @@ -394,13 +394,13 @@ struct compress_tfm {
72794 int (*cot_decompress)(struct crypto_tfm *tfm,
72795 const u8 *src, unsigned int slen,
72796 u8 *dst, unsigned int *dlen);
72797 -};
72798 +} __no_const;
72799
72800 struct rng_tfm {
72801 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72802 unsigned int dlen);
72803 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72804 -};
72805 +} __no_const;
72806
72807 #define crt_ablkcipher crt_u.ablkcipher
72808 #define crt_aead crt_u.aead
72809 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72810 index 653589e..4ef254a 100644
72811 --- a/include/linux/ctype.h
72812 +++ b/include/linux/ctype.h
72813 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72814 * Fast implementation of tolower() for internal usage. Do not use in your
72815 * code.
72816 */
72817 -static inline char _tolower(const char c)
72818 +static inline unsigned char _tolower(const unsigned char c)
72819 {
72820 return c | 0x20;
72821 }
72822 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72823 index 7925bf0..d5143d2 100644
72824 --- a/include/linux/decompress/mm.h
72825 +++ b/include/linux/decompress/mm.h
72826 @@ -77,7 +77,7 @@ static void free(void *where)
72827 * warnings when not needed (indeed large_malloc / large_free are not
72828 * needed by inflate */
72829
72830 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72831 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72832 #define free(a) kfree(a)
72833
72834 #define large_malloc(a) vmalloc(a)
72835 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72836 index 5f1ab92..39c35ae 100644
72837 --- a/include/linux/devfreq.h
72838 +++ b/include/linux/devfreq.h
72839 @@ -114,7 +114,7 @@ struct devfreq_governor {
72840 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72841 int (*event_handler)(struct devfreq *devfreq,
72842 unsigned int event, void *data);
72843 -};
72844 +} __do_const;
72845
72846 /**
72847 * struct devfreq - Device devfreq structure
72848 diff --git a/include/linux/device.h b/include/linux/device.h
72849 index 22b546a..a573dc9 100644
72850 --- a/include/linux/device.h
72851 +++ b/include/linux/device.h
72852 @@ -305,7 +305,7 @@ struct subsys_interface {
72853 struct list_head node;
72854 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72855 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72856 -};
72857 +} __do_const;
72858
72859 int subsys_interface_register(struct subsys_interface *sif);
72860 void subsys_interface_unregister(struct subsys_interface *sif);
72861 @@ -493,7 +493,7 @@ struct device_type {
72862 void (*release)(struct device *dev);
72863
72864 const struct dev_pm_ops *pm;
72865 -};
72866 +} __do_const;
72867
72868 /* interface for exporting device attributes */
72869 struct device_attribute {
72870 @@ -503,11 +503,12 @@ struct device_attribute {
72871 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
72872 const char *buf, size_t count);
72873 };
72874 +typedef struct device_attribute __no_const device_attribute_no_const;
72875
72876 struct dev_ext_attribute {
72877 struct device_attribute attr;
72878 void *var;
72879 -};
72880 +} __do_const;
72881
72882 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
72883 char *buf);
72884 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
72885 index 94af418..b1ca7a2 100644
72886 --- a/include/linux/dma-mapping.h
72887 +++ b/include/linux/dma-mapping.h
72888 @@ -54,7 +54,7 @@ struct dma_map_ops {
72889 u64 (*get_required_mask)(struct device *dev);
72890 #endif
72891 int is_phys;
72892 -};
72893 +} __do_const;
72894
72895 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
72896
72897 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
72898 index cb286b1..923d066 100644
72899 --- a/include/linux/dmaengine.h
72900 +++ b/include/linux/dmaengine.h
72901 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
72902 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
72903 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
72904
72905 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72906 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72907 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
72908 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72909 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72910 struct dma_pinned_list *pinned_list, struct page *page,
72911 unsigned int offset, size_t len);
72912
72913 diff --git a/include/linux/efi.h b/include/linux/efi.h
72914 index 5f8f176..62a0556 100644
72915 --- a/include/linux/efi.h
72916 +++ b/include/linux/efi.h
72917 @@ -745,6 +745,7 @@ struct efivar_operations {
72918 efi_set_variable_t *set_variable;
72919 efi_query_variable_store_t *query_variable_store;
72920 };
72921 +typedef struct efivar_operations __no_const efivar_operations_no_const;
72922
72923 struct efivars {
72924 /*
72925 diff --git a/include/linux/elf.h b/include/linux/elf.h
72926 index 40a3c0e..4c45a38 100644
72927 --- a/include/linux/elf.h
72928 +++ b/include/linux/elf.h
72929 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
72930 #define elf_note elf32_note
72931 #define elf_addr_t Elf32_Off
72932 #define Elf_Half Elf32_Half
72933 +#define elf_dyn Elf32_Dyn
72934
72935 #else
72936
72937 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
72938 #define elf_note elf64_note
72939 #define elf_addr_t Elf64_Off
72940 #define Elf_Half Elf64_Half
72941 +#define elf_dyn Elf64_Dyn
72942
72943 #endif
72944
72945 diff --git a/include/linux/err.h b/include/linux/err.h
72946 index 221fcfb..f29e5e2 100644
72947 --- a/include/linux/err.h
72948 +++ b/include/linux/err.h
72949 @@ -19,12 +19,12 @@
72950
72951 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
72952
72953 -static inline void * __must_check ERR_PTR(long error)
72954 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
72955 {
72956 return (void *) error;
72957 }
72958
72959 -static inline long __must_check PTR_ERR(__force const void *ptr)
72960 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
72961 {
72962 return (long) ptr;
72963 }
72964 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
72965 index fcb51c8..bdafcf6 100644
72966 --- a/include/linux/extcon.h
72967 +++ b/include/linux/extcon.h
72968 @@ -134,7 +134,7 @@ struct extcon_dev {
72969 /* /sys/class/extcon/.../mutually_exclusive/... */
72970 struct attribute_group attr_g_muex;
72971 struct attribute **attrs_muex;
72972 - struct device_attribute *d_attrs_muex;
72973 + device_attribute_no_const *d_attrs_muex;
72974 };
72975
72976 /**
72977 diff --git a/include/linux/fb.h b/include/linux/fb.h
72978 index ffac70a..ca3e711 100644
72979 --- a/include/linux/fb.h
72980 +++ b/include/linux/fb.h
72981 @@ -304,7 +304,7 @@ struct fb_ops {
72982 /* called at KDB enter and leave time to prepare the console */
72983 int (*fb_debug_enter)(struct fb_info *info);
72984 int (*fb_debug_leave)(struct fb_info *info);
72985 -};
72986 +} __do_const;
72987
72988 #ifdef CONFIG_FB_TILEBLITTING
72989 #define FB_TILE_CURSOR_NONE 0
72990 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
72991 index 085197b..0fa6f0b 100644
72992 --- a/include/linux/fdtable.h
72993 +++ b/include/linux/fdtable.h
72994 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
72995 void put_files_struct(struct files_struct *fs);
72996 void reset_files_struct(struct files_struct *);
72997 int unshare_files(struct files_struct **);
72998 -struct files_struct *dup_fd(struct files_struct *, int *);
72999 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73000 void do_close_on_exec(struct files_struct *);
73001 int iterate_fd(struct files_struct *, unsigned,
73002 int (*)(const void *, struct file *, unsigned),
73003 diff --git a/include/linux/filter.h b/include/linux/filter.h
73004 index a6ac848..a104a76 100644
73005 --- a/include/linux/filter.h
73006 +++ b/include/linux/filter.h
73007 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
73008
73009 struct sk_buff;
73010 struct sock;
73011 +struct bpf_jit_work;
73012
73013 struct sk_filter
73014 {
73015 @@ -27,6 +28,9 @@ struct sk_filter
73016 unsigned int len; /* Number of filter blocks */
73017 unsigned int (*bpf_func)(const struct sk_buff *skb,
73018 const struct sock_filter *filter);
73019 +#ifdef CONFIG_BPF_JIT
73020 + struct bpf_jit_work *work;
73021 +#endif
73022 struct rcu_head rcu;
73023 struct sock_filter insns[0];
73024 };
73025 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73026 index 8293262..2b3b8bd 100644
73027 --- a/include/linux/frontswap.h
73028 +++ b/include/linux/frontswap.h
73029 @@ -11,7 +11,7 @@ struct frontswap_ops {
73030 int (*load)(unsigned, pgoff_t, struct page *);
73031 void (*invalidate_page)(unsigned, pgoff_t);
73032 void (*invalidate_area)(unsigned);
73033 -};
73034 +} __no_const;
73035
73036 extern bool frontswap_enabled;
73037 extern struct frontswap_ops *
73038 diff --git a/include/linux/fs.h b/include/linux/fs.h
73039 index 9818747..788bfbd 100644
73040 --- a/include/linux/fs.h
73041 +++ b/include/linux/fs.h
73042 @@ -1554,7 +1554,8 @@ struct file_operations {
73043 long (*fallocate)(struct file *file, int mode, loff_t offset,
73044 loff_t len);
73045 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73046 -};
73047 +} __do_const;
73048 +typedef struct file_operations __no_const file_operations_no_const;
73049
73050 struct inode_operations {
73051 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73052 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
73053 return !IS_DEADDIR(inode);
73054 }
73055
73056 +static inline bool is_sidechannel_device(const struct inode *inode)
73057 +{
73058 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73059 + umode_t mode = inode->i_mode;
73060 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73061 +#else
73062 + return false;
73063 +#endif
73064 +}
73065 +
73066 #endif /* _LINUX_FS_H */
73067 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73068 index 2b93a9a..855d94a 100644
73069 --- a/include/linux/fs_struct.h
73070 +++ b/include/linux/fs_struct.h
73071 @@ -6,7 +6,7 @@
73072 #include <linux/seqlock.h>
73073
73074 struct fs_struct {
73075 - int users;
73076 + atomic_t users;
73077 spinlock_t lock;
73078 seqcount_t seq;
73079 int umask;
73080 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73081 index a9ff9a3..1ba1788 100644
73082 --- a/include/linux/fscache-cache.h
73083 +++ b/include/linux/fscache-cache.h
73084 @@ -113,7 +113,7 @@ struct fscache_operation {
73085 fscache_operation_release_t release;
73086 };
73087
73088 -extern atomic_t fscache_op_debug_id;
73089 +extern atomic_unchecked_t fscache_op_debug_id;
73090 extern void fscache_op_work_func(struct work_struct *work);
73091
73092 extern void fscache_enqueue_operation(struct fscache_operation *);
73093 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73094 INIT_WORK(&op->work, fscache_op_work_func);
73095 atomic_set(&op->usage, 1);
73096 op->state = FSCACHE_OP_ST_INITIALISED;
73097 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73098 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73099 op->processor = processor;
73100 op->release = release;
73101 INIT_LIST_HEAD(&op->pend_link);
73102 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73103 index 7a08623..4c07b0f 100644
73104 --- a/include/linux/fscache.h
73105 +++ b/include/linux/fscache.h
73106 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73107 * - this is mandatory for any object that may have data
73108 */
73109 void (*now_uncached)(void *cookie_netfs_data);
73110 -};
73111 +} __do_const;
73112
73113 /*
73114 * fscache cached network filesystem type
73115 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73116 index 1c804b0..1432c2b 100644
73117 --- a/include/linux/fsnotify.h
73118 +++ b/include/linux/fsnotify.h
73119 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73120 struct inode *inode = file_inode(file);
73121 __u32 mask = FS_ACCESS;
73122
73123 + if (is_sidechannel_device(inode))
73124 + return;
73125 +
73126 if (S_ISDIR(inode->i_mode))
73127 mask |= FS_ISDIR;
73128
73129 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73130 struct inode *inode = file_inode(file);
73131 __u32 mask = FS_MODIFY;
73132
73133 + if (is_sidechannel_device(inode))
73134 + return;
73135 +
73136 if (S_ISDIR(inode->i_mode))
73137 mask |= FS_ISDIR;
73138
73139 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73140 */
73141 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73142 {
73143 - return kstrdup(name, GFP_KERNEL);
73144 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73145 }
73146
73147 /*
73148 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73149 index 9f3c275..911b591 100644
73150 --- a/include/linux/genhd.h
73151 +++ b/include/linux/genhd.h
73152 @@ -194,7 +194,7 @@ struct gendisk {
73153 struct kobject *slave_dir;
73154
73155 struct timer_rand_state *random;
73156 - atomic_t sync_io; /* RAID */
73157 + atomic_unchecked_t sync_io; /* RAID */
73158 struct disk_events *ev;
73159 #ifdef CONFIG_BLK_DEV_INTEGRITY
73160 struct blk_integrity *integrity;
73161 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
73162 index 023bc34..b02b46a 100644
73163 --- a/include/linux/genl_magic_func.h
73164 +++ b/include/linux/genl_magic_func.h
73165 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
73166 },
73167
73168 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
73169 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
73170 +static struct genl_ops ZZZ_genl_ops[] = {
73171 #include GENL_MAGIC_INCLUDE_FILE
73172 };
73173
73174 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
73175 index 9b4dd49..61fd41d 100644
73176 --- a/include/linux/gfp.h
73177 +++ b/include/linux/gfp.h
73178 @@ -35,6 +35,13 @@ struct vm_area_struct;
73179 #define ___GFP_NO_KSWAPD 0x400000u
73180 #define ___GFP_OTHER_NODE 0x800000u
73181 #define ___GFP_WRITE 0x1000000u
73182 +
73183 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73184 +#define ___GFP_USERCOPY 0x2000000u
73185 +#else
73186 +#define ___GFP_USERCOPY 0
73187 +#endif
73188 +
73189 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73190
73191 /*
73192 @@ -92,6 +99,7 @@ struct vm_area_struct;
73193 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73194 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73195 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73196 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73197
73198 /*
73199 * This may seem redundant, but it's a way of annotating false positives vs.
73200 @@ -99,7 +107,7 @@ struct vm_area_struct;
73201 */
73202 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73203
73204 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73205 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73206 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73207
73208 /* This equals 0, but use constants in case they ever change */
73209 @@ -153,6 +161,8 @@ struct vm_area_struct;
73210 /* 4GB DMA on some platforms */
73211 #define GFP_DMA32 __GFP_DMA32
73212
73213 +#define GFP_USERCOPY __GFP_USERCOPY
73214 +
73215 /* Convert GFP flags to their corresponding migrate type */
73216 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73217 {
73218 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73219 new file mode 100644
73220 index 0000000..ebe6d72
73221 --- /dev/null
73222 +++ b/include/linux/gracl.h
73223 @@ -0,0 +1,319 @@
73224 +#ifndef GR_ACL_H
73225 +#define GR_ACL_H
73226 +
73227 +#include <linux/grdefs.h>
73228 +#include <linux/resource.h>
73229 +#include <linux/capability.h>
73230 +#include <linux/dcache.h>
73231 +#include <asm/resource.h>
73232 +
73233 +/* Major status information */
73234 +
73235 +#define GR_VERSION "grsecurity 2.9.1"
73236 +#define GRSECURITY_VERSION 0x2901
73237 +
73238 +enum {
73239 + GR_SHUTDOWN = 0,
73240 + GR_ENABLE = 1,
73241 + GR_SPROLE = 2,
73242 + GR_RELOAD = 3,
73243 + GR_SEGVMOD = 4,
73244 + GR_STATUS = 5,
73245 + GR_UNSPROLE = 6,
73246 + GR_PASSSET = 7,
73247 + GR_SPROLEPAM = 8,
73248 +};
73249 +
73250 +/* Password setup definitions
73251 + * kernel/grhash.c */
73252 +enum {
73253 + GR_PW_LEN = 128,
73254 + GR_SALT_LEN = 16,
73255 + GR_SHA_LEN = 32,
73256 +};
73257 +
73258 +enum {
73259 + GR_SPROLE_LEN = 64,
73260 +};
73261 +
73262 +enum {
73263 + GR_NO_GLOB = 0,
73264 + GR_REG_GLOB,
73265 + GR_CREATE_GLOB
73266 +};
73267 +
73268 +#define GR_NLIMITS 32
73269 +
73270 +/* Begin Data Structures */
73271 +
73272 +struct sprole_pw {
73273 + unsigned char *rolename;
73274 + unsigned char salt[GR_SALT_LEN];
73275 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73276 +};
73277 +
73278 +struct name_entry {
73279 + __u32 key;
73280 + ino_t inode;
73281 + dev_t device;
73282 + char *name;
73283 + __u16 len;
73284 + __u8 deleted;
73285 + struct name_entry *prev;
73286 + struct name_entry *next;
73287 +};
73288 +
73289 +struct inodev_entry {
73290 + struct name_entry *nentry;
73291 + struct inodev_entry *prev;
73292 + struct inodev_entry *next;
73293 +};
73294 +
73295 +struct acl_role_db {
73296 + struct acl_role_label **r_hash;
73297 + __u32 r_size;
73298 +};
73299 +
73300 +struct inodev_db {
73301 + struct inodev_entry **i_hash;
73302 + __u32 i_size;
73303 +};
73304 +
73305 +struct name_db {
73306 + struct name_entry **n_hash;
73307 + __u32 n_size;
73308 +};
73309 +
73310 +struct crash_uid {
73311 + uid_t uid;
73312 + unsigned long expires;
73313 +};
73314 +
73315 +struct gr_hash_struct {
73316 + void **table;
73317 + void **nametable;
73318 + void *first;
73319 + __u32 table_size;
73320 + __u32 used_size;
73321 + int type;
73322 +};
73323 +
73324 +/* Userspace Grsecurity ACL data structures */
73325 +
73326 +struct acl_subject_label {
73327 + char *filename;
73328 + ino_t inode;
73329 + dev_t device;
73330 + __u32 mode;
73331 + kernel_cap_t cap_mask;
73332 + kernel_cap_t cap_lower;
73333 + kernel_cap_t cap_invert_audit;
73334 +
73335 + struct rlimit res[GR_NLIMITS];
73336 + __u32 resmask;
73337 +
73338 + __u8 user_trans_type;
73339 + __u8 group_trans_type;
73340 + uid_t *user_transitions;
73341 + gid_t *group_transitions;
73342 + __u16 user_trans_num;
73343 + __u16 group_trans_num;
73344 +
73345 + __u32 sock_families[2];
73346 + __u32 ip_proto[8];
73347 + __u32 ip_type;
73348 + struct acl_ip_label **ips;
73349 + __u32 ip_num;
73350 + __u32 inaddr_any_override;
73351 +
73352 + __u32 crashes;
73353 + unsigned long expires;
73354 +
73355 + struct acl_subject_label *parent_subject;
73356 + struct gr_hash_struct *hash;
73357 + struct acl_subject_label *prev;
73358 + struct acl_subject_label *next;
73359 +
73360 + struct acl_object_label **obj_hash;
73361 + __u32 obj_hash_size;
73362 + __u16 pax_flags;
73363 +};
73364 +
73365 +struct role_allowed_ip {
73366 + __u32 addr;
73367 + __u32 netmask;
73368 +
73369 + struct role_allowed_ip *prev;
73370 + struct role_allowed_ip *next;
73371 +};
73372 +
73373 +struct role_transition {
73374 + char *rolename;
73375 +
73376 + struct role_transition *prev;
73377 + struct role_transition *next;
73378 +};
73379 +
73380 +struct acl_role_label {
73381 + char *rolename;
73382 + uid_t uidgid;
73383 + __u16 roletype;
73384 +
73385 + __u16 auth_attempts;
73386 + unsigned long expires;
73387 +
73388 + struct acl_subject_label *root_label;
73389 + struct gr_hash_struct *hash;
73390 +
73391 + struct acl_role_label *prev;
73392 + struct acl_role_label *next;
73393 +
73394 + struct role_transition *transitions;
73395 + struct role_allowed_ip *allowed_ips;
73396 + uid_t *domain_children;
73397 + __u16 domain_child_num;
73398 +
73399 + umode_t umask;
73400 +
73401 + struct acl_subject_label **subj_hash;
73402 + __u32 subj_hash_size;
73403 +};
73404 +
73405 +struct user_acl_role_db {
73406 + struct acl_role_label **r_table;
73407 + __u32 num_pointers; /* Number of allocations to track */
73408 + __u32 num_roles; /* Number of roles */
73409 + __u32 num_domain_children; /* Number of domain children */
73410 + __u32 num_subjects; /* Number of subjects */
73411 + __u32 num_objects; /* Number of objects */
73412 +};
73413 +
73414 +struct acl_object_label {
73415 + char *filename;
73416 + ino_t inode;
73417 + dev_t device;
73418 + __u32 mode;
73419 +
73420 + struct acl_subject_label *nested;
73421 + struct acl_object_label *globbed;
73422 +
73423 + /* next two structures not used */
73424 +
73425 + struct acl_object_label *prev;
73426 + struct acl_object_label *next;
73427 +};
73428 +
73429 +struct acl_ip_label {
73430 + char *iface;
73431 + __u32 addr;
73432 + __u32 netmask;
73433 + __u16 low, high;
73434 + __u8 mode;
73435 + __u32 type;
73436 + __u32 proto[8];
73437 +
73438 + /* next two structures not used */
73439 +
73440 + struct acl_ip_label *prev;
73441 + struct acl_ip_label *next;
73442 +};
73443 +
73444 +struct gr_arg {
73445 + struct user_acl_role_db role_db;
73446 + unsigned char pw[GR_PW_LEN];
73447 + unsigned char salt[GR_SALT_LEN];
73448 + unsigned char sum[GR_SHA_LEN];
73449 + unsigned char sp_role[GR_SPROLE_LEN];
73450 + struct sprole_pw *sprole_pws;
73451 + dev_t segv_device;
73452 + ino_t segv_inode;
73453 + uid_t segv_uid;
73454 + __u16 num_sprole_pws;
73455 + __u16 mode;
73456 +};
73457 +
73458 +struct gr_arg_wrapper {
73459 + struct gr_arg *arg;
73460 + __u32 version;
73461 + __u32 size;
73462 +};
73463 +
73464 +struct subject_map {
73465 + struct acl_subject_label *user;
73466 + struct acl_subject_label *kernel;
73467 + struct subject_map *prev;
73468 + struct subject_map *next;
73469 +};
73470 +
73471 +struct acl_subj_map_db {
73472 + struct subject_map **s_hash;
73473 + __u32 s_size;
73474 +};
73475 +
73476 +/* End Data Structures Section */
73477 +
73478 +/* Hash functions generated by empirical testing by Brad Spengler
73479 + Makes good use of the low bits of the inode. Generally 0-1 times
73480 + in loop for successful match. 0-3 for unsuccessful match.
73481 + Shift/add algorithm with modulus of table size and an XOR*/
73482 +
73483 +static __inline__ unsigned int
73484 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73485 +{
73486 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73487 +}
73488 +
73489 + static __inline__ unsigned int
73490 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73491 +{
73492 + return ((const unsigned long)userp % sz);
73493 +}
73494 +
73495 +static __inline__ unsigned int
73496 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73497 +{
73498 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73499 +}
73500 +
73501 +static __inline__ unsigned int
73502 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73503 +{
73504 + return full_name_hash((const unsigned char *)name, len) % sz;
73505 +}
73506 +
73507 +#define FOR_EACH_ROLE_START(role) \
73508 + role = role_list; \
73509 + while (role) {
73510 +
73511 +#define FOR_EACH_ROLE_END(role) \
73512 + role = role->prev; \
73513 + }
73514 +
73515 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73516 + subj = NULL; \
73517 + iter = 0; \
73518 + while (iter < role->subj_hash_size) { \
73519 + if (subj == NULL) \
73520 + subj = role->subj_hash[iter]; \
73521 + if (subj == NULL) { \
73522 + iter++; \
73523 + continue; \
73524 + }
73525 +
73526 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73527 + subj = subj->next; \
73528 + if (subj == NULL) \
73529 + iter++; \
73530 + }
73531 +
73532 +
73533 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73534 + subj = role->hash->first; \
73535 + while (subj != NULL) {
73536 +
73537 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73538 + subj = subj->next; \
73539 + }
73540 +
73541 +#endif
73542 +
73543 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73544 new file mode 100644
73545 index 0000000..33ebd1f
73546 --- /dev/null
73547 +++ b/include/linux/gracl_compat.h
73548 @@ -0,0 +1,156 @@
73549 +#ifndef GR_ACL_COMPAT_H
73550 +#define GR_ACL_COMPAT_H
73551 +
73552 +#include <linux/resource.h>
73553 +#include <asm/resource.h>
73554 +
73555 +struct sprole_pw_compat {
73556 + compat_uptr_t rolename;
73557 + unsigned char salt[GR_SALT_LEN];
73558 + unsigned char sum[GR_SHA_LEN];
73559 +};
73560 +
73561 +struct gr_hash_struct_compat {
73562 + compat_uptr_t table;
73563 + compat_uptr_t nametable;
73564 + compat_uptr_t first;
73565 + __u32 table_size;
73566 + __u32 used_size;
73567 + int type;
73568 +};
73569 +
73570 +struct acl_subject_label_compat {
73571 + compat_uptr_t filename;
73572 + compat_ino_t inode;
73573 + __u32 device;
73574 + __u32 mode;
73575 + kernel_cap_t cap_mask;
73576 + kernel_cap_t cap_lower;
73577 + kernel_cap_t cap_invert_audit;
73578 +
73579 + struct compat_rlimit res[GR_NLIMITS];
73580 + __u32 resmask;
73581 +
73582 + __u8 user_trans_type;
73583 + __u8 group_trans_type;
73584 + compat_uptr_t user_transitions;
73585 + compat_uptr_t group_transitions;
73586 + __u16 user_trans_num;
73587 + __u16 group_trans_num;
73588 +
73589 + __u32 sock_families[2];
73590 + __u32 ip_proto[8];
73591 + __u32 ip_type;
73592 + compat_uptr_t ips;
73593 + __u32 ip_num;
73594 + __u32 inaddr_any_override;
73595 +
73596 + __u32 crashes;
73597 + compat_ulong_t expires;
73598 +
73599 + compat_uptr_t parent_subject;
73600 + compat_uptr_t hash;
73601 + compat_uptr_t prev;
73602 + compat_uptr_t next;
73603 +
73604 + compat_uptr_t obj_hash;
73605 + __u32 obj_hash_size;
73606 + __u16 pax_flags;
73607 +};
73608 +
73609 +struct role_allowed_ip_compat {
73610 + __u32 addr;
73611 + __u32 netmask;
73612 +
73613 + compat_uptr_t prev;
73614 + compat_uptr_t next;
73615 +};
73616 +
73617 +struct role_transition_compat {
73618 + compat_uptr_t rolename;
73619 +
73620 + compat_uptr_t prev;
73621 + compat_uptr_t next;
73622 +};
73623 +
73624 +struct acl_role_label_compat {
73625 + compat_uptr_t rolename;
73626 + uid_t uidgid;
73627 + __u16 roletype;
73628 +
73629 + __u16 auth_attempts;
73630 + compat_ulong_t expires;
73631 +
73632 + compat_uptr_t root_label;
73633 + compat_uptr_t hash;
73634 +
73635 + compat_uptr_t prev;
73636 + compat_uptr_t next;
73637 +
73638 + compat_uptr_t transitions;
73639 + compat_uptr_t allowed_ips;
73640 + compat_uptr_t domain_children;
73641 + __u16 domain_child_num;
73642 +
73643 + umode_t umask;
73644 +
73645 + compat_uptr_t subj_hash;
73646 + __u32 subj_hash_size;
73647 +};
73648 +
73649 +struct user_acl_role_db_compat {
73650 + compat_uptr_t r_table;
73651 + __u32 num_pointers;
73652 + __u32 num_roles;
73653 + __u32 num_domain_children;
73654 + __u32 num_subjects;
73655 + __u32 num_objects;
73656 +};
73657 +
73658 +struct acl_object_label_compat {
73659 + compat_uptr_t filename;
73660 + compat_ino_t inode;
73661 + __u32 device;
73662 + __u32 mode;
73663 +
73664 + compat_uptr_t nested;
73665 + compat_uptr_t globbed;
73666 +
73667 + compat_uptr_t prev;
73668 + compat_uptr_t next;
73669 +};
73670 +
73671 +struct acl_ip_label_compat {
73672 + compat_uptr_t iface;
73673 + __u32 addr;
73674 + __u32 netmask;
73675 + __u16 low, high;
73676 + __u8 mode;
73677 + __u32 type;
73678 + __u32 proto[8];
73679 +
73680 + compat_uptr_t prev;
73681 + compat_uptr_t next;
73682 +};
73683 +
73684 +struct gr_arg_compat {
73685 + struct user_acl_role_db_compat role_db;
73686 + unsigned char pw[GR_PW_LEN];
73687 + unsigned char salt[GR_SALT_LEN];
73688 + unsigned char sum[GR_SHA_LEN];
73689 + unsigned char sp_role[GR_SPROLE_LEN];
73690 + compat_uptr_t sprole_pws;
73691 + __u32 segv_device;
73692 + compat_ino_t segv_inode;
73693 + uid_t segv_uid;
73694 + __u16 num_sprole_pws;
73695 + __u16 mode;
73696 +};
73697 +
73698 +struct gr_arg_wrapper_compat {
73699 + compat_uptr_t arg;
73700 + __u32 version;
73701 + __u32 size;
73702 +};
73703 +
73704 +#endif
73705 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73706 new file mode 100644
73707 index 0000000..323ecf2
73708 --- /dev/null
73709 +++ b/include/linux/gralloc.h
73710 @@ -0,0 +1,9 @@
73711 +#ifndef __GRALLOC_H
73712 +#define __GRALLOC_H
73713 +
73714 +void acl_free_all(void);
73715 +int acl_alloc_stack_init(unsigned long size);
73716 +void *acl_alloc(unsigned long len);
73717 +void *acl_alloc_num(unsigned long num, unsigned long len);
73718 +
73719 +#endif
73720 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73721 new file mode 100644
73722 index 0000000..be66033
73723 --- /dev/null
73724 +++ b/include/linux/grdefs.h
73725 @@ -0,0 +1,140 @@
73726 +#ifndef GRDEFS_H
73727 +#define GRDEFS_H
73728 +
73729 +/* Begin grsecurity status declarations */
73730 +
73731 +enum {
73732 + GR_READY = 0x01,
73733 + GR_STATUS_INIT = 0x00 // disabled state
73734 +};
73735 +
73736 +/* Begin ACL declarations */
73737 +
73738 +/* Role flags */
73739 +
73740 +enum {
73741 + GR_ROLE_USER = 0x0001,
73742 + GR_ROLE_GROUP = 0x0002,
73743 + GR_ROLE_DEFAULT = 0x0004,
73744 + GR_ROLE_SPECIAL = 0x0008,
73745 + GR_ROLE_AUTH = 0x0010,
73746 + GR_ROLE_NOPW = 0x0020,
73747 + GR_ROLE_GOD = 0x0040,
73748 + GR_ROLE_LEARN = 0x0080,
73749 + GR_ROLE_TPE = 0x0100,
73750 + GR_ROLE_DOMAIN = 0x0200,
73751 + GR_ROLE_PAM = 0x0400,
73752 + GR_ROLE_PERSIST = 0x0800
73753 +};
73754 +
73755 +/* ACL Subject and Object mode flags */
73756 +enum {
73757 + GR_DELETED = 0x80000000
73758 +};
73759 +
73760 +/* ACL Object-only mode flags */
73761 +enum {
73762 + GR_READ = 0x00000001,
73763 + GR_APPEND = 0x00000002,
73764 + GR_WRITE = 0x00000004,
73765 + GR_EXEC = 0x00000008,
73766 + GR_FIND = 0x00000010,
73767 + GR_INHERIT = 0x00000020,
73768 + GR_SETID = 0x00000040,
73769 + GR_CREATE = 0x00000080,
73770 + GR_DELETE = 0x00000100,
73771 + GR_LINK = 0x00000200,
73772 + GR_AUDIT_READ = 0x00000400,
73773 + GR_AUDIT_APPEND = 0x00000800,
73774 + GR_AUDIT_WRITE = 0x00001000,
73775 + GR_AUDIT_EXEC = 0x00002000,
73776 + GR_AUDIT_FIND = 0x00004000,
73777 + GR_AUDIT_INHERIT= 0x00008000,
73778 + GR_AUDIT_SETID = 0x00010000,
73779 + GR_AUDIT_CREATE = 0x00020000,
73780 + GR_AUDIT_DELETE = 0x00040000,
73781 + GR_AUDIT_LINK = 0x00080000,
73782 + GR_PTRACERD = 0x00100000,
73783 + GR_NOPTRACE = 0x00200000,
73784 + GR_SUPPRESS = 0x00400000,
73785 + GR_NOLEARN = 0x00800000,
73786 + GR_INIT_TRANSFER= 0x01000000
73787 +};
73788 +
73789 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73790 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73791 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73792 +
73793 +/* ACL subject-only mode flags */
73794 +enum {
73795 + GR_KILL = 0x00000001,
73796 + GR_VIEW = 0x00000002,
73797 + GR_PROTECTED = 0x00000004,
73798 + GR_LEARN = 0x00000008,
73799 + GR_OVERRIDE = 0x00000010,
73800 + /* just a placeholder, this mode is only used in userspace */
73801 + GR_DUMMY = 0x00000020,
73802 + GR_PROTSHM = 0x00000040,
73803 + GR_KILLPROC = 0x00000080,
73804 + GR_KILLIPPROC = 0x00000100,
73805 + /* just a placeholder, this mode is only used in userspace */
73806 + GR_NOTROJAN = 0x00000200,
73807 + GR_PROTPROCFD = 0x00000400,
73808 + GR_PROCACCT = 0x00000800,
73809 + GR_RELAXPTRACE = 0x00001000,
73810 + //GR_NESTED = 0x00002000,
73811 + GR_INHERITLEARN = 0x00004000,
73812 + GR_PROCFIND = 0x00008000,
73813 + GR_POVERRIDE = 0x00010000,
73814 + GR_KERNELAUTH = 0x00020000,
73815 + GR_ATSECURE = 0x00040000,
73816 + GR_SHMEXEC = 0x00080000
73817 +};
73818 +
73819 +enum {
73820 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73821 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73822 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73823 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73824 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73825 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73826 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73827 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73828 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73829 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73830 +};
73831 +
73832 +enum {
73833 + GR_ID_USER = 0x01,
73834 + GR_ID_GROUP = 0x02,
73835 +};
73836 +
73837 +enum {
73838 + GR_ID_ALLOW = 0x01,
73839 + GR_ID_DENY = 0x02,
73840 +};
73841 +
73842 +#define GR_CRASH_RES 31
73843 +#define GR_UIDTABLE_MAX 500
73844 +
73845 +/* begin resource learning section */
73846 +enum {
73847 + GR_RLIM_CPU_BUMP = 60,
73848 + GR_RLIM_FSIZE_BUMP = 50000,
73849 + GR_RLIM_DATA_BUMP = 10000,
73850 + GR_RLIM_STACK_BUMP = 1000,
73851 + GR_RLIM_CORE_BUMP = 10000,
73852 + GR_RLIM_RSS_BUMP = 500000,
73853 + GR_RLIM_NPROC_BUMP = 1,
73854 + GR_RLIM_NOFILE_BUMP = 5,
73855 + GR_RLIM_MEMLOCK_BUMP = 50000,
73856 + GR_RLIM_AS_BUMP = 500000,
73857 + GR_RLIM_LOCKS_BUMP = 2,
73858 + GR_RLIM_SIGPENDING_BUMP = 5,
73859 + GR_RLIM_MSGQUEUE_BUMP = 10000,
73860 + GR_RLIM_NICE_BUMP = 1,
73861 + GR_RLIM_RTPRIO_BUMP = 1,
73862 + GR_RLIM_RTTIME_BUMP = 1000000
73863 +};
73864 +
73865 +#endif
73866 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
73867 new file mode 100644
73868 index 0000000..e337683
73869 --- /dev/null
73870 +++ b/include/linux/grinternal.h
73871 @@ -0,0 +1,229 @@
73872 +#ifndef __GRINTERNAL_H
73873 +#define __GRINTERNAL_H
73874 +
73875 +#ifdef CONFIG_GRKERNSEC
73876 +
73877 +#include <linux/fs.h>
73878 +#include <linux/mnt_namespace.h>
73879 +#include <linux/nsproxy.h>
73880 +#include <linux/gracl.h>
73881 +#include <linux/grdefs.h>
73882 +#include <linux/grmsg.h>
73883 +
73884 +void gr_add_learn_entry(const char *fmt, ...)
73885 + __attribute__ ((format (printf, 1, 2)));
73886 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
73887 + const struct vfsmount *mnt);
73888 +__u32 gr_check_create(const struct dentry *new_dentry,
73889 + const struct dentry *parent,
73890 + const struct vfsmount *mnt, const __u32 mode);
73891 +int gr_check_protected_task(const struct task_struct *task);
73892 +__u32 to_gr_audit(const __u32 reqmode);
73893 +int gr_set_acls(const int type);
73894 +int gr_apply_subject_to_task(struct task_struct *task);
73895 +int gr_acl_is_enabled(void);
73896 +char gr_roletype_to_char(void);
73897 +
73898 +void gr_handle_alertkill(struct task_struct *task);
73899 +char *gr_to_filename(const struct dentry *dentry,
73900 + const struct vfsmount *mnt);
73901 +char *gr_to_filename1(const struct dentry *dentry,
73902 + const struct vfsmount *mnt);
73903 +char *gr_to_filename2(const struct dentry *dentry,
73904 + const struct vfsmount *mnt);
73905 +char *gr_to_filename3(const struct dentry *dentry,
73906 + const struct vfsmount *mnt);
73907 +
73908 +extern int grsec_enable_ptrace_readexec;
73909 +extern int grsec_enable_harden_ptrace;
73910 +extern int grsec_enable_link;
73911 +extern int grsec_enable_fifo;
73912 +extern int grsec_enable_execve;
73913 +extern int grsec_enable_shm;
73914 +extern int grsec_enable_execlog;
73915 +extern int grsec_enable_signal;
73916 +extern int grsec_enable_audit_ptrace;
73917 +extern int grsec_enable_forkfail;
73918 +extern int grsec_enable_time;
73919 +extern int grsec_enable_rofs;
73920 +extern int grsec_deny_new_usb;
73921 +extern int grsec_enable_chroot_shmat;
73922 +extern int grsec_enable_chroot_mount;
73923 +extern int grsec_enable_chroot_double;
73924 +extern int grsec_enable_chroot_pivot;
73925 +extern int grsec_enable_chroot_chdir;
73926 +extern int grsec_enable_chroot_chmod;
73927 +extern int grsec_enable_chroot_mknod;
73928 +extern int grsec_enable_chroot_fchdir;
73929 +extern int grsec_enable_chroot_nice;
73930 +extern int grsec_enable_chroot_execlog;
73931 +extern int grsec_enable_chroot_caps;
73932 +extern int grsec_enable_chroot_sysctl;
73933 +extern int grsec_enable_chroot_unix;
73934 +extern int grsec_enable_symlinkown;
73935 +extern kgid_t grsec_symlinkown_gid;
73936 +extern int grsec_enable_tpe;
73937 +extern kgid_t grsec_tpe_gid;
73938 +extern int grsec_enable_tpe_all;
73939 +extern int grsec_enable_tpe_invert;
73940 +extern int grsec_enable_socket_all;
73941 +extern kgid_t grsec_socket_all_gid;
73942 +extern int grsec_enable_socket_client;
73943 +extern kgid_t grsec_socket_client_gid;
73944 +extern int grsec_enable_socket_server;
73945 +extern kgid_t grsec_socket_server_gid;
73946 +extern kgid_t grsec_audit_gid;
73947 +extern int grsec_enable_group;
73948 +extern int grsec_enable_log_rwxmaps;
73949 +extern int grsec_enable_mount;
73950 +extern int grsec_enable_chdir;
73951 +extern int grsec_resource_logging;
73952 +extern int grsec_enable_blackhole;
73953 +extern int grsec_lastack_retries;
73954 +extern int grsec_enable_brute;
73955 +extern int grsec_lock;
73956 +
73957 +extern spinlock_t grsec_alert_lock;
73958 +extern unsigned long grsec_alert_wtime;
73959 +extern unsigned long grsec_alert_fyet;
73960 +
73961 +extern spinlock_t grsec_audit_lock;
73962 +
73963 +extern rwlock_t grsec_exec_file_lock;
73964 +
73965 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
73966 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
73967 + (tsk)->exec_file->f_path.mnt) : "/")
73968 +
73969 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
73970 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
73971 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73972 +
73973 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
73974 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
73975 + (tsk)->exec_file->f_path.mnt) : "/")
73976 +
73977 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
73978 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
73979 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73980 +
73981 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
73982 +
73983 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
73984 +
73985 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
73986 +{
73987 + if (file1 && file2) {
73988 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
73989 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
73990 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
73991 + return true;
73992 + }
73993 +
73994 + return false;
73995 +}
73996 +
73997 +#define GR_CHROOT_CAPS {{ \
73998 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
73999 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74000 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74001 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74002 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74003 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74004 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74005 +
74006 +#define security_learn(normal_msg,args...) \
74007 +({ \
74008 + read_lock(&grsec_exec_file_lock); \
74009 + gr_add_learn_entry(normal_msg "\n", ## args); \
74010 + read_unlock(&grsec_exec_file_lock); \
74011 +})
74012 +
74013 +enum {
74014 + GR_DO_AUDIT,
74015 + GR_DONT_AUDIT,
74016 + /* used for non-audit messages that we shouldn't kill the task on */
74017 + GR_DONT_AUDIT_GOOD
74018 +};
74019 +
74020 +enum {
74021 + GR_TTYSNIFF,
74022 + GR_RBAC,
74023 + GR_RBAC_STR,
74024 + GR_STR_RBAC,
74025 + GR_RBAC_MODE2,
74026 + GR_RBAC_MODE3,
74027 + GR_FILENAME,
74028 + GR_SYSCTL_HIDDEN,
74029 + GR_NOARGS,
74030 + GR_ONE_INT,
74031 + GR_ONE_INT_TWO_STR,
74032 + GR_ONE_STR,
74033 + GR_STR_INT,
74034 + GR_TWO_STR_INT,
74035 + GR_TWO_INT,
74036 + GR_TWO_U64,
74037 + GR_THREE_INT,
74038 + GR_FIVE_INT_TWO_STR,
74039 + GR_TWO_STR,
74040 + GR_THREE_STR,
74041 + GR_FOUR_STR,
74042 + GR_STR_FILENAME,
74043 + GR_FILENAME_STR,
74044 + GR_FILENAME_TWO_INT,
74045 + GR_FILENAME_TWO_INT_STR,
74046 + GR_TEXTREL,
74047 + GR_PTRACE,
74048 + GR_RESOURCE,
74049 + GR_CAP,
74050 + GR_SIG,
74051 + GR_SIG2,
74052 + GR_CRASH1,
74053 + GR_CRASH2,
74054 + GR_PSACCT,
74055 + GR_RWXMAP,
74056 + GR_RWXMAPVMA
74057 +};
74058 +
74059 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74060 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74061 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74062 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74063 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74064 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74065 +#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)
74066 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74067 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74068 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74069 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74070 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74071 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74072 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74073 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74074 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74075 +#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)
74076 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74077 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74078 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74079 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74080 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74081 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74082 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74083 +#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)
74084 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74085 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74086 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74087 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74088 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74089 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74090 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74091 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74092 +#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)
74093 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74094 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74095 +
74096 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74097 +
74098 +#endif
74099 +
74100 +#endif
74101 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74102 new file mode 100644
74103 index 0000000..a4396b5
74104 --- /dev/null
74105 +++ b/include/linux/grmsg.h
74106 @@ -0,0 +1,113 @@
74107 +#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"
74108 +#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"
74109 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74110 +#define GR_STOPMOD_MSG "denied modification of module state by "
74111 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74112 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74113 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74114 +#define GR_IOPL_MSG "denied use of iopl() by "
74115 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74116 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74117 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74118 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74119 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
74120 +#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"
74121 +#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"
74122 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
74123 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
74124 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
74125 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
74126 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
74127 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
74128 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
74129 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
74130 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
74131 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
74132 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
74133 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
74134 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
74135 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
74136 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
74137 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
74138 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
74139 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
74140 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
74141 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
74142 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
74143 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
74144 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
74145 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
74146 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
74147 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
74148 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
74149 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
74150 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
74151 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
74152 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
74153 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
74154 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
74155 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
74156 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
74157 +#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"
74158 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
74159 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
74160 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
74161 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
74162 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
74163 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
74164 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
74165 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
74166 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
74167 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
74168 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
74169 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
74170 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
74171 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
74172 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
74173 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
74174 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
74175 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
74176 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
74177 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
74178 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
74179 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74180 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74181 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74182 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74183 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74184 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74185 +#define GR_TIME_MSG "time set by "
74186 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74187 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74188 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74189 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74190 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74191 +#define GR_BIND_MSG "denied bind() by "
74192 +#define GR_CONNECT_MSG "denied connect() by "
74193 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74194 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74195 +#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"
74196 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74197 +#define GR_CAP_ACL_MSG "use of %s denied for "
74198 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74199 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74200 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74201 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74202 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74203 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74204 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74205 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74206 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74207 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74208 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74209 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74210 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74211 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74212 +#define GR_VM86_MSG "denied use of vm86 by "
74213 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74214 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74215 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74216 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74217 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74218 +#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 "
74219 +#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 "
74220 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74221 new file mode 100644
74222 index 0000000..d6f5a21
74223 --- /dev/null
74224 +++ b/include/linux/grsecurity.h
74225 @@ -0,0 +1,244 @@
74226 +#ifndef GR_SECURITY_H
74227 +#define GR_SECURITY_H
74228 +#include <linux/fs.h>
74229 +#include <linux/fs_struct.h>
74230 +#include <linux/binfmts.h>
74231 +#include <linux/gracl.h>
74232 +
74233 +/* notify of brain-dead configs */
74234 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74235 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74236 +#endif
74237 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74238 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74239 +#endif
74240 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74241 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74242 +#endif
74243 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74244 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74245 +#endif
74246 +
74247 +int gr_handle_new_usb(void);
74248 +
74249 +void gr_handle_brute_attach(unsigned long mm_flags);
74250 +void gr_handle_brute_check(void);
74251 +void gr_handle_kernel_exploit(void);
74252 +
74253 +char gr_roletype_to_char(void);
74254 +
74255 +int gr_acl_enable_at_secure(void);
74256 +
74257 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74258 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74259 +
74260 +void gr_del_task_from_ip_table(struct task_struct *p);
74261 +
74262 +int gr_pid_is_chrooted(struct task_struct *p);
74263 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74264 +int gr_handle_chroot_nice(void);
74265 +int gr_handle_chroot_sysctl(const int op);
74266 +int gr_handle_chroot_setpriority(struct task_struct *p,
74267 + const int niceval);
74268 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74269 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74270 + const struct vfsmount *mnt);
74271 +void gr_handle_chroot_chdir(const struct path *path);
74272 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74273 + const struct vfsmount *mnt, const int mode);
74274 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74275 + const struct vfsmount *mnt, const int mode);
74276 +int gr_handle_chroot_mount(const struct dentry *dentry,
74277 + const struct vfsmount *mnt,
74278 + const char *dev_name);
74279 +int gr_handle_chroot_pivot(void);
74280 +int gr_handle_chroot_unix(const pid_t pid);
74281 +
74282 +int gr_handle_rawio(const struct inode *inode);
74283 +
74284 +void gr_handle_ioperm(void);
74285 +void gr_handle_iopl(void);
74286 +
74287 +umode_t gr_acl_umask(void);
74288 +
74289 +int gr_tpe_allow(const struct file *file);
74290 +
74291 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74292 +void gr_clear_chroot_entries(struct task_struct *task);
74293 +
74294 +void gr_log_forkfail(const int retval);
74295 +void gr_log_timechange(void);
74296 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74297 +void gr_log_chdir(const struct dentry *dentry,
74298 + const struct vfsmount *mnt);
74299 +void gr_log_chroot_exec(const struct dentry *dentry,
74300 + const struct vfsmount *mnt);
74301 +void gr_log_remount(const char *devname, const int retval);
74302 +void gr_log_unmount(const char *devname, const int retval);
74303 +void gr_log_mount(const char *from, const char *to, const int retval);
74304 +void gr_log_textrel(struct vm_area_struct *vma);
74305 +void gr_log_ptgnustack(struct file *file);
74306 +void gr_log_rwxmmap(struct file *file);
74307 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74308 +
74309 +int gr_handle_follow_link(const struct inode *parent,
74310 + const struct inode *inode,
74311 + const struct dentry *dentry,
74312 + const struct vfsmount *mnt);
74313 +int gr_handle_fifo(const struct dentry *dentry,
74314 + const struct vfsmount *mnt,
74315 + const struct dentry *dir, const int flag,
74316 + const int acc_mode);
74317 +int gr_handle_hardlink(const struct dentry *dentry,
74318 + const struct vfsmount *mnt,
74319 + struct inode *inode,
74320 + const int mode, const struct filename *to);
74321 +
74322 +int gr_is_capable(const int cap);
74323 +int gr_is_capable_nolog(const int cap);
74324 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74325 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74326 +
74327 +void gr_copy_label(struct task_struct *tsk);
74328 +void gr_handle_crash(struct task_struct *task, const int sig);
74329 +int gr_handle_signal(const struct task_struct *p, const int sig);
74330 +int gr_check_crash_uid(const kuid_t uid);
74331 +int gr_check_protected_task(const struct task_struct *task);
74332 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74333 +int gr_acl_handle_mmap(const struct file *file,
74334 + const unsigned long prot);
74335 +int gr_acl_handle_mprotect(const struct file *file,
74336 + const unsigned long prot);
74337 +int gr_check_hidden_task(const struct task_struct *tsk);
74338 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74339 + const struct vfsmount *mnt);
74340 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74341 + const struct vfsmount *mnt);
74342 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74343 + const struct vfsmount *mnt, const int fmode);
74344 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74345 + const struct vfsmount *mnt, umode_t *mode);
74346 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74347 + const struct vfsmount *mnt);
74348 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74349 + const struct vfsmount *mnt);
74350 +int gr_handle_ptrace(struct task_struct *task, const long request);
74351 +int gr_handle_proc_ptrace(struct task_struct *task);
74352 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74353 + const struct vfsmount *mnt);
74354 +int gr_check_crash_exec(const struct file *filp);
74355 +int gr_acl_is_enabled(void);
74356 +void gr_set_kernel_label(struct task_struct *task);
74357 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74358 + const kgid_t gid);
74359 +int gr_set_proc_label(const struct dentry *dentry,
74360 + const struct vfsmount *mnt,
74361 + const int unsafe_flags);
74362 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74363 + const struct vfsmount *mnt);
74364 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74365 + const struct vfsmount *mnt, int acc_mode);
74366 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74367 + const struct dentry *p_dentry,
74368 + const struct vfsmount *p_mnt,
74369 + int open_flags, int acc_mode, const int imode);
74370 +void gr_handle_create(const struct dentry *dentry,
74371 + const struct vfsmount *mnt);
74372 +void gr_handle_proc_create(const struct dentry *dentry,
74373 + const struct inode *inode);
74374 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74375 + const struct dentry *parent_dentry,
74376 + const struct vfsmount *parent_mnt,
74377 + const int mode);
74378 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74379 + const struct dentry *parent_dentry,
74380 + const struct vfsmount *parent_mnt);
74381 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74382 + const struct vfsmount *mnt);
74383 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74384 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74385 + const struct vfsmount *mnt);
74386 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74387 + const struct dentry *parent_dentry,
74388 + const struct vfsmount *parent_mnt,
74389 + const struct filename *from);
74390 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74391 + const struct dentry *parent_dentry,
74392 + const struct vfsmount *parent_mnt,
74393 + const struct dentry *old_dentry,
74394 + const struct vfsmount *old_mnt, const struct filename *to);
74395 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74396 +int gr_acl_handle_rename(struct dentry *new_dentry,
74397 + struct dentry *parent_dentry,
74398 + const struct vfsmount *parent_mnt,
74399 + struct dentry *old_dentry,
74400 + struct inode *old_parent_inode,
74401 + struct vfsmount *old_mnt, const struct filename *newname);
74402 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74403 + struct dentry *old_dentry,
74404 + struct dentry *new_dentry,
74405 + struct vfsmount *mnt, const __u8 replace);
74406 +__u32 gr_check_link(const struct dentry *new_dentry,
74407 + const struct dentry *parent_dentry,
74408 + const struct vfsmount *parent_mnt,
74409 + const struct dentry *old_dentry,
74410 + const struct vfsmount *old_mnt);
74411 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74412 + const unsigned int namelen, const ino_t ino);
74413 +
74414 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74415 + const struct vfsmount *mnt);
74416 +void gr_acl_handle_exit(void);
74417 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74418 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74419 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74420 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74421 +void gr_audit_ptrace(struct task_struct *task);
74422 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74423 +void gr_put_exec_file(struct task_struct *task);
74424 +
74425 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74426 +
74427 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74428 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74429 + const unsigned long wanted, const int gt);
74430 +#else
74431 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74432 + const unsigned long wanted, const int gt)
74433 +{
74434 +}
74435 +#endif
74436 +
74437 +#ifdef CONFIG_GRKERNSEC_RESLOG
74438 +extern void gr_log_resource(const struct task_struct *task, const int res,
74439 + const unsigned long wanted, const int gt);
74440 +#else
74441 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74442 + const unsigned long wanted, const int gt)
74443 +{
74444 +}
74445 +#endif
74446 +
74447 +#ifdef CONFIG_GRKERNSEC
74448 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74449 +void gr_handle_vm86(void);
74450 +void gr_handle_mem_readwrite(u64 from, u64 to);
74451 +
74452 +void gr_log_badprocpid(const char *entry);
74453 +
74454 +extern int grsec_enable_dmesg;
74455 +extern int grsec_disable_privio;
74456 +
74457 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74458 +extern kgid_t grsec_proc_gid;
74459 +#endif
74460 +
74461 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74462 +extern int grsec_enable_chroot_findtask;
74463 +#endif
74464 +#ifdef CONFIG_GRKERNSEC_SETXID
74465 +extern int grsec_enable_setxid;
74466 +#endif
74467 +#endif
74468 +
74469 +#endif
74470 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74471 new file mode 100644
74472 index 0000000..e7ffaaf
74473 --- /dev/null
74474 +++ b/include/linux/grsock.h
74475 @@ -0,0 +1,19 @@
74476 +#ifndef __GRSOCK_H
74477 +#define __GRSOCK_H
74478 +
74479 +extern void gr_attach_curr_ip(const struct sock *sk);
74480 +extern int gr_handle_sock_all(const int family, const int type,
74481 + const int protocol);
74482 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74483 +extern int gr_handle_sock_server_other(const struct sock *sck);
74484 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74485 +extern int gr_search_connect(struct socket * sock,
74486 + struct sockaddr_in * addr);
74487 +extern int gr_search_bind(struct socket * sock,
74488 + struct sockaddr_in * addr);
74489 +extern int gr_search_listen(struct socket * sock);
74490 +extern int gr_search_accept(struct socket * sock);
74491 +extern int gr_search_socket(const int domain, const int type,
74492 + const int protocol);
74493 +
74494 +#endif
74495 diff --git a/include/linux/hid.h b/include/linux/hid.h
74496 index 0c48991..76e41d8 100644
74497 --- a/include/linux/hid.h
74498 +++ b/include/linux/hid.h
74499 @@ -393,10 +393,12 @@ struct hid_report {
74500 struct hid_device *device; /* associated device */
74501 };
74502
74503 +#define HID_MAX_IDS 256
74504 +
74505 struct hid_report_enum {
74506 unsigned numbered;
74507 struct list_head report_list;
74508 - struct hid_report *report_id_hash[256];
74509 + struct hid_report *report_id_hash[HID_MAX_IDS];
74510 };
74511
74512 #define HID_REPORT_TYPES 3
74513 @@ -747,6 +749,10 @@ void hid_output_report(struct hid_report *report, __u8 *data);
74514 struct hid_device *hid_allocate_device(void);
74515 struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
74516 int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
74517 +struct hid_report *hid_validate_report(struct hid_device *hid,
74518 + unsigned int type, unsigned int id,
74519 + unsigned int fields,
74520 + unsigned int report_counts);
74521 int hid_open_report(struct hid_device *device);
74522 int hid_check_keys_pressed(struct hid_device *hid);
74523 int hid_connect(struct hid_device *hid, unsigned int connect_mask);
74524 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74525 index 7fb31da..08b5114 100644
74526 --- a/include/linux/highmem.h
74527 +++ b/include/linux/highmem.h
74528 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74529 kunmap_atomic(kaddr);
74530 }
74531
74532 +static inline void sanitize_highpage(struct page *page)
74533 +{
74534 + void *kaddr;
74535 + unsigned long flags;
74536 +
74537 + local_irq_save(flags);
74538 + kaddr = kmap_atomic(page);
74539 + clear_page(kaddr);
74540 + kunmap_atomic(kaddr);
74541 + local_irq_restore(flags);
74542 +}
74543 +
74544 static inline void zero_user_segments(struct page *page,
74545 unsigned start1, unsigned end1,
74546 unsigned start2, unsigned end2)
74547 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74548 index 1c7b89a..7f52502 100644
74549 --- a/include/linux/hwmon-sysfs.h
74550 +++ b/include/linux/hwmon-sysfs.h
74551 @@ -25,7 +25,8 @@
74552 struct sensor_device_attribute{
74553 struct device_attribute dev_attr;
74554 int index;
74555 -};
74556 +} __do_const;
74557 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74558 #define to_sensor_dev_attr(_dev_attr) \
74559 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74560
74561 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74562 struct device_attribute dev_attr;
74563 u8 index;
74564 u8 nr;
74565 -};
74566 +} __do_const;
74567 #define to_sensor_dev_attr_2(_dev_attr) \
74568 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74569
74570 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74571 index e988fa9..ff9f17e 100644
74572 --- a/include/linux/i2c.h
74573 +++ b/include/linux/i2c.h
74574 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74575 /* To determine what the adapter supports */
74576 u32 (*functionality) (struct i2c_adapter *);
74577 };
74578 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74579
74580 /**
74581 * struct i2c_bus_recovery_info - I2C bus recovery information
74582 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74583 index d23c3c2..eb63c81 100644
74584 --- a/include/linux/i2o.h
74585 +++ b/include/linux/i2o.h
74586 @@ -565,7 +565,7 @@ struct i2o_controller {
74587 struct i2o_device *exec; /* Executive */
74588 #if BITS_PER_LONG == 64
74589 spinlock_t context_list_lock; /* lock for context_list */
74590 - atomic_t context_list_counter; /* needed for unique contexts */
74591 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74592 struct list_head context_list; /* list of context id's
74593 and pointers */
74594 #endif
74595 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74596 index aff7ad8..3942bbd 100644
74597 --- a/include/linux/if_pppox.h
74598 +++ b/include/linux/if_pppox.h
74599 @@ -76,7 +76,7 @@ struct pppox_proto {
74600 int (*ioctl)(struct socket *sock, unsigned int cmd,
74601 unsigned long arg);
74602 struct module *owner;
74603 -};
74604 +} __do_const;
74605
74606 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74607 extern void unregister_pppox_proto(int proto_num);
74608 diff --git a/include/linux/init.h b/include/linux/init.h
74609 index e73f2b7..cc996e0 100644
74610 --- a/include/linux/init.h
74611 +++ b/include/linux/init.h
74612 @@ -39,9 +39,17 @@
74613 * Also note, that this data cannot be "const".
74614 */
74615
74616 +#define add_init_latent_entropy __latent_entropy
74617 +
74618 +#ifdef CONFIG_MEMORY_HOTPLUG
74619 +#define add_meminit_latent_entropy
74620 +#else
74621 +#define add_meminit_latent_entropy __latent_entropy
74622 +#endif
74623 +
74624 /* These are for everybody (although not all archs will actually
74625 discard it in modules) */
74626 -#define __init __section(.init.text) __cold notrace
74627 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74628 #define __initdata __section(.init.data)
74629 #define __initconst __constsection(.init.rodata)
74630 #define __exitdata __section(.exit.data)
74631 @@ -102,7 +110,7 @@
74632 #define __cpuexitconst
74633
74634 /* Used for MEMORY_HOTPLUG */
74635 -#define __meminit __section(.meminit.text) __cold notrace
74636 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74637 #define __meminitdata __section(.meminit.data)
74638 #define __meminitconst __constsection(.meminit.rodata)
74639 #define __memexit __section(.memexit.text) __exitused __cold notrace
74640 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74641 index 5cd0f09..c9f67cc 100644
74642 --- a/include/linux/init_task.h
74643 +++ b/include/linux/init_task.h
74644 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74645
74646 #define INIT_TASK_COMM "swapper"
74647
74648 +#ifdef CONFIG_X86
74649 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74650 +#else
74651 +#define INIT_TASK_THREAD_INFO
74652 +#endif
74653 +
74654 /*
74655 * INIT_TASK is used to set up the first task table, touch at
74656 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74657 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74658 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74659 .comm = INIT_TASK_COMM, \
74660 .thread = INIT_THREAD, \
74661 + INIT_TASK_THREAD_INFO \
74662 .fs = &init_fs, \
74663 .files = &init_files, \
74664 .signal = &init_signals, \
74665 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74666 index 5fa5afe..ac55b25 100644
74667 --- a/include/linux/interrupt.h
74668 +++ b/include/linux/interrupt.h
74669 @@ -430,7 +430,7 @@ enum
74670 /* map softirq index to softirq name. update 'softirq_to_name' in
74671 * kernel/softirq.c when adding a new softirq.
74672 */
74673 -extern char *softirq_to_name[NR_SOFTIRQS];
74674 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74675
74676 /* softirq mask and active fields moved to irq_cpustat_t in
74677 * asm/hardirq.h to get better cache usage. KAO
74678 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74679
74680 struct softirq_action
74681 {
74682 - void (*action)(struct softirq_action *);
74683 -};
74684 + void (*action)(void);
74685 +} __no_const;
74686
74687 asmlinkage void do_softirq(void);
74688 asmlinkage void __do_softirq(void);
74689 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74690 +extern void open_softirq(int nr, void (*action)(void));
74691 extern void softirq_init(void);
74692 extern void __raise_softirq_irqoff(unsigned int nr);
74693
74694 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74695 index 3aeb730..2177f39 100644
74696 --- a/include/linux/iommu.h
74697 +++ b/include/linux/iommu.h
74698 @@ -113,7 +113,7 @@ struct iommu_ops {
74699 u32 (*domain_get_windows)(struct iommu_domain *domain);
74700
74701 unsigned long pgsize_bitmap;
74702 -};
74703 +} __do_const;
74704
74705 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74706 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74707 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74708 index 89b7c24..382af74 100644
74709 --- a/include/linux/ioport.h
74710 +++ b/include/linux/ioport.h
74711 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74712 int adjust_resource(struct resource *res, resource_size_t start,
74713 resource_size_t size);
74714 resource_size_t resource_alignment(struct resource *res);
74715 -static inline resource_size_t resource_size(const struct resource *res)
74716 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74717 {
74718 return res->end - res->start + 1;
74719 }
74720 diff --git a/include/linux/irq.h b/include/linux/irq.h
74721 index f04d3ba..bcf2cfb 100644
74722 --- a/include/linux/irq.h
74723 +++ b/include/linux/irq.h
74724 @@ -333,7 +333,8 @@ struct irq_chip {
74725 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74726
74727 unsigned long flags;
74728 -};
74729 +} __do_const;
74730 +typedef struct irq_chip __no_const irq_chip_no_const;
74731
74732 /*
74733 * irq_chip specific flags
74734 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74735 index 3e203eb..3fe68d0 100644
74736 --- a/include/linux/irqchip/arm-gic.h
74737 +++ b/include/linux/irqchip/arm-gic.h
74738 @@ -59,9 +59,11 @@
74739
74740 #ifndef __ASSEMBLY__
74741
74742 +#include <linux/irq.h>
74743 +
74744 struct device_node;
74745
74746 -extern struct irq_chip gic_arch_extn;
74747 +extern irq_chip_no_const gic_arch_extn;
74748
74749 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74750 u32 offset, struct device_node *);
74751 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74752 index 6883e19..e854fcb 100644
74753 --- a/include/linux/kallsyms.h
74754 +++ b/include/linux/kallsyms.h
74755 @@ -15,7 +15,8 @@
74756
74757 struct module;
74758
74759 -#ifdef CONFIG_KALLSYMS
74760 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74761 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74762 /* Lookup the address for a symbol. Returns 0 if not found. */
74763 unsigned long kallsyms_lookup_name(const char *name);
74764
74765 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74766 /* Stupid that this does nothing, but I didn't create this mess. */
74767 #define __print_symbol(fmt, addr)
74768 #endif /*CONFIG_KALLSYMS*/
74769 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74770 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74771 +extern unsigned long kallsyms_lookup_name(const char *name);
74772 +extern void __print_symbol(const char *fmt, unsigned long address);
74773 +extern int sprint_backtrace(char *buffer, unsigned long address);
74774 +extern int sprint_symbol(char *buffer, unsigned long address);
74775 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74776 +const char *kallsyms_lookup(unsigned long addr,
74777 + unsigned long *symbolsize,
74778 + unsigned long *offset,
74779 + char **modname, char *namebuf);
74780 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74781 + unsigned long *symbolsize,
74782 + unsigned long *offset);
74783 +#endif
74784
74785 /* This macro allows us to keep printk typechecking */
74786 static __printf(1, 2)
74787 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74788 index 518a53a..5e28358 100644
74789 --- a/include/linux/key-type.h
74790 +++ b/include/linux/key-type.h
74791 @@ -125,7 +125,7 @@ struct key_type {
74792 /* internal fields */
74793 struct list_head link; /* link in types list */
74794 struct lock_class_key lock_class; /* key->sem lock class */
74795 -};
74796 +} __do_const;
74797
74798 extern struct key_type key_type_keyring;
74799
74800 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74801 index c6e091b..a940adf 100644
74802 --- a/include/linux/kgdb.h
74803 +++ b/include/linux/kgdb.h
74804 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74805 extern int kgdb_io_module_registered;
74806
74807 extern atomic_t kgdb_setting_breakpoint;
74808 -extern atomic_t kgdb_cpu_doing_single_step;
74809 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74810
74811 extern struct task_struct *kgdb_usethread;
74812 extern struct task_struct *kgdb_contthread;
74813 @@ -254,7 +254,7 @@ struct kgdb_arch {
74814 void (*correct_hw_break)(void);
74815
74816 void (*enable_nmi)(bool on);
74817 -};
74818 +} __do_const;
74819
74820 /**
74821 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74822 @@ -279,7 +279,7 @@ struct kgdb_io {
74823 void (*pre_exception) (void);
74824 void (*post_exception) (void);
74825 int is_console;
74826 -};
74827 +} __do_const;
74828
74829 extern struct kgdb_arch arch_kgdb_ops;
74830
74831 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74832 index 0555cc6..b16a7a4 100644
74833 --- a/include/linux/kmod.h
74834 +++ b/include/linux/kmod.h
74835 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74836 * usually useless though. */
74837 extern __printf(2, 3)
74838 int __request_module(bool wait, const char *name, ...);
74839 +extern __printf(3, 4)
74840 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74841 #define request_module(mod...) __request_module(true, mod)
74842 #define request_module_nowait(mod...) __request_module(false, mod)
74843 #define try_then_request_module(x, mod...) \
74844 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74845 index 939b112..ed6ed51 100644
74846 --- a/include/linux/kobject.h
74847 +++ b/include/linux/kobject.h
74848 @@ -111,7 +111,7 @@ struct kobj_type {
74849 struct attribute **default_attrs;
74850 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74851 const void *(*namespace)(struct kobject *kobj);
74852 -};
74853 +} __do_const;
74854
74855 struct kobj_uevent_env {
74856 char *envp[UEVENT_NUM_ENVP];
74857 @@ -134,6 +134,7 @@ struct kobj_attribute {
74858 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74859 const char *buf, size_t count);
74860 };
74861 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74862
74863 extern const struct sysfs_ops kobj_sysfs_ops;
74864
74865 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74866 index f66b065..c2c29b4 100644
74867 --- a/include/linux/kobject_ns.h
74868 +++ b/include/linux/kobject_ns.h
74869 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74870 const void *(*netlink_ns)(struct sock *sk);
74871 const void *(*initial_ns)(void);
74872 void (*drop_ns)(void *);
74873 -};
74874 +} __do_const;
74875
74876 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74877 int kobj_ns_type_registered(enum kobj_ns_type type);
74878 diff --git a/include/linux/kref.h b/include/linux/kref.h
74879 index 484604d..0f6c5b6 100644
74880 --- a/include/linux/kref.h
74881 +++ b/include/linux/kref.h
74882 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74883 static inline int kref_sub(struct kref *kref, unsigned int count,
74884 void (*release)(struct kref *kref))
74885 {
74886 - WARN_ON(release == NULL);
74887 + BUG_ON(release == NULL);
74888
74889 if (atomic_sub_and_test((int) count, &kref->refcount)) {
74890 release(kref);
74891 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
74892 index a63d83e..77fd685 100644
74893 --- a/include/linux/kvm_host.h
74894 +++ b/include/linux/kvm_host.h
74895 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
74896 {
74897 }
74898 #endif
74899 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74900 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74901 struct module *module);
74902 void kvm_exit(void);
74903
74904 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
74905 struct kvm_guest_debug *dbg);
74906 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
74907
74908 -int kvm_arch_init(void *opaque);
74909 +int kvm_arch_init(const void *opaque);
74910 void kvm_arch_exit(void);
74911
74912 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
74913 diff --git a/include/linux/libata.h b/include/linux/libata.h
74914 index 4ea55bb..dcd2601 100644
74915 --- a/include/linux/libata.h
74916 +++ b/include/linux/libata.h
74917 @@ -924,7 +924,7 @@ struct ata_port_operations {
74918 * fields must be pointers.
74919 */
74920 const struct ata_port_operations *inherits;
74921 -};
74922 +} __do_const;
74923
74924 struct ata_port_info {
74925 unsigned long flags;
74926 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
74927 index d3e8ad2..a949f68 100644
74928 --- a/include/linux/linkage.h
74929 +++ b/include/linux/linkage.h
74930 @@ -31,6 +31,7 @@
74931 #endif
74932
74933 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
74934 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
74935 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
74936
74937 /*
74938 diff --git a/include/linux/list.h b/include/linux/list.h
74939 index f4d8a2f..38e6e46 100644
74940 --- a/include/linux/list.h
74941 +++ b/include/linux/list.h
74942 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
74943 extern void list_del(struct list_head *entry);
74944 #endif
74945
74946 +extern void __pax_list_add(struct list_head *new,
74947 + struct list_head *prev,
74948 + struct list_head *next);
74949 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
74950 +{
74951 + __pax_list_add(new, head, head->next);
74952 +}
74953 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
74954 +{
74955 + __pax_list_add(new, head->prev, head);
74956 +}
74957 +extern void pax_list_del(struct list_head *entry);
74958 +
74959 /**
74960 * list_replace - replace old entry by new one
74961 * @old : the element to be replaced
74962 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
74963 INIT_LIST_HEAD(entry);
74964 }
74965
74966 +extern void pax_list_del_init(struct list_head *entry);
74967 +
74968 /**
74969 * list_move - delete from one list and add as another's head
74970 * @list: the entry to move
74971 diff --git a/include/linux/math64.h b/include/linux/math64.h
74972 index 2913b86..8dcbb1e 100644
74973 --- a/include/linux/math64.h
74974 +++ b/include/linux/math64.h
74975 @@ -15,7 +15,7 @@
74976 * This is commonly provided by 32bit archs to provide an optimized 64bit
74977 * divide.
74978 */
74979 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74980 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74981 {
74982 *remainder = dividend % divisor;
74983 return dividend / divisor;
74984 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
74985 /**
74986 * div64_u64 - unsigned 64bit divide with 64bit divisor
74987 */
74988 -static inline u64 div64_u64(u64 dividend, u64 divisor)
74989 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
74990 {
74991 return dividend / divisor;
74992 }
74993 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
74994 #define div64_ul(x, y) div_u64((x), (y))
74995
74996 #ifndef div_u64_rem
74997 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74998 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74999 {
75000 *remainder = do_div(dividend, divisor);
75001 return dividend;
75002 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
75003 * divide.
75004 */
75005 #ifndef div_u64
75006 -static inline u64 div_u64(u64 dividend, u32 divisor)
75007 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75008 {
75009 u32 remainder;
75010 return div_u64_rem(dividend, divisor, &remainder);
75011 diff --git a/include/linux/mm.h b/include/linux/mm.h
75012 index f022460..6ecf4f9 100644
75013 --- a/include/linux/mm.h
75014 +++ b/include/linux/mm.h
75015 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75016 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75017 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75018 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75019 +
75020 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75021 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75022 +#endif
75023 +
75024 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75025
75026 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
75027 @@ -208,8 +213,8 @@ struct vm_operations_struct {
75028 /* called by access_process_vm when get_user_pages() fails, typically
75029 * for use by special VMAs that can switch between memory and hardware
75030 */
75031 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75032 - void *buf, int len, int write);
75033 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75034 + void *buf, size_t len, int write);
75035 #ifdef CONFIG_NUMA
75036 /*
75037 * set_policy() op must add a reference to any non-NULL @new mempolicy
75038 @@ -239,6 +244,7 @@ struct vm_operations_struct {
75039 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75040 unsigned long size, pgoff_t pgoff);
75041 };
75042 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75043
75044 struct mmu_gather;
75045 struct inode;
75046 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75047 unsigned long *pfn);
75048 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75049 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75050 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75051 - void *buf, int len, int write);
75052 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75053 + void *buf, size_t len, int write);
75054
75055 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75056 loff_t const holebegin, loff_t const holelen)
75057 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75058 }
75059 #endif
75060
75061 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75062 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75063 - void *buf, int len, int write);
75064 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75065 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75066 + void *buf, size_t len, int write);
75067
75068 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75069 unsigned long start, unsigned long nr_pages,
75070 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
75071 int set_page_dirty_lock(struct page *page);
75072 int clear_page_dirty_for_io(struct page *page);
75073
75074 -/* Is the vma a continuation of the stack vma above it? */
75075 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75076 -{
75077 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75078 -}
75079 -
75080 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
75081 - unsigned long addr)
75082 -{
75083 - return (vma->vm_flags & VM_GROWSDOWN) &&
75084 - (vma->vm_start == addr) &&
75085 - !vma_growsdown(vma->vm_prev, addr);
75086 -}
75087 -
75088 -/* Is the vma a continuation of the stack vma below it? */
75089 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
75090 -{
75091 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
75092 -}
75093 -
75094 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
75095 - unsigned long addr)
75096 -{
75097 - return (vma->vm_flags & VM_GROWSUP) &&
75098 - (vma->vm_end == addr) &&
75099 - !vma_growsup(vma->vm_next, addr);
75100 -}
75101 -
75102 extern pid_t
75103 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
75104
75105 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
75106 }
75107 #endif
75108
75109 +#ifdef CONFIG_MMU
75110 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
75111 +#else
75112 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
75113 +{
75114 + return __pgprot(0);
75115 +}
75116 +#endif
75117 +
75118 int vma_wants_writenotify(struct vm_area_struct *vma);
75119
75120 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
75121 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
75122 {
75123 return 0;
75124 }
75125 +
75126 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
75127 + unsigned long address)
75128 +{
75129 + return 0;
75130 +}
75131 #else
75132 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75133 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75134 #endif
75135
75136 #ifdef __PAGETABLE_PMD_FOLDED
75137 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
75138 {
75139 return 0;
75140 }
75141 +
75142 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
75143 + unsigned long address)
75144 +{
75145 + return 0;
75146 +}
75147 #else
75148 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
75149 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
75150 #endif
75151
75152 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
75153 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
75154 NULL: pud_offset(pgd, address);
75155 }
75156
75157 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
75158 +{
75159 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
75160 + NULL: pud_offset(pgd, address);
75161 +}
75162 +
75163 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
75164 {
75165 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
75166 NULL: pmd_offset(pud, address);
75167 }
75168 +
75169 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
75170 +{
75171 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
75172 + NULL: pmd_offset(pud, address);
75173 +}
75174 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
75175
75176 #if USE_SPLIT_PTLOCKS
75177 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
75178 unsigned long len, unsigned long prot, unsigned long flags,
75179 unsigned long pgoff, unsigned long *populate);
75180 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
75181 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
75182
75183 #ifdef CONFIG_MMU
75184 extern int __mm_populate(unsigned long addr, unsigned long len,
75185 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
75186 unsigned long high_limit;
75187 unsigned long align_mask;
75188 unsigned long align_offset;
75189 + unsigned long threadstack_offset;
75190 };
75191
75192 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
75193 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75194 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
75195 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
75196
75197 /*
75198 * Search for an unmapped address range.
75199 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75200 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
75201 */
75202 static inline unsigned long
75203 -vm_unmapped_area(struct vm_unmapped_area_info *info)
75204 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
75205 {
75206 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
75207 return unmapped_area(info);
75208 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75209 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75210 struct vm_area_struct **pprev);
75211
75212 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75213 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75214 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75215 +
75216 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75217 NULL if none. Assume start_addr < end_addr. */
75218 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75219 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75220 return vma;
75221 }
75222
75223 -#ifdef CONFIG_MMU
75224 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75225 -#else
75226 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75227 -{
75228 - return __pgprot(0);
75229 -}
75230 -#endif
75231 -
75232 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75233 unsigned long change_prot_numa(struct vm_area_struct *vma,
75234 unsigned long start, unsigned long end);
75235 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75236 static inline void vm_stat_account(struct mm_struct *mm,
75237 unsigned long flags, struct file *file, long pages)
75238 {
75239 +
75240 +#ifdef CONFIG_PAX_RANDMMAP
75241 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75242 +#endif
75243 +
75244 mm->total_vm += pages;
75245 }
75246 #endif /* CONFIG_PROC_FS */
75247 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75248 extern int sysctl_memory_failure_early_kill;
75249 extern int sysctl_memory_failure_recovery;
75250 extern void shake_page(struct page *p, int access);
75251 -extern atomic_long_t num_poisoned_pages;
75252 +extern atomic_long_unchecked_t num_poisoned_pages;
75253 extern int soft_offline_page(struct page *page, int flags);
75254
75255 extern void dump_page(struct page *page);
75256 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75257 static inline void setup_nr_node_ids(void) {}
75258 #endif
75259
75260 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75261 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75262 +#else
75263 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75264 +#endif
75265 +
75266 #endif /* __KERNEL__ */
75267 #endif /* _LINUX_MM_H */
75268 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75269 index faf4b7c..1e70c6e 100644
75270 --- a/include/linux/mm_types.h
75271 +++ b/include/linux/mm_types.h
75272 @@ -289,6 +289,8 @@ struct vm_area_struct {
75273 #ifdef CONFIG_NUMA
75274 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75275 #endif
75276 +
75277 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75278 };
75279
75280 struct core_thread {
75281 @@ -435,6 +437,24 @@ struct mm_struct {
75282 int first_nid;
75283 #endif
75284 struct uprobes_state uprobes_state;
75285 +
75286 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75287 + unsigned long pax_flags;
75288 +#endif
75289 +
75290 +#ifdef CONFIG_PAX_DLRESOLVE
75291 + unsigned long call_dl_resolve;
75292 +#endif
75293 +
75294 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75295 + unsigned long call_syscall;
75296 +#endif
75297 +
75298 +#ifdef CONFIG_PAX_ASLR
75299 + unsigned long delta_mmap; /* randomized offset */
75300 + unsigned long delta_stack; /* randomized offset */
75301 +#endif
75302 +
75303 };
75304
75305 /* first nid will either be a valid NID or one of these values */
75306 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75307 index c5d5278..f0b68c8 100644
75308 --- a/include/linux/mmiotrace.h
75309 +++ b/include/linux/mmiotrace.h
75310 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75311 /* Called from ioremap.c */
75312 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75313 void __iomem *addr);
75314 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75315 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75316
75317 /* For anyone to insert markers. Remember trailing newline. */
75318 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75319 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75320 {
75321 }
75322
75323 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75324 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75325 {
75326 }
75327
75328 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75329 index af4a3b7..9ad8889 100644
75330 --- a/include/linux/mmzone.h
75331 +++ b/include/linux/mmzone.h
75332 @@ -396,7 +396,7 @@ struct zone {
75333 unsigned long flags; /* zone flags, see below */
75334
75335 /* Zone statistics */
75336 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75337 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75338
75339 /*
75340 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75341 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75342 index 45e9214..a7227d6 100644
75343 --- a/include/linux/mod_devicetable.h
75344 +++ b/include/linux/mod_devicetable.h
75345 @@ -13,7 +13,7 @@
75346 typedef unsigned long kernel_ulong_t;
75347 #endif
75348
75349 -#define PCI_ANY_ID (~0)
75350 +#define PCI_ANY_ID ((__u16)~0)
75351
75352 struct pci_device_id {
75353 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75354 @@ -139,7 +139,7 @@ struct usb_device_id {
75355 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75356 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75357
75358 -#define HID_ANY_ID (~0)
75359 +#define HID_ANY_ID (~0U)
75360 #define HID_BUS_ANY 0xffff
75361 #define HID_GROUP_ANY 0x0000
75362
75363 @@ -467,7 +467,7 @@ struct dmi_system_id {
75364 const char *ident;
75365 struct dmi_strmatch matches[4];
75366 void *driver_data;
75367 -};
75368 +} __do_const;
75369 /*
75370 * struct dmi_device_id appears during expansion of
75371 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75372 diff --git a/include/linux/module.h b/include/linux/module.h
75373 index 46f1ea0..a34ca37 100644
75374 --- a/include/linux/module.h
75375 +++ b/include/linux/module.h
75376 @@ -17,9 +17,11 @@
75377 #include <linux/moduleparam.h>
75378 #include <linux/tracepoint.h>
75379 #include <linux/export.h>
75380 +#include <linux/fs.h>
75381
75382 #include <linux/percpu.h>
75383 #include <asm/module.h>
75384 +#include <asm/pgtable.h>
75385
75386 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75387 #define MODULE_SIG_STRING "~Module signature appended~\n"
75388 @@ -54,12 +56,13 @@ struct module_attribute {
75389 int (*test)(struct module *);
75390 void (*free)(struct module *);
75391 };
75392 +typedef struct module_attribute __no_const module_attribute_no_const;
75393
75394 struct module_version_attribute {
75395 struct module_attribute mattr;
75396 const char *module_name;
75397 const char *version;
75398 -} __attribute__ ((__aligned__(sizeof(void *))));
75399 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75400
75401 extern ssize_t __modver_version_show(struct module_attribute *,
75402 struct module_kobject *, char *);
75403 @@ -232,7 +235,7 @@ struct module
75404
75405 /* Sysfs stuff. */
75406 struct module_kobject mkobj;
75407 - struct module_attribute *modinfo_attrs;
75408 + module_attribute_no_const *modinfo_attrs;
75409 const char *version;
75410 const char *srcversion;
75411 struct kobject *holders_dir;
75412 @@ -281,19 +284,16 @@ struct module
75413 int (*init)(void);
75414
75415 /* If this is non-NULL, vfree after init() returns */
75416 - void *module_init;
75417 + void *module_init_rx, *module_init_rw;
75418
75419 /* Here is the actual code + data, vfree'd on unload. */
75420 - void *module_core;
75421 + void *module_core_rx, *module_core_rw;
75422
75423 /* Here are the sizes of the init and core sections */
75424 - unsigned int init_size, core_size;
75425 + unsigned int init_size_rw, core_size_rw;
75426
75427 /* The size of the executable code in each section. */
75428 - unsigned int init_text_size, core_text_size;
75429 -
75430 - /* Size of RO sections of the module (text+rodata) */
75431 - unsigned int init_ro_size, core_ro_size;
75432 + unsigned int init_size_rx, core_size_rx;
75433
75434 /* Arch-specific module values */
75435 struct mod_arch_specific arch;
75436 @@ -349,6 +349,10 @@ struct module
75437 #ifdef CONFIG_EVENT_TRACING
75438 struct ftrace_event_call **trace_events;
75439 unsigned int num_trace_events;
75440 + struct file_operations trace_id;
75441 + struct file_operations trace_enable;
75442 + struct file_operations trace_format;
75443 + struct file_operations trace_filter;
75444 #endif
75445 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75446 unsigned int num_ftrace_callsites;
75447 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75448 bool is_module_percpu_address(unsigned long addr);
75449 bool is_module_text_address(unsigned long addr);
75450
75451 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75452 +{
75453 +
75454 +#ifdef CONFIG_PAX_KERNEXEC
75455 + if (ktla_ktva(addr) >= (unsigned long)start &&
75456 + ktla_ktva(addr) < (unsigned long)start + size)
75457 + return 1;
75458 +#endif
75459 +
75460 + return ((void *)addr >= start && (void *)addr < start + size);
75461 +}
75462 +
75463 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75464 +{
75465 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75466 +}
75467 +
75468 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75469 +{
75470 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75471 +}
75472 +
75473 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75474 +{
75475 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75476 +}
75477 +
75478 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75479 +{
75480 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75481 +}
75482 +
75483 static inline int within_module_core(unsigned long addr, const struct module *mod)
75484 {
75485 - return (unsigned long)mod->module_core <= addr &&
75486 - addr < (unsigned long)mod->module_core + mod->core_size;
75487 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75488 }
75489
75490 static inline int within_module_init(unsigned long addr, const struct module *mod)
75491 {
75492 - return (unsigned long)mod->module_init <= addr &&
75493 - addr < (unsigned long)mod->module_init + mod->init_size;
75494 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75495 }
75496
75497 /* Search for module by name: must hold module_mutex. */
75498 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75499 index 560ca53..ef621ef 100644
75500 --- a/include/linux/moduleloader.h
75501 +++ b/include/linux/moduleloader.h
75502 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75503 sections. Returns NULL on failure. */
75504 void *module_alloc(unsigned long size);
75505
75506 +#ifdef CONFIG_PAX_KERNEXEC
75507 +void *module_alloc_exec(unsigned long size);
75508 +#else
75509 +#define module_alloc_exec(x) module_alloc(x)
75510 +#endif
75511 +
75512 /* Free memory returned from module_alloc. */
75513 void module_free(struct module *mod, void *module_region);
75514
75515 +#ifdef CONFIG_PAX_KERNEXEC
75516 +void module_free_exec(struct module *mod, void *module_region);
75517 +#else
75518 +#define module_free_exec(x, y) module_free((x), (y))
75519 +#endif
75520 +
75521 /*
75522 * Apply the given relocation to the (simplified) ELF. Return -error
75523 * or 0.
75524 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75525 unsigned int relsec,
75526 struct module *me)
75527 {
75528 +#ifdef CONFIG_MODULES
75529 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75530 +#endif
75531 return -ENOEXEC;
75532 }
75533 #endif
75534 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75535 unsigned int relsec,
75536 struct module *me)
75537 {
75538 +#ifdef CONFIG_MODULES
75539 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75540 +#endif
75541 return -ENOEXEC;
75542 }
75543 #endif
75544 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75545 index 27d9da3..5d94aa3 100644
75546 --- a/include/linux/moduleparam.h
75547 +++ b/include/linux/moduleparam.h
75548 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75549 * @len is usually just sizeof(string).
75550 */
75551 #define module_param_string(name, string, len, perm) \
75552 - static const struct kparam_string __param_string_##name \
75553 + static const struct kparam_string __param_string_##name __used \
75554 = { len, string }; \
75555 __module_param_call(MODULE_PARAM_PREFIX, name, \
75556 &param_ops_string, \
75557 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75558 */
75559 #define module_param_array_named(name, array, type, nump, perm) \
75560 param_check_##type(name, &(array)[0]); \
75561 - static const struct kparam_array __param_arr_##name \
75562 + static const struct kparam_array __param_arr_##name __used \
75563 = { .max = ARRAY_SIZE(array), .num = nump, \
75564 .ops = &param_ops_##type, \
75565 .elemsize = sizeof(array[0]), .elem = array }; \
75566 diff --git a/include/linux/namei.h b/include/linux/namei.h
75567 index 5a5ff57..5ae5070 100644
75568 --- a/include/linux/namei.h
75569 +++ b/include/linux/namei.h
75570 @@ -19,7 +19,7 @@ struct nameidata {
75571 unsigned seq;
75572 int last_type;
75573 unsigned depth;
75574 - char *saved_names[MAX_NESTED_LINKS + 1];
75575 + const char *saved_names[MAX_NESTED_LINKS + 1];
75576 };
75577
75578 /*
75579 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75580
75581 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75582
75583 -static inline void nd_set_link(struct nameidata *nd, char *path)
75584 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75585 {
75586 nd->saved_names[nd->depth] = path;
75587 }
75588
75589 -static inline char *nd_get_link(struct nameidata *nd)
75590 +static inline const char *nd_get_link(const struct nameidata *nd)
75591 {
75592 return nd->saved_names[nd->depth];
75593 }
75594 diff --git a/include/linux/net.h b/include/linux/net.h
75595 index 4f27575..fc8a65f 100644
75596 --- a/include/linux/net.h
75597 +++ b/include/linux/net.h
75598 @@ -183,7 +183,7 @@ struct net_proto_family {
75599 int (*create)(struct net *net, struct socket *sock,
75600 int protocol, int kern);
75601 struct module *owner;
75602 -};
75603 +} __do_const;
75604
75605 struct iovec;
75606 struct kvec;
75607 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75608 index 9a41568..203d903 100644
75609 --- a/include/linux/netdevice.h
75610 +++ b/include/linux/netdevice.h
75611 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75612 int (*ndo_change_carrier)(struct net_device *dev,
75613 bool new_carrier);
75614 };
75615 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75616
75617 /*
75618 * The DEVICE structure.
75619 @@ -1131,7 +1132,7 @@ struct net_device {
75620 int iflink;
75621
75622 struct net_device_stats stats;
75623 - atomic_long_t rx_dropped; /* dropped packets by core network
75624 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75625 * Do not use this in drivers.
75626 */
75627
75628 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75629 index de70f7b..2675e91 100644
75630 --- a/include/linux/netfilter.h
75631 +++ b/include/linux/netfilter.h
75632 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75633 #endif
75634 /* Use the module struct to lock set/get code in place */
75635 struct module *owner;
75636 -};
75637 +} __do_const;
75638
75639 /* Function to register/unregister hook points. */
75640 int nf_register_hook(struct nf_hook_ops *reg);
75641 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75642 index d80e275..c3510b8 100644
75643 --- a/include/linux/netfilter/ipset/ip_set.h
75644 +++ b/include/linux/netfilter/ipset/ip_set.h
75645 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75646 /* Return true if "b" set is the same as "a"
75647 * according to the create set parameters */
75648 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75649 -};
75650 +} __do_const;
75651
75652 /* The core set type structure */
75653 struct ip_set_type {
75654 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75655 index cadb740..d7c37c0 100644
75656 --- a/include/linux/netfilter/nfnetlink.h
75657 +++ b/include/linux/netfilter/nfnetlink.h
75658 @@ -16,7 +16,7 @@ struct nfnl_callback {
75659 const struct nlattr * const cda[]);
75660 const struct nla_policy *policy; /* netlink attribute policy */
75661 const u_int16_t attr_count; /* number of nlattr's */
75662 -};
75663 +} __do_const;
75664
75665 struct nfnetlink_subsystem {
75666 const char *name;
75667 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75668 new file mode 100644
75669 index 0000000..33f4af8
75670 --- /dev/null
75671 +++ b/include/linux/netfilter/xt_gradm.h
75672 @@ -0,0 +1,9 @@
75673 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75674 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75675 +
75676 +struct xt_gradm_mtinfo {
75677 + __u16 flags;
75678 + __u16 invflags;
75679 +};
75680 +
75681 +#endif
75682 diff --git a/include/linux/nls.h b/include/linux/nls.h
75683 index 5dc635f..35f5e11 100644
75684 --- a/include/linux/nls.h
75685 +++ b/include/linux/nls.h
75686 @@ -31,7 +31,7 @@ struct nls_table {
75687 const unsigned char *charset2upper;
75688 struct module *owner;
75689 struct nls_table *next;
75690 -};
75691 +} __do_const;
75692
75693 /* this value hold the maximum octet of charset */
75694 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75695 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75696 index d14a4c3..a078786 100644
75697 --- a/include/linux/notifier.h
75698 +++ b/include/linux/notifier.h
75699 @@ -54,7 +54,8 @@ struct notifier_block {
75700 notifier_fn_t notifier_call;
75701 struct notifier_block __rcu *next;
75702 int priority;
75703 -};
75704 +} __do_const;
75705 +typedef struct notifier_block __no_const notifier_block_no_const;
75706
75707 struct atomic_notifier_head {
75708 spinlock_t lock;
75709 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75710 index a4c5624..79d6d88 100644
75711 --- a/include/linux/oprofile.h
75712 +++ b/include/linux/oprofile.h
75713 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75714 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75715 char const * name, ulong * val);
75716
75717 -/** Create a file for read-only access to an atomic_t. */
75718 +/** Create a file for read-only access to an atomic_unchecked_t. */
75719 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75720 - char const * name, atomic_t * val);
75721 + char const * name, atomic_unchecked_t * val);
75722
75723 /** create a directory */
75724 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75725 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75726 index 8db71dc..a76bf2c 100644
75727 --- a/include/linux/pci_hotplug.h
75728 +++ b/include/linux/pci_hotplug.h
75729 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75730 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75731 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75732 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75733 -};
75734 +} __do_const;
75735 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75736
75737 /**
75738 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75739 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75740 index c43f6ea..2d4416f 100644
75741 --- a/include/linux/perf_event.h
75742 +++ b/include/linux/perf_event.h
75743 @@ -328,8 +328,8 @@ struct perf_event {
75744
75745 enum perf_event_active_state state;
75746 unsigned int attach_state;
75747 - local64_t count;
75748 - atomic64_t child_count;
75749 + local64_t count; /* PaX: fix it one day */
75750 + atomic64_unchecked_t child_count;
75751
75752 /*
75753 * These are the total time in nanoseconds that the event
75754 @@ -380,8 +380,8 @@ struct perf_event {
75755 * These accumulate total time (in nanoseconds) that children
75756 * events have been enabled and running, respectively.
75757 */
75758 - atomic64_t child_total_time_enabled;
75759 - atomic64_t child_total_time_running;
75760 + atomic64_unchecked_t child_total_time_enabled;
75761 + atomic64_unchecked_t child_total_time_running;
75762
75763 /*
75764 * Protect attach/detach and child_list:
75765 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75766 entry->ip[entry->nr++] = ip;
75767 }
75768
75769 -extern int sysctl_perf_event_paranoid;
75770 +extern int sysctl_perf_event_legitimately_concerned;
75771 extern int sysctl_perf_event_mlock;
75772 extern int sysctl_perf_event_sample_rate;
75773 extern int sysctl_perf_cpu_time_max_percent;
75774 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75775 loff_t *ppos);
75776
75777
75778 +static inline bool perf_paranoid_any(void)
75779 +{
75780 + return sysctl_perf_event_legitimately_concerned > 2;
75781 +}
75782 +
75783 static inline bool perf_paranoid_tracepoint_raw(void)
75784 {
75785 - return sysctl_perf_event_paranoid > -1;
75786 + return sysctl_perf_event_legitimately_concerned > -1;
75787 }
75788
75789 static inline bool perf_paranoid_cpu(void)
75790 {
75791 - return sysctl_perf_event_paranoid > 0;
75792 + return sysctl_perf_event_legitimately_concerned > 0;
75793 }
75794
75795 static inline bool perf_paranoid_kernel(void)
75796 {
75797 - return sysctl_perf_event_paranoid > 1;
75798 + return sysctl_perf_event_legitimately_concerned > 1;
75799 }
75800
75801 extern void perf_event_init(void);
75802 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75803 struct device_attribute attr;
75804 u64 id;
75805 const char *event_str;
75806 -};
75807 +} __do_const;
75808
75809 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75810 static struct perf_pmu_events_attr _var = { \
75811 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75812 index b8809fe..ae4ccd0 100644
75813 --- a/include/linux/pipe_fs_i.h
75814 +++ b/include/linux/pipe_fs_i.h
75815 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75816 struct mutex mutex;
75817 wait_queue_head_t wait;
75818 unsigned int nrbufs, curbuf, buffers;
75819 - unsigned int readers;
75820 - unsigned int writers;
75821 - unsigned int files;
75822 - unsigned int waiting_writers;
75823 + atomic_t readers;
75824 + atomic_t writers;
75825 + atomic_t files;
75826 + atomic_t waiting_writers;
75827 unsigned int r_counter;
75828 unsigned int w_counter;
75829 struct page *tmp_page;
75830 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75831 index 5f28cae..3d23723 100644
75832 --- a/include/linux/platform_data/usb-ehci-s5p.h
75833 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75834 @@ -14,7 +14,7 @@
75835 struct s5p_ehci_platdata {
75836 int (*phy_init)(struct platform_device *pdev, int type);
75837 int (*phy_exit)(struct platform_device *pdev, int type);
75838 -};
75839 +} __no_const;
75840
75841 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75842
75843 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75844 index c256c59..8ea94c7 100644
75845 --- a/include/linux/platform_data/usb-ohci-exynos.h
75846 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75847 @@ -14,7 +14,7 @@
75848 struct exynos4_ohci_platdata {
75849 int (*phy_init)(struct platform_device *pdev, int type);
75850 int (*phy_exit)(struct platform_device *pdev, int type);
75851 -};
75852 +} __no_const;
75853
75854 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75855
75856 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75857 index 7c1d252..c5c773e 100644
75858 --- a/include/linux/pm_domain.h
75859 +++ b/include/linux/pm_domain.h
75860 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75861
75862 struct gpd_cpu_data {
75863 unsigned int saved_exit_latency;
75864 - struct cpuidle_state *idle_state;
75865 + cpuidle_state_no_const *idle_state;
75866 };
75867
75868 struct generic_pm_domain {
75869 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75870 index 6fa7cea..7bf6415 100644
75871 --- a/include/linux/pm_runtime.h
75872 +++ b/include/linux/pm_runtime.h
75873 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75874
75875 static inline void pm_runtime_mark_last_busy(struct device *dev)
75876 {
75877 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75878 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75879 }
75880
75881 #else /* !CONFIG_PM_RUNTIME */
75882 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75883 index 195aafc..49a7bc2 100644
75884 --- a/include/linux/pnp.h
75885 +++ b/include/linux/pnp.h
75886 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
75887 struct pnp_fixup {
75888 char id[7];
75889 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
75890 -};
75891 +} __do_const;
75892
75893 /* config parameters */
75894 #define PNP_CONFIG_NORMAL 0x0001
75895 diff --git a/include/linux/poison.h b/include/linux/poison.h
75896 index 2110a81..13a11bb 100644
75897 --- a/include/linux/poison.h
75898 +++ b/include/linux/poison.h
75899 @@ -19,8 +19,8 @@
75900 * under normal circumstances, used to verify that nobody uses
75901 * non-initialized list entries.
75902 */
75903 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
75904 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
75905 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
75906 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
75907
75908 /********** include/linux/timer.h **********/
75909 /*
75910 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
75911 index d8b187c3..9a9257a 100644
75912 --- a/include/linux/power/smartreflex.h
75913 +++ b/include/linux/power/smartreflex.h
75914 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
75915 int (*notify)(struct omap_sr *sr, u32 status);
75916 u8 notify_flags;
75917 u8 class_type;
75918 -};
75919 +} __do_const;
75920
75921 /**
75922 * struct omap_sr_nvalue_table - Smartreflex n-target value info
75923 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
75924 index 4ea1d37..80f4b33 100644
75925 --- a/include/linux/ppp-comp.h
75926 +++ b/include/linux/ppp-comp.h
75927 @@ -84,7 +84,7 @@ struct compressor {
75928 struct module *owner;
75929 /* Extra skb space needed by the compressor algorithm */
75930 unsigned int comp_extra;
75931 -};
75932 +} __do_const;
75933
75934 /*
75935 * The return value from decompress routine is the length of the
75936 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
75937 index f5d4723..a6ea2fa 100644
75938 --- a/include/linux/preempt.h
75939 +++ b/include/linux/preempt.h
75940 @@ -18,8 +18,13 @@
75941 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75942 #endif
75943
75944 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
75945 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75946 +
75947 #define inc_preempt_count() add_preempt_count(1)
75948 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
75949 #define dec_preempt_count() sub_preempt_count(1)
75950 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
75951
75952 #define preempt_count() (current_thread_info()->preempt_count)
75953
75954 @@ -64,6 +69,12 @@ do { \
75955 barrier(); \
75956 } while (0)
75957
75958 +#define raw_preempt_disable() \
75959 +do { \
75960 + raw_inc_preempt_count(); \
75961 + barrier(); \
75962 +} while (0)
75963 +
75964 #define sched_preempt_enable_no_resched() \
75965 do { \
75966 barrier(); \
75967 @@ -72,6 +83,12 @@ do { \
75968
75969 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
75970
75971 +#define raw_preempt_enable_no_resched() \
75972 +do { \
75973 + barrier(); \
75974 + raw_dec_preempt_count(); \
75975 +} while (0)
75976 +
75977 #define preempt_enable() \
75978 do { \
75979 preempt_enable_no_resched(); \
75980 @@ -116,8 +133,10 @@ do { \
75981 * region.
75982 */
75983 #define preempt_disable() barrier()
75984 +#define raw_preempt_disable() barrier()
75985 #define sched_preempt_enable_no_resched() barrier()
75986 #define preempt_enable_no_resched() barrier()
75987 +#define raw_preempt_enable_no_resched() barrier()
75988 #define preempt_enable() barrier()
75989
75990 #define preempt_disable_notrace() barrier()
75991 diff --git a/include/linux/printk.h b/include/linux/printk.h
75992 index 22c7052..ad3fa0a 100644
75993 --- a/include/linux/printk.h
75994 +++ b/include/linux/printk.h
75995 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
75996 void early_printk(const char *s, ...) { }
75997 #endif
75998
75999 +extern int kptr_restrict;
76000 +
76001 #ifdef CONFIG_PRINTK
76002 asmlinkage __printf(5, 0)
76003 int vprintk_emit(int facility, int level,
76004 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
76005
76006 extern int printk_delay_msec;
76007 extern int dmesg_restrict;
76008 -extern int kptr_restrict;
76009
76010 extern void wake_up_klogd(void);
76011
76012 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76013 index 608e60a..c26f864 100644
76014 --- a/include/linux/proc_fs.h
76015 +++ b/include/linux/proc_fs.h
76016 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76017 return proc_create_data(name, mode, parent, proc_fops, NULL);
76018 }
76019
76020 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76021 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76022 +{
76023 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76024 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76025 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76026 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76027 +#else
76028 + return proc_create_data(name, mode, parent, proc_fops, NULL);
76029 +#endif
76030 +}
76031 +
76032 +
76033 extern void proc_set_size(struct proc_dir_entry *, loff_t);
76034 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
76035 extern void *PDE_DATA(const struct inode *);
76036 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
76037 index 34a1e10..03a6d03 100644
76038 --- a/include/linux/proc_ns.h
76039 +++ b/include/linux/proc_ns.h
76040 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76041 void (*put)(void *ns);
76042 int (*install)(struct nsproxy *nsproxy, void *ns);
76043 unsigned int (*inum)(void *ns);
76044 -};
76045 +} __do_const;
76046
76047 struct proc_ns {
76048 void *ns;
76049 diff --git a/include/linux/random.h b/include/linux/random.h
76050 index 3b9377d..943ad4a 100644
76051 --- a/include/linux/random.h
76052 +++ b/include/linux/random.h
76053 @@ -10,6 +10,16 @@
76054
76055
76056 extern void add_device_randomness(const void *, unsigned int);
76057 +
76058 +static inline void add_latent_entropy(void)
76059 +{
76060 +
76061 +#ifdef LATENT_ENTROPY_PLUGIN
76062 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
76063 +#endif
76064 +
76065 +}
76066 +
76067 extern void add_input_randomness(unsigned int type, unsigned int code,
76068 unsigned int value);
76069 extern void add_interrupt_randomness(int irq, int irq_flags);
76070 @@ -32,6 +42,11 @@ void prandom_seed(u32 seed);
76071 u32 prandom_u32_state(struct rnd_state *);
76072 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
76073
76074 +static inline unsigned long pax_get_random_long(void)
76075 +{
76076 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
76077 +}
76078 +
76079 /*
76080 * Handle minimum values for seeds
76081 */
76082 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
76083 index f4b1001..8ddb2b6 100644
76084 --- a/include/linux/rculist.h
76085 +++ b/include/linux/rculist.h
76086 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
76087 struct list_head *prev, struct list_head *next);
76088 #endif
76089
76090 +extern void __pax_list_add_rcu(struct list_head *new,
76091 + struct list_head *prev, struct list_head *next);
76092 +
76093 /**
76094 * list_add_rcu - add a new entry to rcu-protected list
76095 * @new: new entry to be added
76096 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
76097 __list_add_rcu(new, head, head->next);
76098 }
76099
76100 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
76101 +{
76102 + __pax_list_add_rcu(new, head, head->next);
76103 +}
76104 +
76105 /**
76106 * list_add_tail_rcu - add a new entry to rcu-protected list
76107 * @new: new entry to be added
76108 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
76109 __list_add_rcu(new, head->prev, head);
76110 }
76111
76112 +static inline void pax_list_add_tail_rcu(struct list_head *new,
76113 + struct list_head *head)
76114 +{
76115 + __pax_list_add_rcu(new, head->prev, head);
76116 +}
76117 +
76118 /**
76119 * list_del_rcu - deletes entry from list without re-initialization
76120 * @entry: the element to delete from the list.
76121 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
76122 entry->prev = LIST_POISON2;
76123 }
76124
76125 +extern void pax_list_del_rcu(struct list_head *entry);
76126 +
76127 /**
76128 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
76129 * @n: the element to delete from the hash list.
76130 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
76131 index 8e00f9f..9449b55 100644
76132 --- a/include/linux/reboot.h
76133 +++ b/include/linux/reboot.h
76134 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
76135 * Architecture-specific implementations of sys_reboot commands.
76136 */
76137
76138 -extern void machine_restart(char *cmd);
76139 -extern void machine_halt(void);
76140 -extern void machine_power_off(void);
76141 +extern void machine_restart(char *cmd) __noreturn;
76142 +extern void machine_halt(void) __noreturn;
76143 +extern void machine_power_off(void) __noreturn;
76144
76145 extern void machine_shutdown(void);
76146 struct pt_regs;
76147 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
76148 */
76149
76150 extern void kernel_restart_prepare(char *cmd);
76151 -extern void kernel_restart(char *cmd);
76152 -extern void kernel_halt(void);
76153 -extern void kernel_power_off(void);
76154 +extern void kernel_restart(char *cmd) __noreturn;
76155 +extern void kernel_halt(void) __noreturn;
76156 +extern void kernel_power_off(void) __noreturn;
76157
76158 extern int C_A_D; /* for sysctl */
76159 void ctrl_alt_del(void);
76160 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
76161 * Emergency restart, callable from an interrupt handler.
76162 */
76163
76164 -extern void emergency_restart(void);
76165 +extern void emergency_restart(void) __noreturn;
76166 #include <asm/emergency-restart.h>
76167
76168 #endif /* _LINUX_REBOOT_H */
76169 diff --git a/include/linux/regset.h b/include/linux/regset.h
76170 index 8e0c9fe..ac4d221 100644
76171 --- a/include/linux/regset.h
76172 +++ b/include/linux/regset.h
76173 @@ -161,7 +161,8 @@ struct user_regset {
76174 unsigned int align;
76175 unsigned int bias;
76176 unsigned int core_note_type;
76177 -};
76178 +} __do_const;
76179 +typedef struct user_regset __no_const user_regset_no_const;
76180
76181 /**
76182 * struct user_regset_view - available regsets
76183 diff --git a/include/linux/relay.h b/include/linux/relay.h
76184 index d7c8359..818daf5 100644
76185 --- a/include/linux/relay.h
76186 +++ b/include/linux/relay.h
76187 @@ -157,7 +157,7 @@ struct rchan_callbacks
76188 * The callback should return 0 if successful, negative if not.
76189 */
76190 int (*remove_buf_file)(struct dentry *dentry);
76191 -};
76192 +} __no_const;
76193
76194 /*
76195 * CONFIG_RELAY kernel API, kernel/relay.c
76196 diff --git a/include/linux/rio.h b/include/linux/rio.h
76197 index b71d573..2f940bd 100644
76198 --- a/include/linux/rio.h
76199 +++ b/include/linux/rio.h
76200 @@ -355,7 +355,7 @@ struct rio_ops {
76201 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
76202 u64 rstart, u32 size, u32 flags);
76203 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76204 -};
76205 +} __no_const;
76206
76207 #define RIO_RESOURCE_MEM 0x00000100
76208 #define RIO_RESOURCE_DOORBELL 0x00000200
76209 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76210 index 6dacb93..6174423 100644
76211 --- a/include/linux/rmap.h
76212 +++ b/include/linux/rmap.h
76213 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76214 void anon_vma_init(void); /* create anon_vma_cachep */
76215 int anon_vma_prepare(struct vm_area_struct *);
76216 void unlink_anon_vmas(struct vm_area_struct *);
76217 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76218 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76219 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76220 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76221
76222 static inline void anon_vma_merge(struct vm_area_struct *vma,
76223 struct vm_area_struct *next)
76224 diff --git a/include/linux/sched.h b/include/linux/sched.h
76225 index 078066d..4090b3b 100644
76226 --- a/include/linux/sched.h
76227 +++ b/include/linux/sched.h
76228 @@ -62,6 +62,7 @@ struct bio_list;
76229 struct fs_struct;
76230 struct perf_event_context;
76231 struct blk_plug;
76232 +struct linux_binprm;
76233
76234 /*
76235 * List of flags we want to share for kernel threads,
76236 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76237 extern int in_sched_functions(unsigned long addr);
76238
76239 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76240 -extern signed long schedule_timeout(signed long timeout);
76241 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76242 extern signed long schedule_timeout_interruptible(signed long timeout);
76243 extern signed long schedule_timeout_killable(signed long timeout);
76244 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76245 @@ -314,6 +315,19 @@ struct nsproxy;
76246 struct user_namespace;
76247
76248 #ifdef CONFIG_MMU
76249 +
76250 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76251 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76252 +#else
76253 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76254 +{
76255 + return 0;
76256 +}
76257 +#endif
76258 +
76259 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76260 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76261 +
76262 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76263 extern unsigned long
76264 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76265 @@ -589,6 +603,17 @@ struct signal_struct {
76266 #ifdef CONFIG_TASKSTATS
76267 struct taskstats *stats;
76268 #endif
76269 +
76270 +#ifdef CONFIG_GRKERNSEC
76271 + u32 curr_ip;
76272 + u32 saved_ip;
76273 + u32 gr_saddr;
76274 + u32 gr_daddr;
76275 + u16 gr_sport;
76276 + u16 gr_dport;
76277 + u8 used_accept:1;
76278 +#endif
76279 +
76280 #ifdef CONFIG_AUDIT
76281 unsigned audit_tty;
76282 unsigned audit_tty_log_passwd;
76283 @@ -669,6 +694,14 @@ struct user_struct {
76284 struct key *session_keyring; /* UID's default session keyring */
76285 #endif
76286
76287 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76288 + unsigned char kernel_banned;
76289 +#endif
76290 +#ifdef CONFIG_GRKERNSEC_BRUTE
76291 + unsigned char suid_banned;
76292 + unsigned long suid_ban_expires;
76293 +#endif
76294 +
76295 /* Hash table maintenance information */
76296 struct hlist_node uidhash_node;
76297 kuid_t uid;
76298 @@ -1151,8 +1184,8 @@ struct task_struct {
76299 struct list_head thread_group;
76300
76301 struct completion *vfork_done; /* for vfork() */
76302 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76303 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76304 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76305 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76306
76307 cputime_t utime, stime, utimescaled, stimescaled;
76308 cputime_t gtime;
76309 @@ -1177,11 +1210,6 @@ struct task_struct {
76310 struct task_cputime cputime_expires;
76311 struct list_head cpu_timers[3];
76312
76313 -/* process credentials */
76314 - const struct cred __rcu *real_cred; /* objective and real subjective task
76315 - * credentials (COW) */
76316 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76317 - * credentials (COW) */
76318 char comm[TASK_COMM_LEN]; /* executable name excluding path
76319 - access with [gs]et_task_comm (which lock
76320 it with task_lock())
76321 @@ -1198,6 +1226,10 @@ struct task_struct {
76322 #endif
76323 /* CPU-specific state of this task */
76324 struct thread_struct thread;
76325 +/* thread_info moved to task_struct */
76326 +#ifdef CONFIG_X86
76327 + struct thread_info tinfo;
76328 +#endif
76329 /* filesystem information */
76330 struct fs_struct *fs;
76331 /* open file information */
76332 @@ -1271,6 +1303,10 @@ struct task_struct {
76333 gfp_t lockdep_reclaim_gfp;
76334 #endif
76335
76336 +/* process credentials */
76337 + const struct cred __rcu *real_cred; /* objective and real subjective task
76338 + * credentials (COW) */
76339 +
76340 /* journalling filesystem info */
76341 void *journal_info;
76342
76343 @@ -1309,6 +1345,10 @@ struct task_struct {
76344 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76345 struct list_head cg_list;
76346 #endif
76347 +
76348 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76349 + * credentials (COW) */
76350 +
76351 #ifdef CONFIG_FUTEX
76352 struct robust_list_head __user *robust_list;
76353 #ifdef CONFIG_COMPAT
76354 @@ -1406,8 +1446,76 @@ struct task_struct {
76355 unsigned int sequential_io;
76356 unsigned int sequential_io_avg;
76357 #endif
76358 +
76359 +#ifdef CONFIG_GRKERNSEC
76360 + /* grsecurity */
76361 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76362 + u64 exec_id;
76363 +#endif
76364 +#ifdef CONFIG_GRKERNSEC_SETXID
76365 + const struct cred *delayed_cred;
76366 +#endif
76367 + struct dentry *gr_chroot_dentry;
76368 + struct acl_subject_label *acl;
76369 + struct acl_role_label *role;
76370 + struct file *exec_file;
76371 + unsigned long brute_expires;
76372 + u16 acl_role_id;
76373 + /* is this the task that authenticated to the special role */
76374 + u8 acl_sp_role;
76375 + u8 is_writable;
76376 + u8 brute;
76377 + u8 gr_is_chrooted;
76378 +#endif
76379 +
76380 };
76381
76382 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76383 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76384 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76385 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76386 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76387 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76388 +
76389 +#ifdef CONFIG_PAX_SOFTMODE
76390 +extern int pax_softmode;
76391 +#endif
76392 +
76393 +extern int pax_check_flags(unsigned long *);
76394 +
76395 +/* if tsk != current then task_lock must be held on it */
76396 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76397 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76398 +{
76399 + if (likely(tsk->mm))
76400 + return tsk->mm->pax_flags;
76401 + else
76402 + return 0UL;
76403 +}
76404 +
76405 +/* if tsk != current then task_lock must be held on it */
76406 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76407 +{
76408 + if (likely(tsk->mm)) {
76409 + tsk->mm->pax_flags = flags;
76410 + return 0;
76411 + }
76412 + return -EINVAL;
76413 +}
76414 +#endif
76415 +
76416 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76417 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76418 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76419 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76420 +#endif
76421 +
76422 +struct path;
76423 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76424 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76425 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76426 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76427 +
76428 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76429 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76430
76431 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76432 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76433 struct pid_namespace *ns);
76434
76435 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76436 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76437 {
76438 return tsk->pid;
76439 }
76440 @@ -1916,7 +2024,9 @@ void yield(void);
76441 extern struct exec_domain default_exec_domain;
76442
76443 union thread_union {
76444 +#ifndef CONFIG_X86
76445 struct thread_info thread_info;
76446 +#endif
76447 unsigned long stack[THREAD_SIZE/sizeof(long)];
76448 };
76449
76450 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76451 */
76452
76453 extern struct task_struct *find_task_by_vpid(pid_t nr);
76454 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76455 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76456 struct pid_namespace *ns);
76457
76458 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76459 extern void exit_itimers(struct signal_struct *);
76460 extern void flush_itimer_signals(void);
76461
76462 -extern void do_group_exit(int);
76463 +extern __noreturn void do_group_exit(int);
76464
76465 extern int allow_signal(int);
76466 extern int disallow_signal(int);
76467 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76468
76469 #endif
76470
76471 -static inline int object_is_on_stack(void *obj)
76472 +static inline int object_starts_on_stack(void *obj)
76473 {
76474 - void *stack = task_stack_page(current);
76475 + const void *stack = task_stack_page(current);
76476
76477 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76478 }
76479 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76480 index bf8086b..962b035 100644
76481 --- a/include/linux/sched/sysctl.h
76482 +++ b/include/linux/sched/sysctl.h
76483 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76484 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76485
76486 extern int sysctl_max_map_count;
76487 +extern unsigned long sysctl_heap_stack_gap;
76488
76489 extern unsigned int sysctl_sched_latency;
76490 extern unsigned int sysctl_sched_min_granularity;
76491 diff --git a/include/linux/security.h b/include/linux/security.h
76492 index 7ce53ae..8ee24a5 100644
76493 --- a/include/linux/security.h
76494 +++ b/include/linux/security.h
76495 @@ -27,6 +27,7 @@
76496 #include <linux/slab.h>
76497 #include <linux/err.h>
76498 #include <linux/string.h>
76499 +#include <linux/grsecurity.h>
76500
76501 struct linux_binprm;
76502 struct cred;
76503 @@ -116,8 +117,6 @@ struct seq_file;
76504
76505 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76506
76507 -void reset_security_ops(void);
76508 -
76509 #ifdef CONFIG_MMU
76510 extern unsigned long mmap_min_addr;
76511 extern unsigned long dac_mmap_min_addr;
76512 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76513 index 4e32edc..f8f2d18 100644
76514 --- a/include/linux/seq_file.h
76515 +++ b/include/linux/seq_file.h
76516 @@ -26,6 +26,9 @@ struct seq_file {
76517 struct mutex lock;
76518 const struct seq_operations *op;
76519 int poll_event;
76520 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76521 + u64 exec_id;
76522 +#endif
76523 #ifdef CONFIG_USER_NS
76524 struct user_namespace *user_ns;
76525 #endif
76526 @@ -38,6 +41,7 @@ struct seq_operations {
76527 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76528 int (*show) (struct seq_file *m, void *v);
76529 };
76530 +typedef struct seq_operations __no_const seq_operations_no_const;
76531
76532 #define SEQ_SKIP 1
76533
76534 diff --git a/include/linux/shm.h b/include/linux/shm.h
76535 index 429c199..4d42e38 100644
76536 --- a/include/linux/shm.h
76537 +++ b/include/linux/shm.h
76538 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76539
76540 /* The task created the shm object. NULL if the task is dead. */
76541 struct task_struct *shm_creator;
76542 +#ifdef CONFIG_GRKERNSEC
76543 + time_t shm_createtime;
76544 + pid_t shm_lapid;
76545 +#endif
76546 };
76547
76548 /* shm_mode upper byte flags */
76549 diff --git a/include/linux/signal.h b/include/linux/signal.h
76550 index d897484..323ba98 100644
76551 --- a/include/linux/signal.h
76552 +++ b/include/linux/signal.h
76553 @@ -433,6 +433,7 @@ void signals_init(void);
76554
76555 int restore_altstack(const stack_t __user *);
76556 int __save_altstack(stack_t __user *, unsigned long);
76557 +void __save_altstack_ex(stack_t __user *, unsigned long);
76558
76559 #ifdef CONFIG_PROC_FS
76560 struct seq_file;
76561 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76562 index 3b71a4e..5c9f309 100644
76563 --- a/include/linux/skbuff.h
76564 +++ b/include/linux/skbuff.h
76565 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76566 extern struct sk_buff *__alloc_skb(unsigned int size,
76567 gfp_t priority, int flags, int node);
76568 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76569 -static inline struct sk_buff *alloc_skb(unsigned int size,
76570 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76571 gfp_t priority)
76572 {
76573 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76574 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76575 */
76576 static inline int skb_queue_empty(const struct sk_buff_head *list)
76577 {
76578 - return list->next == (struct sk_buff *)list;
76579 + return list->next == (const struct sk_buff *)list;
76580 }
76581
76582 /**
76583 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76584 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76585 const struct sk_buff *skb)
76586 {
76587 - return skb->next == (struct sk_buff *)list;
76588 + return skb->next == (const struct sk_buff *)list;
76589 }
76590
76591 /**
76592 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76593 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76594 const struct sk_buff *skb)
76595 {
76596 - return skb->prev == (struct sk_buff *)list;
76597 + return skb->prev == (const struct sk_buff *)list;
76598 }
76599
76600 /**
76601 @@ -1750,7 +1750,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76602 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76603 */
76604 #ifndef NET_SKB_PAD
76605 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76606 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76607 #endif
76608
76609 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76610 @@ -2345,7 +2345,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76611 int noblock, int *err);
76612 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76613 struct poll_table_struct *wait);
76614 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76615 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76616 int offset, struct iovec *to,
76617 int size);
76618 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76619 @@ -2636,6 +2636,9 @@ static inline void nf_reset(struct sk_buff *skb)
76620 nf_bridge_put(skb->nf_bridge);
76621 skb->nf_bridge = NULL;
76622 #endif
76623 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76624 + skb->nf_trace = 0;
76625 +#endif
76626 }
76627
76628 static inline void nf_reset_trace(struct sk_buff *skb)
76629 diff --git a/include/linux/slab.h b/include/linux/slab.h
76630 index 6c5cc0e..9ca0fd6 100644
76631 --- a/include/linux/slab.h
76632 +++ b/include/linux/slab.h
76633 @@ -12,15 +12,29 @@
76634 #include <linux/gfp.h>
76635 #include <linux/types.h>
76636 #include <linux/workqueue.h>
76637 -
76638 +#include <linux/err.h>
76639
76640 /*
76641 * Flags to pass to kmem_cache_create().
76642 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76643 */
76644 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76645 +
76646 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76647 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76648 +#else
76649 +#define SLAB_USERCOPY 0x00000000UL
76650 +#endif
76651 +
76652 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76653 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76654 +
76655 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76656 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76657 +#else
76658 +#define SLAB_NO_SANITIZE 0x00000000UL
76659 +#endif
76660 +
76661 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76662 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76663 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76664 @@ -89,10 +103,13 @@
76665 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76666 * Both make kfree a no-op.
76667 */
76668 -#define ZERO_SIZE_PTR ((void *)16)
76669 +#define ZERO_SIZE_PTR \
76670 +({ \
76671 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76672 + (void *)(-MAX_ERRNO-1L); \
76673 +})
76674
76675 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76676 - (unsigned long)ZERO_SIZE_PTR)
76677 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76678
76679
76680 struct mem_cgroup;
76681 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76682 void kfree(const void *);
76683 void kzfree(const void *);
76684 size_t ksize(const void *);
76685 +const char *check_heap_object(const void *ptr, unsigned long n);
76686 +bool is_usercopy_object(const void *ptr);
76687
76688 /*
76689 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76690 @@ -164,7 +183,7 @@ struct kmem_cache {
76691 unsigned int align; /* Alignment as calculated */
76692 unsigned long flags; /* Active flags on the slab */
76693 const char *name; /* Slab name for sysfs */
76694 - int refcount; /* Use counter */
76695 + atomic_t refcount; /* Use counter */
76696 void (*ctor)(void *); /* Called on object slot creation */
76697 struct list_head list; /* List of all slab caches on the system */
76698 };
76699 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76700 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76701 #endif
76702
76703 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76704 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76705 +#endif
76706 +
76707 /*
76708 * Figure out which kmalloc slab an allocation of a certain size
76709 * belongs to.
76710 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76711 * 2 = 120 .. 192 bytes
76712 * n = 2^(n-1) .. 2^n -1
76713 */
76714 -static __always_inline int kmalloc_index(size_t size)
76715 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76716 {
76717 if (!size)
76718 return 0;
76719 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76720 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76721 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76722 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76723 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76724 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76725 #define kmalloc_track_caller(size, flags) \
76726 __kmalloc_track_caller(size, flags, _RET_IP_)
76727 #else
76728 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76729 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76730 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76731 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76732 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76733 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76734 #define kmalloc_node_track_caller(size, flags, node) \
76735 __kmalloc_node_track_caller(size, flags, node, \
76736 _RET_IP_)
76737 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76738 index cd40158..4e2f7af 100644
76739 --- a/include/linux/slab_def.h
76740 +++ b/include/linux/slab_def.h
76741 @@ -50,7 +50,7 @@ struct kmem_cache {
76742 /* 4) cache creation/removal */
76743 const char *name;
76744 struct list_head list;
76745 - int refcount;
76746 + atomic_t refcount;
76747 int object_size;
76748 int align;
76749
76750 @@ -66,10 +66,14 @@ struct kmem_cache {
76751 unsigned long node_allocs;
76752 unsigned long node_frees;
76753 unsigned long node_overflow;
76754 - atomic_t allochit;
76755 - atomic_t allocmiss;
76756 - atomic_t freehit;
76757 - atomic_t freemiss;
76758 + atomic_unchecked_t allochit;
76759 + atomic_unchecked_t allocmiss;
76760 + atomic_unchecked_t freehit;
76761 + atomic_unchecked_t freemiss;
76762 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76763 + atomic_unchecked_t sanitized;
76764 + atomic_unchecked_t not_sanitized;
76765 +#endif
76766
76767 /*
76768 * If debugging is enabled, then the allocator can add additional
76769 @@ -103,7 +107,7 @@ struct kmem_cache {
76770 };
76771
76772 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76773 -void *__kmalloc(size_t size, gfp_t flags);
76774 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76775
76776 #ifdef CONFIG_TRACING
76777 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76778 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76779 cachep = kmalloc_dma_caches[i];
76780 else
76781 #endif
76782 +
76783 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76784 + if (flags & GFP_USERCOPY)
76785 + cachep = kmalloc_usercopy_caches[i];
76786 + else
76787 +#endif
76788 +
76789 cachep = kmalloc_caches[i];
76790
76791 ret = kmem_cache_alloc_trace(cachep, flags, size);
76792 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76793 }
76794
76795 #ifdef CONFIG_NUMA
76796 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76797 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76798 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76799
76800 #ifdef CONFIG_TRACING
76801 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76802 cachep = kmalloc_dma_caches[i];
76803 else
76804 #endif
76805 +
76806 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76807 + if (flags & GFP_USERCOPY)
76808 + cachep = kmalloc_usercopy_caches[i];
76809 + else
76810 +#endif
76811 +
76812 cachep = kmalloc_caches[i];
76813
76814 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76815 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76816 index 095a5a4..4b82027 100644
76817 --- a/include/linux/slob_def.h
76818 +++ b/include/linux/slob_def.h
76819 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76820 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76821 }
76822
76823 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76824 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76825
76826 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76827 {
76828 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76829 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76830 }
76831
76832 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76833 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76834 {
76835 return kmalloc(size, flags);
76836 }
76837 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76838 index 027276f..092bfe8 100644
76839 --- a/include/linux/slub_def.h
76840 +++ b/include/linux/slub_def.h
76841 @@ -80,7 +80,7 @@ struct kmem_cache {
76842 struct kmem_cache_order_objects max;
76843 struct kmem_cache_order_objects min;
76844 gfp_t allocflags; /* gfp flags to use on each alloc */
76845 - int refcount; /* Refcount for slab cache destroy */
76846 + atomic_t refcount; /* Refcount for slab cache destroy */
76847 void (*ctor)(void *);
76848 int inuse; /* Offset to metadata */
76849 int align; /* Alignment */
76850 @@ -105,7 +105,7 @@ struct kmem_cache {
76851 };
76852
76853 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76854 -void *__kmalloc(size_t size, gfp_t flags);
76855 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76856
76857 static __always_inline void *
76858 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76859 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76860 }
76861 #endif
76862
76863 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76864 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76865 {
76866 unsigned int order = get_order(size);
76867 return kmalloc_order_trace(size, flags, order);
76868 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76869 }
76870
76871 #ifdef CONFIG_NUMA
76872 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76873 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76874 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76875
76876 #ifdef CONFIG_TRACING
76877 diff --git a/include/linux/smp.h b/include/linux/smp.h
76878 index c181399..09d7b92 100644
76879 --- a/include/linux/smp.h
76880 +++ b/include/linux/smp.h
76881 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
76882 #endif
76883
76884 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
76885 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
76886 #define put_cpu() preempt_enable()
76887 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
76888
76889 /*
76890 * Callback to arch code if there's nosmp or maxcpus=0 on the
76891 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
76892 index 54f91d3..be2c379 100644
76893 --- a/include/linux/sock_diag.h
76894 +++ b/include/linux/sock_diag.h
76895 @@ -11,7 +11,7 @@ struct sock;
76896 struct sock_diag_handler {
76897 __u8 family;
76898 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
76899 -};
76900 +} __do_const;
76901
76902 int sock_diag_register(const struct sock_diag_handler *h);
76903 void sock_diag_unregister(const struct sock_diag_handler *h);
76904 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
76905 index 680f9a3..f13aeb0 100644
76906 --- a/include/linux/sonet.h
76907 +++ b/include/linux/sonet.h
76908 @@ -7,7 +7,7 @@
76909 #include <uapi/linux/sonet.h>
76910
76911 struct k_sonet_stats {
76912 -#define __HANDLE_ITEM(i) atomic_t i
76913 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
76914 __SONET_ITEMS
76915 #undef __HANDLE_ITEM
76916 };
76917 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
76918 index 07d8e53..dc934c9 100644
76919 --- a/include/linux/sunrpc/addr.h
76920 +++ b/include/linux/sunrpc/addr.h
76921 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
76922 {
76923 switch (sap->sa_family) {
76924 case AF_INET:
76925 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
76926 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
76927 case AF_INET6:
76928 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
76929 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
76930 }
76931 return 0;
76932 }
76933 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
76934 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
76935 const struct sockaddr *src)
76936 {
76937 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
76938 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
76939 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
76940
76941 dsin->sin_family = ssin->sin_family;
76942 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
76943 if (sa->sa_family != AF_INET6)
76944 return 0;
76945
76946 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
76947 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
76948 }
76949
76950 #endif /* _LINUX_SUNRPC_ADDR_H */
76951 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
76952 index bfe11be..12bc8c4 100644
76953 --- a/include/linux/sunrpc/clnt.h
76954 +++ b/include/linux/sunrpc/clnt.h
76955 @@ -96,7 +96,7 @@ struct rpc_procinfo {
76956 unsigned int p_timer; /* Which RTT timer to use */
76957 u32 p_statidx; /* Which procedure to account */
76958 const char * p_name; /* name of procedure */
76959 -};
76960 +} __do_const;
76961
76962 #ifdef __KERNEL__
76963
76964 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
76965 index 1f0216b..6a4fa50 100644
76966 --- a/include/linux/sunrpc/svc.h
76967 +++ b/include/linux/sunrpc/svc.h
76968 @@ -411,7 +411,7 @@ struct svc_procedure {
76969 unsigned int pc_count; /* call count */
76970 unsigned int pc_cachetype; /* cache info (NFS) */
76971 unsigned int pc_xdrressize; /* maximum size of XDR reply */
76972 -};
76973 +} __do_const;
76974
76975 /*
76976 * Function prototypes.
76977 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
76978 index 0b8e3e6..33e0a01 100644
76979 --- a/include/linux/sunrpc/svc_rdma.h
76980 +++ b/include/linux/sunrpc/svc_rdma.h
76981 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
76982 extern unsigned int svcrdma_max_requests;
76983 extern unsigned int svcrdma_max_req_size;
76984
76985 -extern atomic_t rdma_stat_recv;
76986 -extern atomic_t rdma_stat_read;
76987 -extern atomic_t rdma_stat_write;
76988 -extern atomic_t rdma_stat_sq_starve;
76989 -extern atomic_t rdma_stat_rq_starve;
76990 -extern atomic_t rdma_stat_rq_poll;
76991 -extern atomic_t rdma_stat_rq_prod;
76992 -extern atomic_t rdma_stat_sq_poll;
76993 -extern atomic_t rdma_stat_sq_prod;
76994 +extern atomic_unchecked_t rdma_stat_recv;
76995 +extern atomic_unchecked_t rdma_stat_read;
76996 +extern atomic_unchecked_t rdma_stat_write;
76997 +extern atomic_unchecked_t rdma_stat_sq_starve;
76998 +extern atomic_unchecked_t rdma_stat_rq_starve;
76999 +extern atomic_unchecked_t rdma_stat_rq_poll;
77000 +extern atomic_unchecked_t rdma_stat_rq_prod;
77001 +extern atomic_unchecked_t rdma_stat_sq_poll;
77002 +extern atomic_unchecked_t rdma_stat_sq_prod;
77003
77004 #define RPCRDMA_VERSION 1
77005
77006 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
77007 index 8d71d65..f79586e 100644
77008 --- a/include/linux/sunrpc/svcauth.h
77009 +++ b/include/linux/sunrpc/svcauth.h
77010 @@ -120,7 +120,7 @@ struct auth_ops {
77011 int (*release)(struct svc_rqst *rq);
77012 void (*domain_release)(struct auth_domain *);
77013 int (*set_client)(struct svc_rqst *rq);
77014 -};
77015 +} __do_const;
77016
77017 #define SVC_GARBAGE 1
77018 #define SVC_SYSERR 2
77019 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77020 index a5ffd32..0935dea 100644
77021 --- a/include/linux/swiotlb.h
77022 +++ b/include/linux/swiotlb.h
77023 @@ -60,7 +60,8 @@ extern void
77024
77025 extern void
77026 swiotlb_free_coherent(struct device *hwdev, size_t size,
77027 - void *vaddr, dma_addr_t dma_handle);
77028 + void *vaddr, dma_addr_t dma_handle,
77029 + struct dma_attrs *attrs);
77030
77031 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77032 unsigned long offset, size_t size,
77033 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77034 index 84662ec..5271947 100644
77035 --- a/include/linux/syscalls.h
77036 +++ b/include/linux/syscalls.h
77037 @@ -97,8 +97,14 @@ struct sigaltstack;
77038 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77039
77040 #define __SC_DECL(t, a) t a
77041 +#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))
77042 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77043 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77044 +#define __SC_LONG(t, a) __typeof( \
77045 + __builtin_choose_expr( \
77046 + sizeof(t) > sizeof(int), \
77047 + (t) 0, \
77048 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77049 + )) a
77050 #define __SC_CAST(t, a) (t) a
77051 #define __SC_ARGS(t, a) a
77052 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77053 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
77054 asmlinkage long sys_fsync(unsigned int fd);
77055 asmlinkage long sys_fdatasync(unsigned int fd);
77056 asmlinkage long sys_bdflush(int func, long data);
77057 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77058 - char __user *type, unsigned long flags,
77059 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77060 + const char __user *type, unsigned long flags,
77061 void __user *data);
77062 -asmlinkage long sys_umount(char __user *name, int flags);
77063 -asmlinkage long sys_oldumount(char __user *name);
77064 +asmlinkage long sys_umount(const char __user *name, int flags);
77065 +asmlinkage long sys_oldumount(const char __user *name);
77066 asmlinkage long sys_truncate(const char __user *path, long length);
77067 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77068 asmlinkage long sys_stat(const char __user *filename,
77069 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77070 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77071 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77072 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77073 - struct sockaddr __user *, int);
77074 + struct sockaddr __user *, int) __intentional_overflow(0);
77075 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77076 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77077 unsigned int vlen, unsigned flags);
77078 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77079 index 27b3b0b..e093dd9 100644
77080 --- a/include/linux/syscore_ops.h
77081 +++ b/include/linux/syscore_ops.h
77082 @@ -16,7 +16,7 @@ struct syscore_ops {
77083 int (*suspend)(void);
77084 void (*resume)(void);
77085 void (*shutdown)(void);
77086 -};
77087 +} __do_const;
77088
77089 extern void register_syscore_ops(struct syscore_ops *ops);
77090 extern void unregister_syscore_ops(struct syscore_ops *ops);
77091 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77092 index 14a8ff2..af52bad 100644
77093 --- a/include/linux/sysctl.h
77094 +++ b/include/linux/sysctl.h
77095 @@ -34,13 +34,13 @@ struct ctl_table_root;
77096 struct ctl_table_header;
77097 struct ctl_dir;
77098
77099 -typedef struct ctl_table ctl_table;
77100 -
77101 typedef int proc_handler (struct ctl_table *ctl, int write,
77102 void __user *buffer, size_t *lenp, loff_t *ppos);
77103
77104 extern int proc_dostring(struct ctl_table *, int,
77105 void __user *, size_t *, loff_t *);
77106 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77107 + void __user *, size_t *, loff_t *);
77108 extern int proc_dointvec(struct ctl_table *, int,
77109 void __user *, size_t *, loff_t *);
77110 extern int proc_dointvec_minmax(struct ctl_table *, int,
77111 @@ -115,7 +115,9 @@ struct ctl_table
77112 struct ctl_table_poll *poll;
77113 void *extra1;
77114 void *extra2;
77115 -};
77116 +} __do_const;
77117 +typedef struct ctl_table __no_const ctl_table_no_const;
77118 +typedef struct ctl_table ctl_table;
77119
77120 struct ctl_node {
77121 struct rb_node node;
77122 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77123 index 9e8a9b5..753de68 100644
77124 --- a/include/linux/sysfs.h
77125 +++ b/include/linux/sysfs.h
77126 @@ -33,7 +33,8 @@ struct attribute {
77127 struct lock_class_key *key;
77128 struct lock_class_key skey;
77129 #endif
77130 -};
77131 +} __do_const;
77132 +typedef struct attribute __no_const attribute_no_const;
77133
77134 /**
77135 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
77136 @@ -62,7 +63,8 @@ struct attribute_group {
77137 struct attribute *, int);
77138 struct attribute **attrs;
77139 struct bin_attribute **bin_attrs;
77140 -};
77141 +} __do_const;
77142 +typedef struct attribute_group __no_const attribute_group_no_const;
77143
77144 /**
77145 * Use these macros to make defining attributes easier. See include/linux/device.h
77146 @@ -123,7 +125,8 @@ struct bin_attribute {
77147 char *, loff_t, size_t);
77148 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
77149 struct vm_area_struct *vma);
77150 -};
77151 +} __do_const;
77152 +typedef struct bin_attribute __no_const bin_attribute_no_const;
77153
77154 /**
77155 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
77156 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
77157 index 7faf933..9b85a0c 100644
77158 --- a/include/linux/sysrq.h
77159 +++ b/include/linux/sysrq.h
77160 @@ -16,6 +16,7 @@
77161
77162 #include <linux/errno.h>
77163 #include <linux/types.h>
77164 +#include <linux/compiler.h>
77165
77166 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
77167 #define SYSRQ_DEFAULT_ENABLE 1
77168 @@ -36,7 +37,7 @@ struct sysrq_key_op {
77169 char *help_msg;
77170 char *action_msg;
77171 int enable_mask;
77172 -};
77173 +} __do_const;
77174
77175 #ifdef CONFIG_MAGIC_SYSRQ
77176
77177 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
77178 index e7e0473..7989295 100644
77179 --- a/include/linux/thread_info.h
77180 +++ b/include/linux/thread_info.h
77181 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
77182 #error "no set_restore_sigmask() provided and default one won't work"
77183 #endif
77184
77185 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
77186 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
77187 +{
77188 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
77189 + if (!__builtin_constant_p(n))
77190 +#endif
77191 + __check_object_size(ptr, n, to_user);
77192 +}
77193 +
77194 #endif /* __KERNEL__ */
77195
77196 #endif /* _LINUX_THREAD_INFO_H */
77197 diff --git a/include/linux/tty.h b/include/linux/tty.h
77198 index 01ac30e..bf18a71 100644
77199 --- a/include/linux/tty.h
77200 +++ b/include/linux/tty.h
77201 @@ -194,7 +194,7 @@ struct tty_port {
77202 const struct tty_port_operations *ops; /* Port operations */
77203 spinlock_t lock; /* Lock protecting tty field */
77204 int blocked_open; /* Waiting to open */
77205 - int count; /* Usage count */
77206 + atomic_t count; /* Usage count */
77207 wait_queue_head_t open_wait; /* Open waiters */
77208 wait_queue_head_t close_wait; /* Close waiters */
77209 wait_queue_head_t delta_msr_wait; /* Modem status change */
77210 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
77211 struct tty_struct *tty, struct file *filp);
77212 static inline int tty_port_users(struct tty_port *port)
77213 {
77214 - return port->count + port->blocked_open;
77215 + return atomic_read(&port->count) + port->blocked_open;
77216 }
77217
77218 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77219 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77220 index 756a609..b302dd6 100644
77221 --- a/include/linux/tty_driver.h
77222 +++ b/include/linux/tty_driver.h
77223 @@ -285,7 +285,7 @@ struct tty_operations {
77224 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77225 #endif
77226 const struct file_operations *proc_fops;
77227 -};
77228 +} __do_const;
77229
77230 struct tty_driver {
77231 int magic; /* magic number for this structure */
77232 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77233 index a1b0489..f02e17c 100644
77234 --- a/include/linux/tty_ldisc.h
77235 +++ b/include/linux/tty_ldisc.h
77236 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77237
77238 struct module *owner;
77239
77240 - int refcount;
77241 + atomic_t refcount;
77242 };
77243
77244 struct tty_ldisc {
77245 diff --git a/include/linux/types.h b/include/linux/types.h
77246 index 4d118ba..c3ee9bf 100644
77247 --- a/include/linux/types.h
77248 +++ b/include/linux/types.h
77249 @@ -176,10 +176,26 @@ typedef struct {
77250 int counter;
77251 } atomic_t;
77252
77253 +#ifdef CONFIG_PAX_REFCOUNT
77254 +typedef struct {
77255 + int counter;
77256 +} atomic_unchecked_t;
77257 +#else
77258 +typedef atomic_t atomic_unchecked_t;
77259 +#endif
77260 +
77261 #ifdef CONFIG_64BIT
77262 typedef struct {
77263 long counter;
77264 } atomic64_t;
77265 +
77266 +#ifdef CONFIG_PAX_REFCOUNT
77267 +typedef struct {
77268 + long counter;
77269 +} atomic64_unchecked_t;
77270 +#else
77271 +typedef atomic64_t atomic64_unchecked_t;
77272 +#endif
77273 #endif
77274
77275 struct list_head {
77276 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77277 index 5ca0951..ab496a5 100644
77278 --- a/include/linux/uaccess.h
77279 +++ b/include/linux/uaccess.h
77280 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77281 long ret; \
77282 mm_segment_t old_fs = get_fs(); \
77283 \
77284 - set_fs(KERNEL_DS); \
77285 pagefault_disable(); \
77286 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77287 - pagefault_enable(); \
77288 + set_fs(KERNEL_DS); \
77289 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77290 set_fs(old_fs); \
77291 + pagefault_enable(); \
77292 ret; \
77293 })
77294
77295 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77296 index 8e522cbc..aa8572d 100644
77297 --- a/include/linux/uidgid.h
77298 +++ b/include/linux/uidgid.h
77299 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77300
77301 #endif /* CONFIG_USER_NS */
77302
77303 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77304 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77305 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77306 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77307 +
77308 #endif /* _LINUX_UIDGID_H */
77309 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77310 index 99c1b4d..562e6f3 100644
77311 --- a/include/linux/unaligned/access_ok.h
77312 +++ b/include/linux/unaligned/access_ok.h
77313 @@ -4,34 +4,34 @@
77314 #include <linux/kernel.h>
77315 #include <asm/byteorder.h>
77316
77317 -static inline u16 get_unaligned_le16(const void *p)
77318 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77319 {
77320 - return le16_to_cpup((__le16 *)p);
77321 + return le16_to_cpup((const __le16 *)p);
77322 }
77323
77324 -static inline u32 get_unaligned_le32(const void *p)
77325 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77326 {
77327 - return le32_to_cpup((__le32 *)p);
77328 + return le32_to_cpup((const __le32 *)p);
77329 }
77330
77331 -static inline u64 get_unaligned_le64(const void *p)
77332 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77333 {
77334 - return le64_to_cpup((__le64 *)p);
77335 + return le64_to_cpup((const __le64 *)p);
77336 }
77337
77338 -static inline u16 get_unaligned_be16(const void *p)
77339 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77340 {
77341 - return be16_to_cpup((__be16 *)p);
77342 + return be16_to_cpup((const __be16 *)p);
77343 }
77344
77345 -static inline u32 get_unaligned_be32(const void *p)
77346 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77347 {
77348 - return be32_to_cpup((__be32 *)p);
77349 + return be32_to_cpup((const __be32 *)p);
77350 }
77351
77352 -static inline u64 get_unaligned_be64(const void *p)
77353 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77354 {
77355 - return be64_to_cpup((__be64 *)p);
77356 + return be64_to_cpup((const __be64 *)p);
77357 }
77358
77359 static inline void put_unaligned_le16(u16 val, void *p)
77360 diff --git a/include/linux/usb.h b/include/linux/usb.h
77361 index 0eec268..4496526 100644
77362 --- a/include/linux/usb.h
77363 +++ b/include/linux/usb.h
77364 @@ -560,7 +560,7 @@ struct usb_device {
77365 int maxchild;
77366
77367 u32 quirks;
77368 - atomic_t urbnum;
77369 + atomic_unchecked_t urbnum;
77370
77371 unsigned long active_duration;
77372
77373 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77374
77375 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77376 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77377 - void *data, __u16 size, int timeout);
77378 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77379 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77380 void *data, int len, int *actual_length, int timeout);
77381 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77382 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77383 index e452ba6..78f8e80 100644
77384 --- a/include/linux/usb/renesas_usbhs.h
77385 +++ b/include/linux/usb/renesas_usbhs.h
77386 @@ -39,7 +39,7 @@ enum {
77387 */
77388 struct renesas_usbhs_driver_callback {
77389 int (*notify_hotplug)(struct platform_device *pdev);
77390 -};
77391 +} __no_const;
77392
77393 /*
77394 * callback functions for platform
77395 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77396 index 6f8fbcf..8259001 100644
77397 --- a/include/linux/vermagic.h
77398 +++ b/include/linux/vermagic.h
77399 @@ -25,9 +25,35 @@
77400 #define MODULE_ARCH_VERMAGIC ""
77401 #endif
77402
77403 +#ifdef CONFIG_PAX_REFCOUNT
77404 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77405 +#else
77406 +#define MODULE_PAX_REFCOUNT ""
77407 +#endif
77408 +
77409 +#ifdef CONSTIFY_PLUGIN
77410 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77411 +#else
77412 +#define MODULE_CONSTIFY_PLUGIN ""
77413 +#endif
77414 +
77415 +#ifdef STACKLEAK_PLUGIN
77416 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77417 +#else
77418 +#define MODULE_STACKLEAK_PLUGIN ""
77419 +#endif
77420 +
77421 +#ifdef CONFIG_GRKERNSEC
77422 +#define MODULE_GRSEC "GRSEC "
77423 +#else
77424 +#define MODULE_GRSEC ""
77425 +#endif
77426 +
77427 #define VERMAGIC_STRING \
77428 UTS_RELEASE " " \
77429 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77430 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77431 - MODULE_ARCH_VERMAGIC
77432 + MODULE_ARCH_VERMAGIC \
77433 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77434 + MODULE_GRSEC
77435
77436 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77437 index 4b8a891..c20e936 100644
77438 --- a/include/linux/vmalloc.h
77439 +++ b/include/linux/vmalloc.h
77440 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77441 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77442 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77443 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77444 +
77445 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77446 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77447 +#endif
77448 +
77449 /* bits [20..32] reserved for arch specific ioremap internals */
77450
77451 /*
77452 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77453 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77454 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77455 unsigned long start, unsigned long end, gfp_t gfp_mask,
77456 - pgprot_t prot, int node, const void *caller);
77457 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77458 extern void vfree(const void *addr);
77459
77460 extern void *vmap(struct page **pages, unsigned int count,
77461 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77462 extern void free_vm_area(struct vm_struct *area);
77463
77464 /* for /dev/kmem */
77465 -extern long vread(char *buf, char *addr, unsigned long count);
77466 -extern long vwrite(char *buf, char *addr, unsigned long count);
77467 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77468 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77469
77470 /*
77471 * Internals. Dont't use..
77472 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77473 index c586679..f06b389 100644
77474 --- a/include/linux/vmstat.h
77475 +++ b/include/linux/vmstat.h
77476 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77477 /*
77478 * Zone based page accounting with per cpu differentials.
77479 */
77480 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77481 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77482
77483 static inline void zone_page_state_add(long x, struct zone *zone,
77484 enum zone_stat_item item)
77485 {
77486 - atomic_long_add(x, &zone->vm_stat[item]);
77487 - atomic_long_add(x, &vm_stat[item]);
77488 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77489 + atomic_long_add_unchecked(x, &vm_stat[item]);
77490 }
77491
77492 static inline unsigned long global_page_state(enum zone_stat_item item)
77493 {
77494 - long x = atomic_long_read(&vm_stat[item]);
77495 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77496 #ifdef CONFIG_SMP
77497 if (x < 0)
77498 x = 0;
77499 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77500 static inline unsigned long zone_page_state(struct zone *zone,
77501 enum zone_stat_item item)
77502 {
77503 - long x = atomic_long_read(&zone->vm_stat[item]);
77504 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77505 #ifdef CONFIG_SMP
77506 if (x < 0)
77507 x = 0;
77508 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77509 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77510 enum zone_stat_item item)
77511 {
77512 - long x = atomic_long_read(&zone->vm_stat[item]);
77513 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77514
77515 #ifdef CONFIG_SMP
77516 int cpu;
77517 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77518
77519 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77520 {
77521 - atomic_long_inc(&zone->vm_stat[item]);
77522 - atomic_long_inc(&vm_stat[item]);
77523 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77524 + atomic_long_inc_unchecked(&vm_stat[item]);
77525 }
77526
77527 static inline void __inc_zone_page_state(struct page *page,
77528 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77529
77530 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77531 {
77532 - atomic_long_dec(&zone->vm_stat[item]);
77533 - atomic_long_dec(&vm_stat[item]);
77534 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77535 + atomic_long_dec_unchecked(&vm_stat[item]);
77536 }
77537
77538 static inline void __dec_zone_page_state(struct page *page,
77539 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77540 index fdbafc6..49dfe4f 100644
77541 --- a/include/linux/xattr.h
77542 +++ b/include/linux/xattr.h
77543 @@ -28,7 +28,7 @@ struct xattr_handler {
77544 size_t size, int handler_flags);
77545 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77546 size_t size, int flags, int handler_flags);
77547 -};
77548 +} __do_const;
77549
77550 struct xattr {
77551 char *name;
77552 @@ -37,6 +37,9 @@ struct xattr {
77553 };
77554
77555 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77556 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77557 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77558 +#endif
77559 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77560 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77561 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77562 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77563 index 9c5a6b4..09c9438 100644
77564 --- a/include/linux/zlib.h
77565 +++ b/include/linux/zlib.h
77566 @@ -31,6 +31,7 @@
77567 #define _ZLIB_H
77568
77569 #include <linux/zconf.h>
77570 +#include <linux/compiler.h>
77571
77572 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77573 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77574 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77575
77576 /* basic functions */
77577
77578 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77579 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77580 /*
77581 Returns the number of bytes that needs to be allocated for a per-
77582 stream workspace with the specified parameters. A pointer to this
77583 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77584 index c768c9f..bdcaa5a 100644
77585 --- a/include/media/v4l2-dev.h
77586 +++ b/include/media/v4l2-dev.h
77587 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77588 int (*mmap) (struct file *, struct vm_area_struct *);
77589 int (*open) (struct file *);
77590 int (*release) (struct file *);
77591 -};
77592 +} __do_const;
77593
77594 /*
77595 * Newer version of video_device, handled by videodev2.c
77596 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77597 index c9b1593..a572459 100644
77598 --- a/include/media/v4l2-device.h
77599 +++ b/include/media/v4l2-device.h
77600 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77601 this function returns 0. If the name ends with a digit (e.g. cx18),
77602 then the name will be set to cx18-0 since cx180 looks really odd. */
77603 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77604 - atomic_t *instance);
77605 + atomic_unchecked_t *instance);
77606
77607 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77608 Since the parent disappears this ensures that v4l2_dev doesn't have an
77609 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77610 index d9fa68f..45c88d1 100644
77611 --- a/include/net/9p/transport.h
77612 +++ b/include/net/9p/transport.h
77613 @@ -63,7 +63,7 @@ struct p9_trans_module {
77614 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77615 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77616 char *, char *, int , int, int, int);
77617 -};
77618 +} __do_const;
77619
77620 void v9fs_register_trans(struct p9_trans_module *m);
77621 void v9fs_unregister_trans(struct p9_trans_module *m);
77622 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77623 index 1a966af..2767cf6 100644
77624 --- a/include/net/bluetooth/l2cap.h
77625 +++ b/include/net/bluetooth/l2cap.h
77626 @@ -551,7 +551,7 @@ struct l2cap_ops {
77627 void (*defer) (struct l2cap_chan *chan);
77628 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77629 unsigned long len, int nb);
77630 -};
77631 +} __do_const;
77632
77633 struct l2cap_conn {
77634 struct hci_conn *hcon;
77635 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77636 index f2ae33d..c457cf0 100644
77637 --- a/include/net/caif/cfctrl.h
77638 +++ b/include/net/caif/cfctrl.h
77639 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77640 void (*radioset_rsp)(void);
77641 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77642 struct cflayer *client_layer);
77643 -};
77644 +} __no_const;
77645
77646 /* Link Setup Parameters for CAIF-Links. */
77647 struct cfctrl_link_param {
77648 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77649 struct cfctrl {
77650 struct cfsrvl serv;
77651 struct cfctrl_rsp res;
77652 - atomic_t req_seq_no;
77653 - atomic_t rsp_seq_no;
77654 + atomic_unchecked_t req_seq_no;
77655 + atomic_unchecked_t rsp_seq_no;
77656 struct list_head list;
77657 /* Protects from simultaneous access to first_req list */
77658 spinlock_t info_list_lock;
77659 diff --git a/include/net/flow.h b/include/net/flow.h
77660 index 628e11b..4c475df 100644
77661 --- a/include/net/flow.h
77662 +++ b/include/net/flow.h
77663 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77664
77665 extern void flow_cache_flush(void);
77666 extern void flow_cache_flush_deferred(void);
77667 -extern atomic_t flow_cache_genid;
77668 +extern atomic_unchecked_t flow_cache_genid;
77669
77670 #endif
77671 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77672 index 8e0b6c8..73cf605 100644
77673 --- a/include/net/genetlink.h
77674 +++ b/include/net/genetlink.h
77675 @@ -120,7 +120,7 @@ struct genl_ops {
77676 struct netlink_callback *cb);
77677 int (*done)(struct netlink_callback *cb);
77678 struct list_head ops_list;
77679 -};
77680 +} __do_const;
77681
77682 extern int __genl_register_family(struct genl_family *family);
77683
77684 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77685 index 734d9b5..48a9a4b 100644
77686 --- a/include/net/gro_cells.h
77687 +++ b/include/net/gro_cells.h
77688 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77689 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77690
77691 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77692 - atomic_long_inc(&dev->rx_dropped);
77693 + atomic_long_inc_unchecked(&dev->rx_dropped);
77694 kfree_skb(skb);
77695 return;
77696 }
77697 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77698 index de2c785..0588a6b 100644
77699 --- a/include/net/inet_connection_sock.h
77700 +++ b/include/net/inet_connection_sock.h
77701 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77702 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77703 int (*bind_conflict)(const struct sock *sk,
77704 const struct inet_bind_bucket *tb, bool relax);
77705 -};
77706 +} __do_const;
77707
77708 /** inet_connection_sock - INET connection oriented sock
77709 *
77710 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77711 index 53f464d..0bd0b49 100644
77712 --- a/include/net/inetpeer.h
77713 +++ b/include/net/inetpeer.h
77714 @@ -47,8 +47,8 @@ struct inet_peer {
77715 */
77716 union {
77717 struct {
77718 - atomic_t rid; /* Frag reception counter */
77719 - atomic_t ip_id_count; /* IP ID for the next packet */
77720 + atomic_unchecked_t rid; /* Frag reception counter */
77721 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77722 };
77723 struct rcu_head rcu;
77724 struct inet_peer *gc_next;
77725 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77726 /* can be called with or without local BH being disabled */
77727 static inline int inet_getid(struct inet_peer *p, int more)
77728 {
77729 - int old, new;
77730 + int id;
77731 more++;
77732 inet_peer_refcheck(p);
77733 - do {
77734 - old = atomic_read(&p->ip_id_count);
77735 - new = old + more;
77736 - if (!new)
77737 - new = 1;
77738 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77739 - return new;
77740 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77741 + if (!id)
77742 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77743 + return id;
77744 }
77745
77746 #endif /* _NET_INETPEER_H */
77747 diff --git a/include/net/ip.h b/include/net/ip.h
77748 index a68f838..74518ab 100644
77749 --- a/include/net/ip.h
77750 +++ b/include/net/ip.h
77751 @@ -202,7 +202,7 @@ extern struct local_ports {
77752 } sysctl_local_ports;
77753 extern void inet_get_local_port_range(int *low, int *high);
77754
77755 -extern unsigned long *sysctl_local_reserved_ports;
77756 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77757 static inline int inet_is_reserved_local_port(int port)
77758 {
77759 return test_bit(port, sysctl_local_reserved_ports);
77760 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77761 index cbf2be3..3683f6d 100644
77762 --- a/include/net/ip_fib.h
77763 +++ b/include/net/ip_fib.h
77764 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77765
77766 #define FIB_RES_SADDR(net, res) \
77767 ((FIB_RES_NH(res).nh_saddr_genid == \
77768 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77769 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77770 FIB_RES_NH(res).nh_saddr : \
77771 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77772 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77773 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77774 index f0d70f0..185f15b 100644
77775 --- a/include/net/ip_vs.h
77776 +++ b/include/net/ip_vs.h
77777 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77778 struct ip_vs_conn *control; /* Master control connection */
77779 atomic_t n_control; /* Number of controlled ones */
77780 struct ip_vs_dest *dest; /* real server */
77781 - atomic_t in_pkts; /* incoming packet counter */
77782 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77783
77784 /* packet transmitter for different forwarding methods. If it
77785 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77786 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77787 __be16 port; /* port number of the server */
77788 union nf_inet_addr addr; /* IP address of the server */
77789 volatile unsigned int flags; /* dest status flags */
77790 - atomic_t conn_flags; /* flags to copy to conn */
77791 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77792 atomic_t weight; /* server weight */
77793
77794 atomic_t refcnt; /* reference counter */
77795 @@ -993,11 +993,11 @@ struct netns_ipvs {
77796 /* ip_vs_lblc */
77797 int sysctl_lblc_expiration;
77798 struct ctl_table_header *lblc_ctl_header;
77799 - struct ctl_table *lblc_ctl_table;
77800 + ctl_table_no_const *lblc_ctl_table;
77801 /* ip_vs_lblcr */
77802 int sysctl_lblcr_expiration;
77803 struct ctl_table_header *lblcr_ctl_header;
77804 - struct ctl_table *lblcr_ctl_table;
77805 + ctl_table_no_const *lblcr_ctl_table;
77806 /* ip_vs_est */
77807 struct list_head est_list; /* estimator list */
77808 spinlock_t est_lock;
77809 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77810 index 80ffde3..968b0f4 100644
77811 --- a/include/net/irda/ircomm_tty.h
77812 +++ b/include/net/irda/ircomm_tty.h
77813 @@ -35,6 +35,7 @@
77814 #include <linux/termios.h>
77815 #include <linux/timer.h>
77816 #include <linux/tty.h> /* struct tty_struct */
77817 +#include <asm/local.h>
77818
77819 #include <net/irda/irias_object.h>
77820 #include <net/irda/ircomm_core.h>
77821 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77822 index 714cc9a..ea05f3e 100644
77823 --- a/include/net/iucv/af_iucv.h
77824 +++ b/include/net/iucv/af_iucv.h
77825 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77826 struct iucv_sock_list {
77827 struct hlist_head head;
77828 rwlock_t lock;
77829 - atomic_t autobind_name;
77830 + atomic_unchecked_t autobind_name;
77831 };
77832
77833 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77834 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77835 index df83f69..9b640b8 100644
77836 --- a/include/net/llc_c_ac.h
77837 +++ b/include/net/llc_c_ac.h
77838 @@ -87,7 +87,7 @@
77839 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77840 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77841
77842 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77843 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77844
77845 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77846 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77847 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77848 index 6ca3113..f8026dd 100644
77849 --- a/include/net/llc_c_ev.h
77850 +++ b/include/net/llc_c_ev.h
77851 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77852 return (struct llc_conn_state_ev *)skb->cb;
77853 }
77854
77855 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77856 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77857 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77858 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77859
77860 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77861 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77862 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77863 index 0e79cfb..f46db31 100644
77864 --- a/include/net/llc_c_st.h
77865 +++ b/include/net/llc_c_st.h
77866 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77867 u8 next_state;
77868 llc_conn_ev_qfyr_t *ev_qualifiers;
77869 llc_conn_action_t *ev_actions;
77870 -};
77871 +} __do_const;
77872
77873 struct llc_conn_state {
77874 u8 current_state;
77875 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
77876 index 37a3bbd..55a4241 100644
77877 --- a/include/net/llc_s_ac.h
77878 +++ b/include/net/llc_s_ac.h
77879 @@ -23,7 +23,7 @@
77880 #define SAP_ACT_TEST_IND 9
77881
77882 /* All action functions must look like this */
77883 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77884 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77885
77886 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
77887 struct sk_buff *skb);
77888 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
77889 index 567c681..cd73ac0 100644
77890 --- a/include/net/llc_s_st.h
77891 +++ b/include/net/llc_s_st.h
77892 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
77893 llc_sap_ev_t ev;
77894 u8 next_state;
77895 llc_sap_action_t *ev_actions;
77896 -};
77897 +} __do_const;
77898
77899 struct llc_sap_state {
77900 u8 curr_state;
77901 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
77902 index 551ba6a..11c99c1 100644
77903 --- a/include/net/mac80211.h
77904 +++ b/include/net/mac80211.h
77905 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
77906 void (*add_sta_debugfs)(void *priv, void *priv_sta,
77907 struct dentry *dir);
77908 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
77909 -};
77910 +} __do_const;
77911
77912 static inline int rate_supported(struct ieee80211_sta *sta,
77913 enum ieee80211_band band,
77914 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
77915 index 7e748ad..5c6229b 100644
77916 --- a/include/net/neighbour.h
77917 +++ b/include/net/neighbour.h
77918 @@ -123,7 +123,7 @@ struct neigh_ops {
77919 void (*error_report)(struct neighbour *, struct sk_buff *);
77920 int (*output)(struct neighbour *, struct sk_buff *);
77921 int (*connected_output)(struct neighbour *, struct sk_buff *);
77922 -};
77923 +} __do_const;
77924
77925 struct pneigh_entry {
77926 struct pneigh_entry *next;
77927 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
77928 index 84e37b1..8eba19a 100644
77929 --- a/include/net/net_namespace.h
77930 +++ b/include/net/net_namespace.h
77931 @@ -119,8 +119,8 @@ struct net {
77932 struct netns_ipvs *ipvs;
77933 #endif
77934 struct sock *diag_nlsk;
77935 - atomic_t rt_genid;
77936 - atomic_t fnhe_genid;
77937 + atomic_unchecked_t rt_genid;
77938 + atomic_unchecked_t fnhe_genid;
77939 };
77940
77941 /*
77942 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
77943 #define __net_init __init
77944 #define __net_exit __exit_refok
77945 #define __net_initdata __initdata
77946 +#ifdef CONSTIFY_PLUGIN
77947 #define __net_initconst __initconst
77948 +#else
77949 +#define __net_initconst __initdata
77950 +#endif
77951 #endif
77952
77953 struct pernet_operations {
77954 @@ -287,7 +291,7 @@ struct pernet_operations {
77955 void (*exit_batch)(struct list_head *net_exit_list);
77956 int *id;
77957 size_t size;
77958 -};
77959 +} __do_const;
77960
77961 /*
77962 * Use these carefully. If you implement a network device and it
77963 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
77964
77965 static inline int rt_genid(struct net *net)
77966 {
77967 - return atomic_read(&net->rt_genid);
77968 + return atomic_read_unchecked(&net->rt_genid);
77969 }
77970
77971 static inline void rt_genid_bump(struct net *net)
77972 {
77973 - atomic_inc(&net->rt_genid);
77974 + atomic_inc_unchecked(&net->rt_genid);
77975 }
77976
77977 static inline int fnhe_genid(struct net *net)
77978 {
77979 - return atomic_read(&net->fnhe_genid);
77980 + return atomic_read_unchecked(&net->fnhe_genid);
77981 }
77982
77983 static inline void fnhe_genid_bump(struct net *net)
77984 {
77985 - atomic_inc(&net->fnhe_genid);
77986 + atomic_inc_unchecked(&net->fnhe_genid);
77987 }
77988
77989 #endif /* __NET_NET_NAMESPACE_H */
77990 diff --git a/include/net/netdma.h b/include/net/netdma.h
77991 index 8ba8ce2..99b7fff 100644
77992 --- a/include/net/netdma.h
77993 +++ b/include/net/netdma.h
77994 @@ -24,7 +24,7 @@
77995 #include <linux/dmaengine.h>
77996 #include <linux/skbuff.h>
77997
77998 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77999 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78000 struct sk_buff *skb, int offset, struct iovec *to,
78001 size_t len, struct dma_pinned_list *pinned_list);
78002
78003 diff --git a/include/net/netlink.h b/include/net/netlink.h
78004 index 9690b0f..87aded7 100644
78005 --- a/include/net/netlink.h
78006 +++ b/include/net/netlink.h
78007 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78008 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78009 {
78010 if (mark)
78011 - skb_trim(skb, (unsigned char *) mark - skb->data);
78012 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78013 }
78014
78015 /**
78016 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78017 index c9c0c53..53f24c3 100644
78018 --- a/include/net/netns/conntrack.h
78019 +++ b/include/net/netns/conntrack.h
78020 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78021 struct nf_proto_net {
78022 #ifdef CONFIG_SYSCTL
78023 struct ctl_table_header *ctl_table_header;
78024 - struct ctl_table *ctl_table;
78025 + ctl_table_no_const *ctl_table;
78026 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78027 struct ctl_table_header *ctl_compat_header;
78028 - struct ctl_table *ctl_compat_table;
78029 + ctl_table_no_const *ctl_compat_table;
78030 #endif
78031 #endif
78032 unsigned int users;
78033 @@ -58,7 +58,7 @@ struct nf_ip_net {
78034 struct nf_icmp_net icmpv6;
78035 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78036 struct ctl_table_header *ctl_table_header;
78037 - struct ctl_table *ctl_table;
78038 + ctl_table_no_const *ctl_table;
78039 #endif
78040 };
78041
78042 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78043 index 2ba9de8..47bd6c7 100644
78044 --- a/include/net/netns/ipv4.h
78045 +++ b/include/net/netns/ipv4.h
78046 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78047 kgid_t sysctl_ping_group_range[2];
78048 long sysctl_tcp_mem[3];
78049
78050 - atomic_t dev_addr_genid;
78051 + atomic_unchecked_t dev_addr_genid;
78052
78053 #ifdef CONFIG_IP_MROUTE
78054 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78055 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78056 index 005e2c2..023d340 100644
78057 --- a/include/net/netns/ipv6.h
78058 +++ b/include/net/netns/ipv6.h
78059 @@ -71,7 +71,7 @@ struct netns_ipv6 {
78060 struct fib_rules_ops *mr6_rules_ops;
78061 #endif
78062 #endif
78063 - atomic_t dev_addr_genid;
78064 + atomic_unchecked_t dev_addr_genid;
78065 };
78066
78067 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78068 diff --git a/include/net/ping.h b/include/net/ping.h
78069 index 5db0224..0d65365 100644
78070 --- a/include/net/ping.h
78071 +++ b/include/net/ping.h
78072 @@ -55,7 +55,7 @@ struct ping_iter_state {
78073 extern struct proto ping_prot;
78074 extern struct ping_table ping_table;
78075 #if IS_ENABLED(CONFIG_IPV6)
78076 -extern struct pingv6_ops pingv6_ops;
78077 +extern struct pingv6_ops *pingv6_ops;
78078 #endif
78079
78080 struct pingfakehdr {
78081 diff --git a/include/net/protocol.h b/include/net/protocol.h
78082 index 047c047..b9dad15 100644
78083 --- a/include/net/protocol.h
78084 +++ b/include/net/protocol.h
78085 @@ -44,7 +44,7 @@ struct net_protocol {
78086 void (*err_handler)(struct sk_buff *skb, u32 info);
78087 unsigned int no_policy:1,
78088 netns_ok:1;
78089 -};
78090 +} __do_const;
78091
78092 #if IS_ENABLED(CONFIG_IPV6)
78093 struct inet6_protocol {
78094 @@ -57,7 +57,7 @@ struct inet6_protocol {
78095 u8 type, u8 code, int offset,
78096 __be32 info);
78097 unsigned int flags; /* INET6_PROTO_xxx */
78098 -};
78099 +} __do_const;
78100
78101 #define INET6_PROTO_NOPOLICY 0x1
78102 #define INET6_PROTO_FINAL 0x2
78103 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
78104 index 7026648..584cc8c 100644
78105 --- a/include/net/rtnetlink.h
78106 +++ b/include/net/rtnetlink.h
78107 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
78108 const struct net_device *dev);
78109 unsigned int (*get_num_tx_queues)(void);
78110 unsigned int (*get_num_rx_queues)(void);
78111 -};
78112 +} __do_const;
78113
78114 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
78115 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78116 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
78117 index 2a82d13..62a31c2 100644
78118 --- a/include/net/sctp/sm.h
78119 +++ b/include/net/sctp/sm.h
78120 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
78121 typedef struct {
78122 sctp_state_fn_t *fn;
78123 const char *name;
78124 -} sctp_sm_table_entry_t;
78125 +} __do_const sctp_sm_table_entry_t;
78126
78127 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
78128 * currently in use.
78129 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
78130 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
78131
78132 /* Extern declarations for major data structures. */
78133 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78134 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78135
78136
78137 /* Get the size of a DATA chunk payload. */
78138 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
78139 index e745c92..3641448 100644
78140 --- a/include/net/sctp/structs.h
78141 +++ b/include/net/sctp/structs.h
78142 @@ -516,7 +516,7 @@ struct sctp_pf {
78143 struct sctp_association *asoc);
78144 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
78145 struct sctp_af *af;
78146 -};
78147 +} __do_const;
78148
78149
78150 /* Structure to track chunk fragments that have been acked, but peer
78151 diff --git a/include/net/sock.h b/include/net/sock.h
78152 index 31d5cfb..9ee0602 100644
78153 --- a/include/net/sock.h
78154 +++ b/include/net/sock.h
78155 @@ -331,7 +331,7 @@ struct sock {
78156 unsigned int sk_napi_id;
78157 unsigned int sk_ll_usec;
78158 #endif
78159 - atomic_t sk_drops;
78160 + atomic_unchecked_t sk_drops;
78161 int sk_rcvbuf;
78162
78163 struct sk_filter __rcu *sk_filter;
78164 @@ -1803,7 +1803,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
78165 }
78166
78167 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
78168 - char __user *from, char *to,
78169 + char __user *from, unsigned char *to,
78170 int copy, int offset)
78171 {
78172 if (skb->ip_summed == CHECKSUM_NONE) {
78173 @@ -2065,7 +2065,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
78174 }
78175 }
78176
78177 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78178 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78179
78180 /**
78181 * sk_page_frag - return an appropriate page_frag
78182 diff --git a/include/net/tcp.h b/include/net/tcp.h
78183 index d198005..c974a393 100644
78184 --- a/include/net/tcp.h
78185 +++ b/include/net/tcp.h
78186 @@ -521,7 +521,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
78187 extern void tcp_xmit_retransmit_queue(struct sock *);
78188 extern void tcp_simple_retransmit(struct sock *);
78189 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
78190 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78191 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78192
78193 extern void tcp_send_probe0(struct sock *);
78194 extern void tcp_send_partial(struct sock *);
78195 @@ -694,8 +694,8 @@ struct tcp_skb_cb {
78196 struct inet6_skb_parm h6;
78197 #endif
78198 } header; /* For incoming frames */
78199 - __u32 seq; /* Starting sequence number */
78200 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
78201 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
78202 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
78203 __u32 when; /* used to compute rtt's */
78204 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
78205
78206 @@ -709,7 +709,7 @@ struct tcp_skb_cb {
78207
78208 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
78209 /* 1 byte hole */
78210 - __u32 ack_seq; /* Sequence number ACK'd */
78211 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
78212 };
78213
78214 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
78215 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78216 index e823786..53b0608 100644
78217 --- a/include/net/xfrm.h
78218 +++ b/include/net/xfrm.h
78219 @@ -287,7 +287,6 @@ struct xfrm_dst;
78220 struct xfrm_policy_afinfo {
78221 unsigned short family;
78222 struct dst_ops *dst_ops;
78223 - void (*garbage_collect)(struct net *net);
78224 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78225 const xfrm_address_t *saddr,
78226 const xfrm_address_t *daddr);
78227 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78228 struct net_device *dev,
78229 const struct flowi *fl);
78230 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78231 -};
78232 +} __do_const;
78233
78234 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78235 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78236 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78237 int (*transport_finish)(struct sk_buff *skb,
78238 int async);
78239 void (*local_error)(struct sk_buff *skb, u32 mtu);
78240 -};
78241 +} __do_const;
78242
78243 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78244 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78245 @@ -427,7 +426,7 @@ struct xfrm_mode {
78246 struct module *owner;
78247 unsigned int encap;
78248 int flags;
78249 -};
78250 +} __do_const;
78251
78252 /* Flags for xfrm_mode. */
78253 enum {
78254 @@ -524,7 +523,7 @@ struct xfrm_policy {
78255 struct timer_list timer;
78256
78257 struct flow_cache_object flo;
78258 - atomic_t genid;
78259 + atomic_unchecked_t genid;
78260 u32 priority;
78261 u32 index;
78262 struct xfrm_mark mark;
78263 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78264 }
78265
78266 extern void xfrm_garbage_collect(struct net *net);
78267 +extern void xfrm_garbage_collect_deferred(struct net *net);
78268
78269 #else
78270
78271 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78272 static inline void xfrm_garbage_collect(struct net *net)
78273 {
78274 }
78275 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78276 +{
78277 +}
78278 #endif
78279
78280 static __inline__
78281 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78282 index 1a046b1..ee0bef0 100644
78283 --- a/include/rdma/iw_cm.h
78284 +++ b/include/rdma/iw_cm.h
78285 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78286 int backlog);
78287
78288 int (*destroy_listen)(struct iw_cm_id *cm_id);
78289 -};
78290 +} __no_const;
78291
78292 /**
78293 * iw_create_cm_id - Create an IW CM identifier.
78294 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78295 index e1379b4..67eafbe 100644
78296 --- a/include/scsi/libfc.h
78297 +++ b/include/scsi/libfc.h
78298 @@ -762,6 +762,7 @@ struct libfc_function_template {
78299 */
78300 void (*disc_stop_final) (struct fc_lport *);
78301 };
78302 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78303
78304 /**
78305 * struct fc_disc - Discovery context
78306 @@ -866,7 +867,7 @@ struct fc_lport {
78307 struct fc_vport *vport;
78308
78309 /* Operational Information */
78310 - struct libfc_function_template tt;
78311 + libfc_function_template_no_const tt;
78312 u8 link_up;
78313 u8 qfull;
78314 enum fc_lport_state state;
78315 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78316 index a44954c..5da04b2 100644
78317 --- a/include/scsi/scsi_device.h
78318 +++ b/include/scsi/scsi_device.h
78319 @@ -172,9 +172,9 @@ struct scsi_device {
78320 unsigned int max_device_blocked; /* what device_blocked counts down from */
78321 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78322
78323 - atomic_t iorequest_cnt;
78324 - atomic_t iodone_cnt;
78325 - atomic_t ioerr_cnt;
78326 + atomic_unchecked_t iorequest_cnt;
78327 + atomic_unchecked_t iodone_cnt;
78328 + atomic_unchecked_t ioerr_cnt;
78329
78330 struct device sdev_gendev,
78331 sdev_dev;
78332 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78333 index b797e8f..8e2c3aa 100644
78334 --- a/include/scsi/scsi_transport_fc.h
78335 +++ b/include/scsi/scsi_transport_fc.h
78336 @@ -751,7 +751,8 @@ struct fc_function_template {
78337 unsigned long show_host_system_hostname:1;
78338
78339 unsigned long disable_target_scan:1;
78340 -};
78341 +} __do_const;
78342 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78343
78344
78345 /**
78346 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78347 index 9031a26..750d592 100644
78348 --- a/include/sound/compress_driver.h
78349 +++ b/include/sound/compress_driver.h
78350 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78351 struct snd_compr_caps *caps);
78352 int (*get_codec_caps) (struct snd_compr_stream *stream,
78353 struct snd_compr_codec_caps *codec);
78354 -};
78355 +} __no_const;
78356
78357 /**
78358 * struct snd_compr: Compressed device
78359 diff --git a/include/sound/soc.h b/include/sound/soc.h
78360 index 6eabee7..58afb50 100644
78361 --- a/include/sound/soc.h
78362 +++ b/include/sound/soc.h
78363 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78364 /* probe ordering - for components with runtime dependencies */
78365 int probe_order;
78366 int remove_order;
78367 -};
78368 +} __do_const;
78369
78370 /* SoC platform interface */
78371 struct snd_soc_platform_driver {
78372 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78373 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78374 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78375 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78376 -};
78377 +} __do_const;
78378
78379 struct snd_soc_platform {
78380 const char *name;
78381 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78382 index e34fc90..ecefa2c 100644
78383 --- a/include/target/target_core_base.h
78384 +++ b/include/target/target_core_base.h
78385 @@ -643,7 +643,7 @@ struct se_device {
78386 spinlock_t stats_lock;
78387 /* Active commands on this virtual SE device */
78388 atomic_t simple_cmds;
78389 - atomic_t dev_ordered_id;
78390 + atomic_unchecked_t dev_ordered_id;
78391 atomic_t dev_ordered_sync;
78392 atomic_t dev_qf_count;
78393 int export_count;
78394 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78395 new file mode 100644
78396 index 0000000..fb634b7
78397 --- /dev/null
78398 +++ b/include/trace/events/fs.h
78399 @@ -0,0 +1,53 @@
78400 +#undef TRACE_SYSTEM
78401 +#define TRACE_SYSTEM fs
78402 +
78403 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78404 +#define _TRACE_FS_H
78405 +
78406 +#include <linux/fs.h>
78407 +#include <linux/tracepoint.h>
78408 +
78409 +TRACE_EVENT(do_sys_open,
78410 +
78411 + TP_PROTO(const char *filename, int flags, int mode),
78412 +
78413 + TP_ARGS(filename, flags, mode),
78414 +
78415 + TP_STRUCT__entry(
78416 + __string( filename, filename )
78417 + __field( int, flags )
78418 + __field( int, mode )
78419 + ),
78420 +
78421 + TP_fast_assign(
78422 + __assign_str(filename, filename);
78423 + __entry->flags = flags;
78424 + __entry->mode = mode;
78425 + ),
78426 +
78427 + TP_printk("\"%s\" %x %o",
78428 + __get_str(filename), __entry->flags, __entry->mode)
78429 +);
78430 +
78431 +TRACE_EVENT(open_exec,
78432 +
78433 + TP_PROTO(const char *filename),
78434 +
78435 + TP_ARGS(filename),
78436 +
78437 + TP_STRUCT__entry(
78438 + __string( filename, filename )
78439 + ),
78440 +
78441 + TP_fast_assign(
78442 + __assign_str(filename, filename);
78443 + ),
78444 +
78445 + TP_printk("\"%s\"",
78446 + __get_str(filename))
78447 +);
78448 +
78449 +#endif /* _TRACE_FS_H */
78450 +
78451 +/* This part must be outside protection */
78452 +#include <trace/define_trace.h>
78453 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78454 index 1c09820..7f5ec79 100644
78455 --- a/include/trace/events/irq.h
78456 +++ b/include/trace/events/irq.h
78457 @@ -36,7 +36,7 @@ struct softirq_action;
78458 */
78459 TRACE_EVENT(irq_handler_entry,
78460
78461 - TP_PROTO(int irq, struct irqaction *action),
78462 + TP_PROTO(int irq, const struct irqaction *action),
78463
78464 TP_ARGS(irq, action),
78465
78466 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78467 */
78468 TRACE_EVENT(irq_handler_exit,
78469
78470 - TP_PROTO(int irq, struct irqaction *action, int ret),
78471 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78472
78473 TP_ARGS(irq, action, ret),
78474
78475 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78476 index 7caf44c..23c6f27 100644
78477 --- a/include/uapi/linux/a.out.h
78478 +++ b/include/uapi/linux/a.out.h
78479 @@ -39,6 +39,14 @@ enum machine_type {
78480 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78481 };
78482
78483 +/* Constants for the N_FLAGS field */
78484 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78485 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78486 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78487 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78488 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78489 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78490 +
78491 #if !defined (N_MAGIC)
78492 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78493 #endif
78494 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78495 index d876736..ccce5c0 100644
78496 --- a/include/uapi/linux/byteorder/little_endian.h
78497 +++ b/include/uapi/linux/byteorder/little_endian.h
78498 @@ -42,51 +42,51 @@
78499
78500 static inline __le64 __cpu_to_le64p(const __u64 *p)
78501 {
78502 - return (__force __le64)*p;
78503 + return (__force const __le64)*p;
78504 }
78505 -static inline __u64 __le64_to_cpup(const __le64 *p)
78506 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78507 {
78508 - return (__force __u64)*p;
78509 + return (__force const __u64)*p;
78510 }
78511 static inline __le32 __cpu_to_le32p(const __u32 *p)
78512 {
78513 - return (__force __le32)*p;
78514 + return (__force const __le32)*p;
78515 }
78516 static inline __u32 __le32_to_cpup(const __le32 *p)
78517 {
78518 - return (__force __u32)*p;
78519 + return (__force const __u32)*p;
78520 }
78521 static inline __le16 __cpu_to_le16p(const __u16 *p)
78522 {
78523 - return (__force __le16)*p;
78524 + return (__force const __le16)*p;
78525 }
78526 static inline __u16 __le16_to_cpup(const __le16 *p)
78527 {
78528 - return (__force __u16)*p;
78529 + return (__force const __u16)*p;
78530 }
78531 static inline __be64 __cpu_to_be64p(const __u64 *p)
78532 {
78533 - return (__force __be64)__swab64p(p);
78534 + return (__force const __be64)__swab64p(p);
78535 }
78536 static inline __u64 __be64_to_cpup(const __be64 *p)
78537 {
78538 - return __swab64p((__u64 *)p);
78539 + return __swab64p((const __u64 *)p);
78540 }
78541 static inline __be32 __cpu_to_be32p(const __u32 *p)
78542 {
78543 - return (__force __be32)__swab32p(p);
78544 + return (__force const __be32)__swab32p(p);
78545 }
78546 -static inline __u32 __be32_to_cpup(const __be32 *p)
78547 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78548 {
78549 - return __swab32p((__u32 *)p);
78550 + return __swab32p((const __u32 *)p);
78551 }
78552 static inline __be16 __cpu_to_be16p(const __u16 *p)
78553 {
78554 - return (__force __be16)__swab16p(p);
78555 + return (__force const __be16)__swab16p(p);
78556 }
78557 static inline __u16 __be16_to_cpup(const __be16 *p)
78558 {
78559 - return __swab16p((__u16 *)p);
78560 + return __swab16p((const __u16 *)p);
78561 }
78562 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78563 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78564 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78565 index ef6103b..d4e65dd 100644
78566 --- a/include/uapi/linux/elf.h
78567 +++ b/include/uapi/linux/elf.h
78568 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78569 #define PT_GNU_EH_FRAME 0x6474e550
78570
78571 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78572 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78573 +
78574 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78575 +
78576 +/* Constants for the e_flags field */
78577 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78578 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78579 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78580 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78581 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78582 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78583
78584 /*
78585 * Extended Numbering
78586 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78587 #define DT_DEBUG 21
78588 #define DT_TEXTREL 22
78589 #define DT_JMPREL 23
78590 +#define DT_FLAGS 30
78591 + #define DF_TEXTREL 0x00000004
78592 #define DT_ENCODING 32
78593 #define OLD_DT_LOOS 0x60000000
78594 #define DT_LOOS 0x6000000d
78595 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78596 #define PF_W 0x2
78597 #define PF_X 0x1
78598
78599 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78600 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78601 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78602 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78603 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78604 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78605 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78606 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78607 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78608 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78609 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78610 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78611 +
78612 typedef struct elf32_phdr{
78613 Elf32_Word p_type;
78614 Elf32_Off p_offset;
78615 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78616 #define EI_OSABI 7
78617 #define EI_PAD 8
78618
78619 +#define EI_PAX 14
78620 +
78621 #define ELFMAG0 0x7f /* EI_MAG */
78622 #define ELFMAG1 'E'
78623 #define ELFMAG2 'L'
78624 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78625 index aa169c4..6a2771d 100644
78626 --- a/include/uapi/linux/personality.h
78627 +++ b/include/uapi/linux/personality.h
78628 @@ -30,6 +30,7 @@ enum {
78629 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78630 ADDR_NO_RANDOMIZE | \
78631 ADDR_COMPAT_LAYOUT | \
78632 + ADDR_LIMIT_3GB | \
78633 MMAP_PAGE_ZERO)
78634
78635 /*
78636 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78637 index 7530e74..e714828 100644
78638 --- a/include/uapi/linux/screen_info.h
78639 +++ b/include/uapi/linux/screen_info.h
78640 @@ -43,7 +43,8 @@ struct screen_info {
78641 __u16 pages; /* 0x32 */
78642 __u16 vesa_attributes; /* 0x34 */
78643 __u32 capabilities; /* 0x36 */
78644 - __u8 _reserved[6]; /* 0x3a */
78645 + __u16 vesapm_size; /* 0x3a */
78646 + __u8 _reserved[4]; /* 0x3c */
78647 } __attribute__((packed));
78648
78649 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78650 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78651 index 0e011eb..82681b1 100644
78652 --- a/include/uapi/linux/swab.h
78653 +++ b/include/uapi/linux/swab.h
78654 @@ -43,7 +43,7 @@
78655 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78656 */
78657
78658 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78659 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78660 {
78661 #ifdef __HAVE_BUILTIN_BSWAP16__
78662 return __builtin_bswap16(val);
78663 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78664 #endif
78665 }
78666
78667 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78668 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78669 {
78670 #ifdef __HAVE_BUILTIN_BSWAP32__
78671 return __builtin_bswap32(val);
78672 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78673 #endif
78674 }
78675
78676 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78677 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78678 {
78679 #ifdef __HAVE_BUILTIN_BSWAP64__
78680 return __builtin_bswap64(val);
78681 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78682 index 6d67213..8dab561 100644
78683 --- a/include/uapi/linux/sysctl.h
78684 +++ b/include/uapi/linux/sysctl.h
78685 @@ -155,7 +155,11 @@ enum
78686 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78687 };
78688
78689 -
78690 +#ifdef CONFIG_PAX_SOFTMODE
78691 +enum {
78692 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78693 +};
78694 +#endif
78695
78696 /* CTL_VM names: */
78697 enum
78698 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78699 index e4629b9..6958086 100644
78700 --- a/include/uapi/linux/xattr.h
78701 +++ b/include/uapi/linux/xattr.h
78702 @@ -63,5 +63,9 @@
78703 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78704 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78705
78706 +/* User namespace */
78707 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78708 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78709 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78710
78711 #endif /* _UAPI_LINUX_XATTR_H */
78712 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78713 index f9466fa..f4e2b81 100644
78714 --- a/include/video/udlfb.h
78715 +++ b/include/video/udlfb.h
78716 @@ -53,10 +53,10 @@ struct dlfb_data {
78717 u32 pseudo_palette[256];
78718 int blank_mode; /*one of FB_BLANK_ */
78719 /* blit-only rendering path metrics, exposed through sysfs */
78720 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78721 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78722 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78723 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78724 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78725 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78726 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78727 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78728 };
78729
78730 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78731 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78732 index 30f5362..8ed8ac9 100644
78733 --- a/include/video/uvesafb.h
78734 +++ b/include/video/uvesafb.h
78735 @@ -122,6 +122,7 @@ struct uvesafb_par {
78736 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78737 u8 pmi_setpal; /* PMI for palette changes */
78738 u16 *pmi_base; /* protected mode interface location */
78739 + u8 *pmi_code; /* protected mode code location */
78740 void *pmi_start;
78741 void *pmi_pal;
78742 u8 *vbe_state_orig; /*
78743 diff --git a/init/Kconfig b/init/Kconfig
78744 index fed81b5..0d3b964 100644
78745 --- a/init/Kconfig
78746 +++ b/init/Kconfig
78747 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78748
78749 config CHECKPOINT_RESTORE
78750 bool "Checkpoint/restore support" if EXPERT
78751 + depends on !GRKERNSEC
78752 default n
78753 help
78754 Enables additional kernel features in a sake of checkpoint/restore.
78755 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78756
78757 config COMPAT_BRK
78758 bool "Disable heap randomization"
78759 - default y
78760 + default n
78761 help
78762 Randomizing heap placement makes heap exploits harder, but it
78763 also breaks ancient binaries (including anything libc5 based).
78764 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78765 config STOP_MACHINE
78766 bool
78767 default y
78768 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78769 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78770 help
78771 Need stop_machine() primitive.
78772
78773 diff --git a/init/Makefile b/init/Makefile
78774 index 7bc47ee..6da2dc7 100644
78775 --- a/init/Makefile
78776 +++ b/init/Makefile
78777 @@ -2,6 +2,9 @@
78778 # Makefile for the linux kernel.
78779 #
78780
78781 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78782 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78783 +
78784 obj-y := main.o version.o mounts.o
78785 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78786 obj-y += noinitramfs.o
78787 diff --git a/init/do_mounts.c b/init/do_mounts.c
78788 index 816014c..c2054db 100644
78789 --- a/init/do_mounts.c
78790 +++ b/init/do_mounts.c
78791 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78792 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78793 {
78794 struct super_block *s;
78795 - int err = sys_mount(name, "/root", fs, flags, data);
78796 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78797 if (err)
78798 return err;
78799
78800 - sys_chdir("/root");
78801 + sys_chdir((const char __force_user *)"/root");
78802 s = current->fs->pwd.dentry->d_sb;
78803 ROOT_DEV = s->s_dev;
78804 printk(KERN_INFO
78805 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78806 va_start(args, fmt);
78807 vsprintf(buf, fmt, args);
78808 va_end(args);
78809 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78810 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78811 if (fd >= 0) {
78812 sys_ioctl(fd, FDEJECT, 0);
78813 sys_close(fd);
78814 }
78815 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78816 - fd = sys_open("/dev/console", O_RDWR, 0);
78817 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78818 if (fd >= 0) {
78819 sys_ioctl(fd, TCGETS, (long)&termios);
78820 termios.c_lflag &= ~ICANON;
78821 sys_ioctl(fd, TCSETSF, (long)&termios);
78822 - sys_read(fd, &c, 1);
78823 + sys_read(fd, (char __user *)&c, 1);
78824 termios.c_lflag |= ICANON;
78825 sys_ioctl(fd, TCSETSF, (long)&termios);
78826 sys_close(fd);
78827 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78828 mount_root();
78829 out:
78830 devtmpfs_mount("dev");
78831 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78832 - sys_chroot(".");
78833 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78834 + sys_chroot((const char __force_user *)".");
78835 }
78836 diff --git a/init/do_mounts.h b/init/do_mounts.h
78837 index f5b978a..69dbfe8 100644
78838 --- a/init/do_mounts.h
78839 +++ b/init/do_mounts.h
78840 @@ -15,15 +15,15 @@ extern int root_mountflags;
78841
78842 static inline int create_dev(char *name, dev_t dev)
78843 {
78844 - sys_unlink(name);
78845 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78846 + sys_unlink((char __force_user *)name);
78847 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78848 }
78849
78850 #if BITS_PER_LONG == 32
78851 static inline u32 bstat(char *name)
78852 {
78853 struct stat64 stat;
78854 - if (sys_stat64(name, &stat) != 0)
78855 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78856 return 0;
78857 if (!S_ISBLK(stat.st_mode))
78858 return 0;
78859 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78860 static inline u32 bstat(char *name)
78861 {
78862 struct stat stat;
78863 - if (sys_newstat(name, &stat) != 0)
78864 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78865 return 0;
78866 if (!S_ISBLK(stat.st_mode))
78867 return 0;
78868 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
78869 index 3e0878e..8a9d7a0 100644
78870 --- a/init/do_mounts_initrd.c
78871 +++ b/init/do_mounts_initrd.c
78872 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
78873 {
78874 sys_unshare(CLONE_FS | CLONE_FILES);
78875 /* stdin/stdout/stderr for /linuxrc */
78876 - sys_open("/dev/console", O_RDWR, 0);
78877 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
78878 sys_dup(0);
78879 sys_dup(0);
78880 /* move initrd over / and chdir/chroot in initrd root */
78881 - sys_chdir("/root");
78882 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78883 - sys_chroot(".");
78884 + sys_chdir((const char __force_user *)"/root");
78885 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78886 + sys_chroot((const char __force_user *)".");
78887 sys_setsid();
78888 return 0;
78889 }
78890 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
78891 create_dev("/dev/root.old", Root_RAM0);
78892 /* mount initrd on rootfs' /root */
78893 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
78894 - sys_mkdir("/old", 0700);
78895 - sys_chdir("/old");
78896 + sys_mkdir((const char __force_user *)"/old", 0700);
78897 + sys_chdir((const char __force_user *)"/old");
78898
78899 /* try loading default modules from initrd */
78900 load_default_modules();
78901 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
78902 current->flags &= ~PF_FREEZER_SKIP;
78903
78904 /* move initrd to rootfs' /old */
78905 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
78906 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
78907 /* switch root and cwd back to / of rootfs */
78908 - sys_chroot("..");
78909 + sys_chroot((const char __force_user *)"..");
78910
78911 if (new_decode_dev(real_root_dev) == Root_RAM0) {
78912 - sys_chdir("/old");
78913 + sys_chdir((const char __force_user *)"/old");
78914 return;
78915 }
78916
78917 - sys_chdir("/");
78918 + sys_chdir((const char __force_user *)"/");
78919 ROOT_DEV = new_decode_dev(real_root_dev);
78920 mount_root();
78921
78922 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
78923 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
78924 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
78925 if (!error)
78926 printk("okay\n");
78927 else {
78928 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
78929 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
78930 if (error == -ENOENT)
78931 printk("/initrd does not exist. Ignored.\n");
78932 else
78933 printk("failed\n");
78934 printk(KERN_NOTICE "Unmounting old root\n");
78935 - sys_umount("/old", MNT_DETACH);
78936 + sys_umount((char __force_user *)"/old", MNT_DETACH);
78937 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
78938 if (fd < 0) {
78939 error = fd;
78940 @@ -127,11 +127,11 @@ int __init initrd_load(void)
78941 * mounted in the normal path.
78942 */
78943 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
78944 - sys_unlink("/initrd.image");
78945 + sys_unlink((const char __force_user *)"/initrd.image");
78946 handle_initrd();
78947 return 1;
78948 }
78949 }
78950 - sys_unlink("/initrd.image");
78951 + sys_unlink((const char __force_user *)"/initrd.image");
78952 return 0;
78953 }
78954 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
78955 index 8cb6db5..d729f50 100644
78956 --- a/init/do_mounts_md.c
78957 +++ b/init/do_mounts_md.c
78958 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
78959 partitioned ? "_d" : "", minor,
78960 md_setup_args[ent].device_names);
78961
78962 - fd = sys_open(name, 0, 0);
78963 + fd = sys_open((char __force_user *)name, 0, 0);
78964 if (fd < 0) {
78965 printk(KERN_ERR "md: open failed - cannot start "
78966 "array %s\n", name);
78967 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
78968 * array without it
78969 */
78970 sys_close(fd);
78971 - fd = sys_open(name, 0, 0);
78972 + fd = sys_open((char __force_user *)name, 0, 0);
78973 sys_ioctl(fd, BLKRRPART, 0);
78974 }
78975 sys_close(fd);
78976 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
78977
78978 wait_for_device_probe();
78979
78980 - fd = sys_open("/dev/md0", 0, 0);
78981 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
78982 if (fd >= 0) {
78983 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
78984 sys_close(fd);
78985 diff --git a/init/init_task.c b/init/init_task.c
78986 index ba0a7f36..2bcf1d5 100644
78987 --- a/init/init_task.c
78988 +++ b/init/init_task.c
78989 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
78990 * Initial thread structure. Alignment of this is handled by a special
78991 * linker map entry.
78992 */
78993 +#ifdef CONFIG_X86
78994 +union thread_union init_thread_union __init_task_data;
78995 +#else
78996 union thread_union init_thread_union __init_task_data =
78997 { INIT_THREAD_INFO(init_task) };
78998 +#endif
78999 diff --git a/init/initramfs.c b/init/initramfs.c
79000 index a67ef9d..2d17ed9 100644
79001 --- a/init/initramfs.c
79002 +++ b/init/initramfs.c
79003 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79004 }
79005 }
79006
79007 -static long __init do_utime(char *filename, time_t mtime)
79008 +static long __init do_utime(char __force_user *filename, time_t mtime)
79009 {
79010 struct timespec t[2];
79011
79012 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79013 struct dir_entry *de, *tmp;
79014 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79015 list_del(&de->list);
79016 - do_utime(de->name, de->mtime);
79017 + do_utime((char __force_user *)de->name, de->mtime);
79018 kfree(de->name);
79019 kfree(de);
79020 }
79021 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79022 if (nlink >= 2) {
79023 char *old = find_link(major, minor, ino, mode, collected);
79024 if (old)
79025 - return (sys_link(old, collected) < 0) ? -1 : 1;
79026 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79027 }
79028 return 0;
79029 }
79030 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79031 {
79032 struct stat st;
79033
79034 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79035 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79036 if (S_ISDIR(st.st_mode))
79037 - sys_rmdir(path);
79038 + sys_rmdir((char __force_user *)path);
79039 else
79040 - sys_unlink(path);
79041 + sys_unlink((char __force_user *)path);
79042 }
79043 }
79044
79045 @@ -315,7 +315,7 @@ static int __init do_name(void)
79046 int openflags = O_WRONLY|O_CREAT;
79047 if (ml != 1)
79048 openflags |= O_TRUNC;
79049 - wfd = sys_open(collected, openflags, mode);
79050 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79051
79052 if (wfd >= 0) {
79053 sys_fchown(wfd, uid, gid);
79054 @@ -327,17 +327,17 @@ static int __init do_name(void)
79055 }
79056 }
79057 } else if (S_ISDIR(mode)) {
79058 - sys_mkdir(collected, mode);
79059 - sys_chown(collected, uid, gid);
79060 - sys_chmod(collected, mode);
79061 + sys_mkdir((char __force_user *)collected, mode);
79062 + sys_chown((char __force_user *)collected, uid, gid);
79063 + sys_chmod((char __force_user *)collected, mode);
79064 dir_add(collected, mtime);
79065 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79066 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79067 if (maybe_link() == 0) {
79068 - sys_mknod(collected, mode, rdev);
79069 - sys_chown(collected, uid, gid);
79070 - sys_chmod(collected, mode);
79071 - do_utime(collected, mtime);
79072 + sys_mknod((char __force_user *)collected, mode, rdev);
79073 + sys_chown((char __force_user *)collected, uid, gid);
79074 + sys_chmod((char __force_user *)collected, mode);
79075 + do_utime((char __force_user *)collected, mtime);
79076 }
79077 }
79078 return 0;
79079 @@ -346,15 +346,15 @@ static int __init do_name(void)
79080 static int __init do_copy(void)
79081 {
79082 if (count >= body_len) {
79083 - sys_write(wfd, victim, body_len);
79084 + sys_write(wfd, (char __force_user *)victim, body_len);
79085 sys_close(wfd);
79086 - do_utime(vcollected, mtime);
79087 + do_utime((char __force_user *)vcollected, mtime);
79088 kfree(vcollected);
79089 eat(body_len);
79090 state = SkipIt;
79091 return 0;
79092 } else {
79093 - sys_write(wfd, victim, count);
79094 + sys_write(wfd, (char __force_user *)victim, count);
79095 body_len -= count;
79096 eat(count);
79097 return 1;
79098 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
79099 {
79100 collected[N_ALIGN(name_len) + body_len] = '\0';
79101 clean_path(collected, 0);
79102 - sys_symlink(collected + N_ALIGN(name_len), collected);
79103 - sys_lchown(collected, uid, gid);
79104 - do_utime(collected, mtime);
79105 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
79106 + sys_lchown((char __force_user *)collected, uid, gid);
79107 + do_utime((char __force_user *)collected, mtime);
79108 state = SkipIt;
79109 next_state = Reset;
79110 return 0;
79111 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
79112 {
79113 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
79114 if (err)
79115 - panic(err); /* Failed to decompress INTERNAL initramfs */
79116 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
79117 if (initrd_start) {
79118 #ifdef CONFIG_BLK_DEV_RAM
79119 int fd;
79120 diff --git a/init/main.c b/init/main.c
79121 index d03d2ec..9fc4737 100644
79122 --- a/init/main.c
79123 +++ b/init/main.c
79124 @@ -101,6 +101,8 @@ static inline void mark_rodata_ro(void) { }
79125 extern void tc_init(void);
79126 #endif
79127
79128 +extern void grsecurity_init(void);
79129 +
79130 /*
79131 * Debug helper: via this flag we know that we are in 'early bootup code'
79132 * where only the boot processor is running with IRQ disabled. This means
79133 @@ -154,6 +156,74 @@ static int __init set_reset_devices(char *str)
79134
79135 __setup("reset_devices", set_reset_devices);
79136
79137 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79138 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
79139 +static int __init setup_grsec_proc_gid(char *str)
79140 +{
79141 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
79142 + return 1;
79143 +}
79144 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
79145 +#endif
79146 +
79147 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
79148 +unsigned long pax_user_shadow_base __read_only;
79149 +EXPORT_SYMBOL(pax_user_shadow_base);
79150 +extern char pax_enter_kernel_user[];
79151 +extern char pax_exit_kernel_user[];
79152 +#endif
79153 +
79154 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
79155 +static int __init setup_pax_nouderef(char *str)
79156 +{
79157 +#ifdef CONFIG_X86_32
79158 + unsigned int cpu;
79159 + struct desc_struct *gdt;
79160 +
79161 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
79162 + gdt = get_cpu_gdt_table(cpu);
79163 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
79164 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
79165 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
79166 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
79167 + }
79168 + loadsegment(ds, __KERNEL_DS);
79169 + loadsegment(es, __KERNEL_DS);
79170 + loadsegment(ss, __KERNEL_DS);
79171 +#else
79172 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
79173 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
79174 + clone_pgd_mask = ~(pgdval_t)0UL;
79175 + pax_user_shadow_base = 0UL;
79176 + setup_clear_cpu_cap(X86_FEATURE_PCID);
79177 +#endif
79178 +
79179 + return 0;
79180 +}
79181 +early_param("pax_nouderef", setup_pax_nouderef);
79182 +
79183 +#ifdef CONFIG_X86_64
79184 +static int __init setup_pax_weakuderef(char *str)
79185 +{
79186 + if (clone_pgd_mask != ~(pgdval_t)0UL)
79187 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
79188 + return 1;
79189 +}
79190 +__setup("pax_weakuderef", setup_pax_weakuderef);
79191 +#endif
79192 +#endif
79193 +
79194 +#ifdef CONFIG_PAX_SOFTMODE
79195 +int pax_softmode;
79196 +
79197 +static int __init setup_pax_softmode(char *str)
79198 +{
79199 + get_option(&str, &pax_softmode);
79200 + return 1;
79201 +}
79202 +__setup("pax_softmode=", setup_pax_softmode);
79203 +#endif
79204 +
79205 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
79206 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
79207 static const char *panic_later, *panic_param;
79208 @@ -679,25 +749,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
79209 {
79210 int count = preempt_count();
79211 int ret;
79212 - char msgbuf[64];
79213 + const char *msg1 = "", *msg2 = "";
79214
79215 if (initcall_debug)
79216 ret = do_one_initcall_debug(fn);
79217 else
79218 ret = fn();
79219
79220 - msgbuf[0] = 0;
79221 -
79222 if (preempt_count() != count) {
79223 - sprintf(msgbuf, "preemption imbalance ");
79224 + msg1 = " preemption imbalance";
79225 preempt_count() = count;
79226 }
79227 if (irqs_disabled()) {
79228 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79229 + msg2 = " disabled interrupts";
79230 local_irq_enable();
79231 }
79232 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79233 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79234
79235 + add_latent_entropy();
79236 return ret;
79237 }
79238
79239 @@ -803,8 +872,8 @@ static int run_init_process(const char *init_filename)
79240 {
79241 argv_init[0] = init_filename;
79242 return do_execve(init_filename,
79243 - (const char __user *const __user *)argv_init,
79244 - (const char __user *const __user *)envp_init);
79245 + (const char __user *const __force_user *)argv_init,
79246 + (const char __user *const __force_user *)envp_init);
79247 }
79248
79249 static noinline void __init kernel_init_freeable(void);
79250 @@ -881,7 +950,7 @@ static noinline void __init kernel_init_freeable(void)
79251 do_basic_setup();
79252
79253 /* Open the /dev/console on the rootfs, this should never fail */
79254 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79255 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79256 pr_err("Warning: unable to open an initial console.\n");
79257
79258 (void) sys_dup(0);
79259 @@ -894,11 +963,13 @@ static noinline void __init kernel_init_freeable(void)
79260 if (!ramdisk_execute_command)
79261 ramdisk_execute_command = "/init";
79262
79263 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79264 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79265 ramdisk_execute_command = NULL;
79266 prepare_namespace();
79267 }
79268
79269 + grsecurity_init();
79270 +
79271 /*
79272 * Ok, we have completed the initial bootup, and
79273 * we're essentially up and running. Get rid of the
79274 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79275 index 130dfec..cc88451 100644
79276 --- a/ipc/ipc_sysctl.c
79277 +++ b/ipc/ipc_sysctl.c
79278 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79279 static int proc_ipc_dointvec(ctl_table *table, int write,
79280 void __user *buffer, size_t *lenp, loff_t *ppos)
79281 {
79282 - struct ctl_table ipc_table;
79283 + ctl_table_no_const ipc_table;
79284
79285 memcpy(&ipc_table, table, sizeof(ipc_table));
79286 ipc_table.data = get_ipc(table);
79287 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79288 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79289 void __user *buffer, size_t *lenp, loff_t *ppos)
79290 {
79291 - struct ctl_table ipc_table;
79292 + ctl_table_no_const ipc_table;
79293
79294 memcpy(&ipc_table, table, sizeof(ipc_table));
79295 ipc_table.data = get_ipc(table);
79296 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79297 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79298 void __user *buffer, size_t *lenp, loff_t *ppos)
79299 {
79300 - struct ctl_table ipc_table;
79301 + ctl_table_no_const ipc_table;
79302 size_t lenp_bef = *lenp;
79303 int rc;
79304
79305 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79306 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79307 void __user *buffer, size_t *lenp, loff_t *ppos)
79308 {
79309 - struct ctl_table ipc_table;
79310 + ctl_table_no_const ipc_table;
79311 memcpy(&ipc_table, table, sizeof(ipc_table));
79312 ipc_table.data = get_ipc(table);
79313
79314 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79315 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79316 void __user *buffer, size_t *lenp, loff_t *ppos)
79317 {
79318 - struct ctl_table ipc_table;
79319 + ctl_table_no_const ipc_table;
79320 size_t lenp_bef = *lenp;
79321 int oldval;
79322 int rc;
79323 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79324 index 383d638..943fdbb 100644
79325 --- a/ipc/mq_sysctl.c
79326 +++ b/ipc/mq_sysctl.c
79327 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79328 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79329 void __user *buffer, size_t *lenp, loff_t *ppos)
79330 {
79331 - struct ctl_table mq_table;
79332 + ctl_table_no_const mq_table;
79333 memcpy(&mq_table, table, sizeof(mq_table));
79334 mq_table.data = get_mq(table);
79335
79336 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79337 index ae1996d..a35f2cc 100644
79338 --- a/ipc/mqueue.c
79339 +++ b/ipc/mqueue.c
79340 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79341 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79342 info->attr.mq_msgsize);
79343
79344 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79345 spin_lock(&mq_lock);
79346 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79347 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79348 diff --git a/ipc/msg.c b/ipc/msg.c
79349 index 9f29d9e..8f284e0 100644
79350 --- a/ipc/msg.c
79351 +++ b/ipc/msg.c
79352 @@ -291,18 +291,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79353 return security_msg_queue_associate(msq, msgflg);
79354 }
79355
79356 +static struct ipc_ops msg_ops = {
79357 + .getnew = newque,
79358 + .associate = msg_security,
79359 + .more_checks = NULL
79360 +};
79361 +
79362 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79363 {
79364 struct ipc_namespace *ns;
79365 - struct ipc_ops msg_ops;
79366 struct ipc_params msg_params;
79367
79368 ns = current->nsproxy->ipc_ns;
79369
79370 - msg_ops.getnew = newque;
79371 - msg_ops.associate = msg_security;
79372 - msg_ops.more_checks = NULL;
79373 -
79374 msg_params.key = key;
79375 msg_params.flg = msgflg;
79376
79377 diff --git a/ipc/sem.c b/ipc/sem.c
79378 index 4108889..511ada1 100644
79379 --- a/ipc/sem.c
79380 +++ b/ipc/sem.c
79381 @@ -517,10 +517,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79382 return 0;
79383 }
79384
79385 +static struct ipc_ops sem_ops = {
79386 + .getnew = newary,
79387 + .associate = sem_security,
79388 + .more_checks = sem_more_checks
79389 +};
79390 +
79391 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79392 {
79393 struct ipc_namespace *ns;
79394 - struct ipc_ops sem_ops;
79395 struct ipc_params sem_params;
79396
79397 ns = current->nsproxy->ipc_ns;
79398 @@ -528,10 +533,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79399 if (nsems < 0 || nsems > ns->sc_semmsl)
79400 return -EINVAL;
79401
79402 - sem_ops.getnew = newary;
79403 - sem_ops.associate = sem_security;
79404 - sem_ops.more_checks = sem_more_checks;
79405 -
79406 sem_params.key = key;
79407 sem_params.flg = semflg;
79408 sem_params.u.nsems = nsems;
79409 diff --git a/ipc/shm.c b/ipc/shm.c
79410 index c6b4ad5..3ec3254 100644
79411 --- a/ipc/shm.c
79412 +++ b/ipc/shm.c
79413 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79414 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79415 #endif
79416
79417 +#ifdef CONFIG_GRKERNSEC
79418 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79419 + const time_t shm_createtime, const kuid_t cuid,
79420 + const int shmid);
79421 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79422 + const time_t shm_createtime);
79423 +#endif
79424 +
79425 void shm_init_ns(struct ipc_namespace *ns)
79426 {
79427 ns->shm_ctlmax = SHMMAX;
79428 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79429 shp->shm_lprid = 0;
79430 shp->shm_atim = shp->shm_dtim = 0;
79431 shp->shm_ctim = get_seconds();
79432 +#ifdef CONFIG_GRKERNSEC
79433 + {
79434 + struct timespec timeval;
79435 + do_posix_clock_monotonic_gettime(&timeval);
79436 +
79437 + shp->shm_createtime = timeval.tv_sec;
79438 + }
79439 +#endif
79440 shp->shm_segsz = size;
79441 shp->shm_nattch = 0;
79442 shp->shm_file = file;
79443 @@ -585,18 +601,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79444 return 0;
79445 }
79446
79447 +static struct ipc_ops shm_ops = {
79448 + .getnew = newseg,
79449 + .associate = shm_security,
79450 + .more_checks = shm_more_checks
79451 +};
79452 +
79453 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79454 {
79455 struct ipc_namespace *ns;
79456 - struct ipc_ops shm_ops;
79457 struct ipc_params shm_params;
79458
79459 ns = current->nsproxy->ipc_ns;
79460
79461 - shm_ops.getnew = newseg;
79462 - shm_ops.associate = shm_security;
79463 - shm_ops.more_checks = shm_more_checks;
79464 -
79465 shm_params.key = key;
79466 shm_params.flg = shmflg;
79467 shm_params.u.size = size;
79468 @@ -1028,6 +1045,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79469 f_mode = FMODE_READ | FMODE_WRITE;
79470 }
79471 if (shmflg & SHM_EXEC) {
79472 +
79473 +#ifdef CONFIG_PAX_MPROTECT
79474 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79475 + goto out;
79476 +#endif
79477 +
79478 prot |= PROT_EXEC;
79479 acc_mode |= S_IXUGO;
79480 }
79481 @@ -1051,9 +1074,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79482 if (err)
79483 goto out_unlock;
79484
79485 +#ifdef CONFIG_GRKERNSEC
79486 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79487 + shp->shm_perm.cuid, shmid) ||
79488 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79489 + err = -EACCES;
79490 + goto out_unlock;
79491 + }
79492 +#endif
79493 +
79494 path = shp->shm_file->f_path;
79495 path_get(&path);
79496 shp->shm_nattch++;
79497 +#ifdef CONFIG_GRKERNSEC
79498 + shp->shm_lapid = current->pid;
79499 +#endif
79500 size = i_size_read(path.dentry->d_inode);
79501 shm_unlock(shp);
79502
79503 diff --git a/kernel/acct.c b/kernel/acct.c
79504 index 8d6e145..33e0b1e 100644
79505 --- a/kernel/acct.c
79506 +++ b/kernel/acct.c
79507 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79508 */
79509 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79510 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79511 - file->f_op->write(file, (char *)&ac,
79512 + file->f_op->write(file, (char __force_user *)&ac,
79513 sizeof(acct_t), &file->f_pos);
79514 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79515 set_fs(fs);
79516 diff --git a/kernel/audit.c b/kernel/audit.c
79517 index 91e53d0..d9e3ec4 100644
79518 --- a/kernel/audit.c
79519 +++ b/kernel/audit.c
79520 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79521 3) suppressed due to audit_rate_limit
79522 4) suppressed due to audit_backlog_limit
79523 */
79524 -static atomic_t audit_lost = ATOMIC_INIT(0);
79525 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79526
79527 /* The netlink socket. */
79528 static struct sock *audit_sock;
79529 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79530 unsigned long now;
79531 int print;
79532
79533 - atomic_inc(&audit_lost);
79534 + atomic_inc_unchecked(&audit_lost);
79535
79536 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79537
79538 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79539 printk(KERN_WARNING
79540 "audit: audit_lost=%d audit_rate_limit=%d "
79541 "audit_backlog_limit=%d\n",
79542 - atomic_read(&audit_lost),
79543 + atomic_read_unchecked(&audit_lost),
79544 audit_rate_limit,
79545 audit_backlog_limit);
79546 audit_panic(message);
79547 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79548 status_set.pid = audit_pid;
79549 status_set.rate_limit = audit_rate_limit;
79550 status_set.backlog_limit = audit_backlog_limit;
79551 - status_set.lost = atomic_read(&audit_lost);
79552 + status_set.lost = atomic_read_unchecked(&audit_lost);
79553 status_set.backlog = skb_queue_len(&audit_skb_queue);
79554 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79555 &status_set, sizeof(status_set));
79556 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79557 index 9845cb3..3ec9369 100644
79558 --- a/kernel/auditsc.c
79559 +++ b/kernel/auditsc.c
79560 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79561 }
79562
79563 /* global counter which is incremented every time something logs in */
79564 -static atomic_t session_id = ATOMIC_INIT(0);
79565 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79566
79567 /**
79568 * audit_set_loginuid - set current task's audit_context loginuid
79569 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79570 return -EPERM;
79571 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79572
79573 - sessionid = atomic_inc_return(&session_id);
79574 + sessionid = atomic_inc_return_unchecked(&session_id);
79575 if (context && context->in_syscall) {
79576 struct audit_buffer *ab;
79577
79578 diff --git a/kernel/capability.c b/kernel/capability.c
79579 index f6c2ce5..982c0f9 100644
79580 --- a/kernel/capability.c
79581 +++ b/kernel/capability.c
79582 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79583 * before modification is attempted and the application
79584 * fails.
79585 */
79586 + if (tocopy > ARRAY_SIZE(kdata))
79587 + return -EFAULT;
79588 +
79589 if (copy_to_user(dataptr, kdata, tocopy
79590 * sizeof(struct __user_cap_data_struct))) {
79591 return -EFAULT;
79592 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79593 int ret;
79594
79595 rcu_read_lock();
79596 - ret = security_capable(__task_cred(t), ns, cap);
79597 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79598 + gr_task_is_capable(t, __task_cred(t), cap);
79599 rcu_read_unlock();
79600
79601 - return (ret == 0);
79602 + return ret;
79603 }
79604
79605 /**
79606 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79607 int ret;
79608
79609 rcu_read_lock();
79610 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79611 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79612 rcu_read_unlock();
79613
79614 - return (ret == 0);
79615 + return ret;
79616 }
79617
79618 /**
79619 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79620 BUG();
79621 }
79622
79623 - if (security_capable(current_cred(), ns, cap) == 0) {
79624 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79625 current->flags |= PF_SUPERPRIV;
79626 return true;
79627 }
79628 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79629 }
79630 EXPORT_SYMBOL(ns_capable);
79631
79632 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79633 +{
79634 + if (unlikely(!cap_valid(cap))) {
79635 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79636 + BUG();
79637 + }
79638 +
79639 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79640 + current->flags |= PF_SUPERPRIV;
79641 + return true;
79642 + }
79643 + return false;
79644 +}
79645 +EXPORT_SYMBOL(ns_capable_nolog);
79646 +
79647 /**
79648 * file_ns_capable - Determine if the file's opener had a capability in effect
79649 * @file: The file we want to check
79650 @@ -432,6 +451,12 @@ bool capable(int cap)
79651 }
79652 EXPORT_SYMBOL(capable);
79653
79654 +bool capable_nolog(int cap)
79655 +{
79656 + return ns_capable_nolog(&init_user_ns, cap);
79657 +}
79658 +EXPORT_SYMBOL(capable_nolog);
79659 +
79660 /**
79661 * nsown_capable - Check superior capability to one's own user_ns
79662 * @cap: The capability in question
79663 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79664
79665 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79666 }
79667 +
79668 +bool inode_capable_nolog(const struct inode *inode, int cap)
79669 +{
79670 + struct user_namespace *ns = current_user_ns();
79671 +
79672 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79673 +}
79674 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79675 index e919633..f46b08f 100644
79676 --- a/kernel/cgroup.c
79677 +++ b/kernel/cgroup.c
79678 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79679 struct css_set *cset = link->cset;
79680 struct task_struct *task;
79681 int count = 0;
79682 - seq_printf(seq, "css_set %p\n", cset);
79683 + seq_printf(seq, "css_set %pK\n", cset);
79684 list_for_each_entry(task, &cset->tasks, cg_list) {
79685 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79686 seq_puts(seq, " ...\n");
79687 diff --git a/kernel/compat.c b/kernel/compat.c
79688 index 0a09e48..f44f3f0 100644
79689 --- a/kernel/compat.c
79690 +++ b/kernel/compat.c
79691 @@ -13,6 +13,7 @@
79692
79693 #include <linux/linkage.h>
79694 #include <linux/compat.h>
79695 +#include <linux/module.h>
79696 #include <linux/errno.h>
79697 #include <linux/time.h>
79698 #include <linux/signal.h>
79699 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79700 mm_segment_t oldfs;
79701 long ret;
79702
79703 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79704 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79705 oldfs = get_fs();
79706 set_fs(KERNEL_DS);
79707 ret = hrtimer_nanosleep_restart(restart);
79708 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79709 oldfs = get_fs();
79710 set_fs(KERNEL_DS);
79711 ret = hrtimer_nanosleep(&tu,
79712 - rmtp ? (struct timespec __user *)&rmt : NULL,
79713 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79714 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79715 set_fs(oldfs);
79716
79717 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79718 mm_segment_t old_fs = get_fs();
79719
79720 set_fs(KERNEL_DS);
79721 - ret = sys_sigpending((old_sigset_t __user *) &s);
79722 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79723 set_fs(old_fs);
79724 if (ret == 0)
79725 ret = put_user(s, set);
79726 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79727 mm_segment_t old_fs = get_fs();
79728
79729 set_fs(KERNEL_DS);
79730 - ret = sys_old_getrlimit(resource, &r);
79731 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79732 set_fs(old_fs);
79733
79734 if (!ret) {
79735 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79736 set_fs (KERNEL_DS);
79737 ret = sys_wait4(pid,
79738 (stat_addr ?
79739 - (unsigned int __user *) &status : NULL),
79740 - options, (struct rusage __user *) &r);
79741 + (unsigned int __force_user *) &status : NULL),
79742 + options, (struct rusage __force_user *) &r);
79743 set_fs (old_fs);
79744
79745 if (ret > 0) {
79746 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79747 memset(&info, 0, sizeof(info));
79748
79749 set_fs(KERNEL_DS);
79750 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79751 - uru ? (struct rusage __user *)&ru : NULL);
79752 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79753 + uru ? (struct rusage __force_user *)&ru : NULL);
79754 set_fs(old_fs);
79755
79756 if ((ret < 0) || (info.si_signo == 0))
79757 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79758 oldfs = get_fs();
79759 set_fs(KERNEL_DS);
79760 err = sys_timer_settime(timer_id, flags,
79761 - (struct itimerspec __user *) &newts,
79762 - (struct itimerspec __user *) &oldts);
79763 + (struct itimerspec __force_user *) &newts,
79764 + (struct itimerspec __force_user *) &oldts);
79765 set_fs(oldfs);
79766 if (!err && old && put_compat_itimerspec(old, &oldts))
79767 return -EFAULT;
79768 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79769 oldfs = get_fs();
79770 set_fs(KERNEL_DS);
79771 err = sys_timer_gettime(timer_id,
79772 - (struct itimerspec __user *) &ts);
79773 + (struct itimerspec __force_user *) &ts);
79774 set_fs(oldfs);
79775 if (!err && put_compat_itimerspec(setting, &ts))
79776 return -EFAULT;
79777 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79778 oldfs = get_fs();
79779 set_fs(KERNEL_DS);
79780 err = sys_clock_settime(which_clock,
79781 - (struct timespec __user *) &ts);
79782 + (struct timespec __force_user *) &ts);
79783 set_fs(oldfs);
79784 return err;
79785 }
79786 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79787 oldfs = get_fs();
79788 set_fs(KERNEL_DS);
79789 err = sys_clock_gettime(which_clock,
79790 - (struct timespec __user *) &ts);
79791 + (struct timespec __force_user *) &ts);
79792 set_fs(oldfs);
79793 if (!err && put_compat_timespec(&ts, tp))
79794 return -EFAULT;
79795 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79796
79797 oldfs = get_fs();
79798 set_fs(KERNEL_DS);
79799 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79800 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79801 set_fs(oldfs);
79802
79803 err = compat_put_timex(utp, &txc);
79804 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79805 oldfs = get_fs();
79806 set_fs(KERNEL_DS);
79807 err = sys_clock_getres(which_clock,
79808 - (struct timespec __user *) &ts);
79809 + (struct timespec __force_user *) &ts);
79810 set_fs(oldfs);
79811 if (!err && tp && put_compat_timespec(&ts, tp))
79812 return -EFAULT;
79813 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79814 long err;
79815 mm_segment_t oldfs;
79816 struct timespec tu;
79817 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79818 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79819
79820 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79821 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79822 oldfs = get_fs();
79823 set_fs(KERNEL_DS);
79824 err = clock_nanosleep_restart(restart);
79825 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79826 oldfs = get_fs();
79827 set_fs(KERNEL_DS);
79828 err = sys_clock_nanosleep(which_clock, flags,
79829 - (struct timespec __user *) &in,
79830 - (struct timespec __user *) &out);
79831 + (struct timespec __force_user *) &in,
79832 + (struct timespec __force_user *) &out);
79833 set_fs(oldfs);
79834
79835 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79836 diff --git a/kernel/configs.c b/kernel/configs.c
79837 index c18b1f1..b9a0132 100644
79838 --- a/kernel/configs.c
79839 +++ b/kernel/configs.c
79840 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79841 struct proc_dir_entry *entry;
79842
79843 /* create the current config file */
79844 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79845 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
79846 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
79847 + &ikconfig_file_ops);
79848 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79849 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
79850 + &ikconfig_file_ops);
79851 +#endif
79852 +#else
79853 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
79854 &ikconfig_file_ops);
79855 +#endif
79856 +
79857 if (!entry)
79858 return -ENOMEM;
79859
79860 diff --git a/kernel/cred.c b/kernel/cred.c
79861 index e0573a4..3874e41 100644
79862 --- a/kernel/cred.c
79863 +++ b/kernel/cred.c
79864 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
79865 validate_creds(cred);
79866 alter_cred_subscribers(cred, -1);
79867 put_cred(cred);
79868 +
79869 +#ifdef CONFIG_GRKERNSEC_SETXID
79870 + cred = (struct cred *) tsk->delayed_cred;
79871 + if (cred != NULL) {
79872 + tsk->delayed_cred = NULL;
79873 + validate_creds(cred);
79874 + alter_cred_subscribers(cred, -1);
79875 + put_cred(cred);
79876 + }
79877 +#endif
79878 }
79879
79880 /**
79881 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
79882 * Always returns 0 thus allowing this function to be tail-called at the end
79883 * of, say, sys_setgid().
79884 */
79885 -int commit_creds(struct cred *new)
79886 +static int __commit_creds(struct cred *new)
79887 {
79888 struct task_struct *task = current;
79889 const struct cred *old = task->real_cred;
79890 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
79891
79892 get_cred(new); /* we will require a ref for the subj creds too */
79893
79894 + gr_set_role_label(task, new->uid, new->gid);
79895 +
79896 /* dumpability changes */
79897 if (!uid_eq(old->euid, new->euid) ||
79898 !gid_eq(old->egid, new->egid) ||
79899 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
79900 put_cred(old);
79901 return 0;
79902 }
79903 +#ifdef CONFIG_GRKERNSEC_SETXID
79904 +extern int set_user(struct cred *new);
79905 +
79906 +void gr_delayed_cred_worker(void)
79907 +{
79908 + const struct cred *new = current->delayed_cred;
79909 + struct cred *ncred;
79910 +
79911 + current->delayed_cred = NULL;
79912 +
79913 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
79914 + // from doing get_cred on it when queueing this
79915 + put_cred(new);
79916 + return;
79917 + } else if (new == NULL)
79918 + return;
79919 +
79920 + ncred = prepare_creds();
79921 + if (!ncred)
79922 + goto die;
79923 + // uids
79924 + ncred->uid = new->uid;
79925 + ncred->euid = new->euid;
79926 + ncred->suid = new->suid;
79927 + ncred->fsuid = new->fsuid;
79928 + // gids
79929 + ncred->gid = new->gid;
79930 + ncred->egid = new->egid;
79931 + ncred->sgid = new->sgid;
79932 + ncred->fsgid = new->fsgid;
79933 + // groups
79934 + if (set_groups(ncred, new->group_info) < 0) {
79935 + abort_creds(ncred);
79936 + goto die;
79937 + }
79938 + // caps
79939 + ncred->securebits = new->securebits;
79940 + ncred->cap_inheritable = new->cap_inheritable;
79941 + ncred->cap_permitted = new->cap_permitted;
79942 + ncred->cap_effective = new->cap_effective;
79943 + ncred->cap_bset = new->cap_bset;
79944 +
79945 + if (set_user(ncred)) {
79946 + abort_creds(ncred);
79947 + goto die;
79948 + }
79949 +
79950 + // from doing get_cred on it when queueing this
79951 + put_cred(new);
79952 +
79953 + __commit_creds(ncred);
79954 + return;
79955 +die:
79956 + // from doing get_cred on it when queueing this
79957 + put_cred(new);
79958 + do_group_exit(SIGKILL);
79959 +}
79960 +#endif
79961 +
79962 +int commit_creds(struct cred *new)
79963 +{
79964 +#ifdef CONFIG_GRKERNSEC_SETXID
79965 + int ret;
79966 + int schedule_it = 0;
79967 + struct task_struct *t;
79968 +
79969 + /* we won't get called with tasklist_lock held for writing
79970 + and interrupts disabled as the cred struct in that case is
79971 + init_cred
79972 + */
79973 + if (grsec_enable_setxid && !current_is_single_threaded() &&
79974 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
79975 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
79976 + schedule_it = 1;
79977 + }
79978 + ret = __commit_creds(new);
79979 + if (schedule_it) {
79980 + rcu_read_lock();
79981 + read_lock(&tasklist_lock);
79982 + for (t = next_thread(current); t != current;
79983 + t = next_thread(t)) {
79984 + if (t->delayed_cred == NULL) {
79985 + t->delayed_cred = get_cred(new);
79986 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
79987 + set_tsk_need_resched(t);
79988 + }
79989 + }
79990 + read_unlock(&tasklist_lock);
79991 + rcu_read_unlock();
79992 + }
79993 + return ret;
79994 +#else
79995 + return __commit_creds(new);
79996 +#endif
79997 +}
79998 +
79999 EXPORT_SYMBOL(commit_creds);
80000
80001 /**
80002 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80003 index 0506d44..2c20034 100644
80004 --- a/kernel/debug/debug_core.c
80005 +++ b/kernel/debug/debug_core.c
80006 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
80007 */
80008 static atomic_t masters_in_kgdb;
80009 static atomic_t slaves_in_kgdb;
80010 -static atomic_t kgdb_break_tasklet_var;
80011 +static atomic_unchecked_t kgdb_break_tasklet_var;
80012 atomic_t kgdb_setting_breakpoint;
80013
80014 struct task_struct *kgdb_usethread;
80015 @@ -133,7 +133,7 @@ int kgdb_single_step;
80016 static pid_t kgdb_sstep_pid;
80017
80018 /* to keep track of the CPU which is doing the single stepping*/
80019 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80020 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80021
80022 /*
80023 * If you are debugging a problem where roundup (the collection of
80024 @@ -541,7 +541,7 @@ return_normal:
80025 * kernel will only try for the value of sstep_tries before
80026 * giving up and continuing on.
80027 */
80028 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
80029 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
80030 (kgdb_info[cpu].task &&
80031 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
80032 atomic_set(&kgdb_active, -1);
80033 @@ -635,8 +635,8 @@ cpu_master_loop:
80034 }
80035
80036 kgdb_restore:
80037 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
80038 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
80039 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
80040 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
80041 if (kgdb_info[sstep_cpu].task)
80042 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
80043 else
80044 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
80045 static void kgdb_tasklet_bpt(unsigned long ing)
80046 {
80047 kgdb_breakpoint();
80048 - atomic_set(&kgdb_break_tasklet_var, 0);
80049 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
80050 }
80051
80052 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
80053
80054 void kgdb_schedule_breakpoint(void)
80055 {
80056 - if (atomic_read(&kgdb_break_tasklet_var) ||
80057 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
80058 atomic_read(&kgdb_active) != -1 ||
80059 atomic_read(&kgdb_setting_breakpoint))
80060 return;
80061 - atomic_inc(&kgdb_break_tasklet_var);
80062 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
80063 tasklet_schedule(&kgdb_tasklet_breakpoint);
80064 }
80065 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
80066 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
80067 index 00eb8f7..d7e3244 100644
80068 --- a/kernel/debug/kdb/kdb_main.c
80069 +++ b/kernel/debug/kdb/kdb_main.c
80070 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
80071 continue;
80072
80073 kdb_printf("%-20s%8u 0x%p ", mod->name,
80074 - mod->core_size, (void *)mod);
80075 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
80076 #ifdef CONFIG_MODULE_UNLOAD
80077 kdb_printf("%4ld ", module_refcount(mod));
80078 #endif
80079 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
80080 kdb_printf(" (Loading)");
80081 else
80082 kdb_printf(" (Live)");
80083 - kdb_printf(" 0x%p", mod->module_core);
80084 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
80085
80086 #ifdef CONFIG_MODULE_UNLOAD
80087 {
80088 diff --git a/kernel/events/core.c b/kernel/events/core.c
80089 index f86599e..b18b180 100644
80090 --- a/kernel/events/core.c
80091 +++ b/kernel/events/core.c
80092 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
80093 * 0 - disallow raw tracepoint access for unpriv
80094 * 1 - disallow cpu events for unpriv
80095 * 2 - disallow kernel profiling for unpriv
80096 + * 3 - disallow all unpriv perf event use
80097 */
80098 -int sysctl_perf_event_paranoid __read_mostly = 1;
80099 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80100 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
80101 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
80102 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
80103 +#else
80104 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
80105 +#endif
80106
80107 /* Minimum for 512 kiB + 1 user control page */
80108 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
80109 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
80110 update_perf_cpu_limits();
80111 }
80112
80113 -static atomic64_t perf_event_id;
80114 +static atomic64_unchecked_t perf_event_id;
80115
80116 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
80117 enum event_type_t event_type);
80118 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
80119
80120 static inline u64 perf_event_count(struct perf_event *event)
80121 {
80122 - return local64_read(&event->count) + atomic64_read(&event->child_count);
80123 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
80124 }
80125
80126 static u64 perf_event_read(struct perf_event *event)
80127 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
80128 mutex_lock(&event->child_mutex);
80129 total += perf_event_read(event);
80130 *enabled += event->total_time_enabled +
80131 - atomic64_read(&event->child_total_time_enabled);
80132 + atomic64_read_unchecked(&event->child_total_time_enabled);
80133 *running += event->total_time_running +
80134 - atomic64_read(&event->child_total_time_running);
80135 + atomic64_read_unchecked(&event->child_total_time_running);
80136
80137 list_for_each_entry(child, &event->child_list, child_list) {
80138 total += perf_event_read(child);
80139 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
80140 userpg->offset -= local64_read(&event->hw.prev_count);
80141
80142 userpg->time_enabled = enabled +
80143 - atomic64_read(&event->child_total_time_enabled);
80144 + atomic64_read_unchecked(&event->child_total_time_enabled);
80145
80146 userpg->time_running = running +
80147 - atomic64_read(&event->child_total_time_running);
80148 + atomic64_read_unchecked(&event->child_total_time_running);
80149
80150 arch_perf_update_userpage(userpg, now);
80151
80152 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
80153
80154 /* Data. */
80155 sp = perf_user_stack_pointer(regs);
80156 - rem = __output_copy_user(handle, (void *) sp, dump_size);
80157 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
80158 dyn_size = dump_size - rem;
80159
80160 perf_output_skip(handle, rem);
80161 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
80162 values[n++] = perf_event_count(event);
80163 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
80164 values[n++] = enabled +
80165 - atomic64_read(&event->child_total_time_enabled);
80166 + atomic64_read_unchecked(&event->child_total_time_enabled);
80167 }
80168 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
80169 values[n++] = running +
80170 - atomic64_read(&event->child_total_time_running);
80171 + atomic64_read_unchecked(&event->child_total_time_running);
80172 }
80173 if (read_format & PERF_FORMAT_ID)
80174 values[n++] = primary_event_id(event);
80175 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
80176 * need to add enough zero bytes after the string to handle
80177 * the 64bit alignment we do later.
80178 */
80179 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
80180 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
80181 if (!buf) {
80182 name = strncpy(tmp, "//enomem", sizeof(tmp));
80183 goto got_name;
80184 }
80185 - name = d_path(&file->f_path, buf, PATH_MAX);
80186 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
80187 if (IS_ERR(name)) {
80188 name = strncpy(tmp, "//toolong", sizeof(tmp));
80189 goto got_name;
80190 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
80191 event->parent = parent_event;
80192
80193 event->ns = get_pid_ns(task_active_pid_ns(current));
80194 - event->id = atomic64_inc_return(&perf_event_id);
80195 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80196
80197 event->state = PERF_EVENT_STATE_INACTIVE;
80198
80199 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80200 if (flags & ~PERF_FLAG_ALL)
80201 return -EINVAL;
80202
80203 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80204 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80205 + return -EACCES;
80206 +#endif
80207 +
80208 err = perf_copy_attr(attr_uptr, &attr);
80209 if (err)
80210 return err;
80211 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80212 /*
80213 * Add back the child's count to the parent's count:
80214 */
80215 - atomic64_add(child_val, &parent_event->child_count);
80216 - atomic64_add(child_event->total_time_enabled,
80217 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80218 + atomic64_add_unchecked(child_event->total_time_enabled,
80219 &parent_event->child_total_time_enabled);
80220 - atomic64_add(child_event->total_time_running,
80221 + atomic64_add_unchecked(child_event->total_time_running,
80222 &parent_event->child_total_time_running);
80223
80224 /*
80225 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80226 index ca65997..60df03d 100644
80227 --- a/kernel/events/internal.h
80228 +++ b/kernel/events/internal.h
80229 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80230 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80231 }
80232
80233 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80234 -static inline unsigned int \
80235 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80236 +static inline unsigned long \
80237 func_name(struct perf_output_handle *handle, \
80238 - const void *buf, unsigned int len) \
80239 + const void user *buf, unsigned long len) \
80240 { \
80241 unsigned long size, written; \
80242 \
80243 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80244 return n;
80245 }
80246
80247 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80248 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80249
80250 #define MEMCPY_SKIP(dst, src, n) (n)
80251
80252 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80253 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80254
80255 #ifndef arch_perf_out_copy_user
80256 #define arch_perf_out_copy_user __copy_from_user_inatomic
80257 #endif
80258
80259 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80260 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80261
80262 /* Callchain handling */
80263 extern struct perf_callchain_entry *
80264 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80265 index f356974..cb8c570 100644
80266 --- a/kernel/events/uprobes.c
80267 +++ b/kernel/events/uprobes.c
80268 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80269 {
80270 struct page *page;
80271 uprobe_opcode_t opcode;
80272 - int result;
80273 + long result;
80274
80275 pagefault_disable();
80276 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80277 diff --git a/kernel/exit.c b/kernel/exit.c
80278 index a949819..a5f127d 100644
80279 --- a/kernel/exit.c
80280 +++ b/kernel/exit.c
80281 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80282 struct task_struct *leader;
80283 int zap_leader;
80284 repeat:
80285 +#ifdef CONFIG_NET
80286 + gr_del_task_from_ip_table(p);
80287 +#endif
80288 +
80289 /* don't need to get the RCU readlock here - the process is dead and
80290 * can't be modifying its own credentials. But shut RCU-lockdep up */
80291 rcu_read_lock();
80292 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80293 * know it'll be handled, so that they don't get converted to
80294 * SIGKILL or just silently dropped.
80295 */
80296 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80297 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80298 recalc_sigpending();
80299 spin_unlock_irq(&current->sighand->siglock);
80300 return 0;
80301 @@ -698,6 +702,8 @@ void do_exit(long code)
80302 struct task_struct *tsk = current;
80303 int group_dead;
80304
80305 + set_fs(USER_DS);
80306 +
80307 profile_task_exit(tsk);
80308
80309 WARN_ON(blk_needs_flush_plug(tsk));
80310 @@ -714,7 +720,6 @@ void do_exit(long code)
80311 * mm_release()->clear_child_tid() from writing to a user-controlled
80312 * kernel address.
80313 */
80314 - set_fs(USER_DS);
80315
80316 ptrace_event(PTRACE_EVENT_EXIT, code);
80317
80318 @@ -773,6 +778,9 @@ void do_exit(long code)
80319 tsk->exit_code = code;
80320 taskstats_exit(tsk, group_dead);
80321
80322 + gr_acl_handle_psacct(tsk, code);
80323 + gr_acl_handle_exit();
80324 +
80325 exit_mm(tsk);
80326
80327 if (group_dead)
80328 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80329 * Take down every thread in the group. This is called by fatal signals
80330 * as well as by sys_exit_group (below).
80331 */
80332 -void
80333 +__noreturn void
80334 do_group_exit(int exit_code)
80335 {
80336 struct signal_struct *sig = current->signal;
80337 diff --git a/kernel/fork.c b/kernel/fork.c
80338 index bf46287..2af185d 100644
80339 --- a/kernel/fork.c
80340 +++ b/kernel/fork.c
80341 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80342 *stackend = STACK_END_MAGIC; /* for overflow detection */
80343
80344 #ifdef CONFIG_CC_STACKPROTECTOR
80345 - tsk->stack_canary = get_random_int();
80346 + tsk->stack_canary = pax_get_random_long();
80347 #endif
80348
80349 /*
80350 @@ -345,13 +345,81 @@ free_tsk:
80351 }
80352
80353 #ifdef CONFIG_MMU
80354 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80355 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80356 {
80357 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80358 - struct rb_node **rb_link, *rb_parent;
80359 - int retval;
80360 + struct vm_area_struct *tmp;
80361 unsigned long charge;
80362 struct mempolicy *pol;
80363 + struct file *file;
80364 +
80365 + charge = 0;
80366 + if (mpnt->vm_flags & VM_ACCOUNT) {
80367 + unsigned long len = vma_pages(mpnt);
80368 +
80369 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80370 + goto fail_nomem;
80371 + charge = len;
80372 + }
80373 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80374 + if (!tmp)
80375 + goto fail_nomem;
80376 + *tmp = *mpnt;
80377 + tmp->vm_mm = mm;
80378 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80379 + pol = mpol_dup(vma_policy(mpnt));
80380 + if (IS_ERR(pol))
80381 + goto fail_nomem_policy;
80382 + vma_set_policy(tmp, pol);
80383 + if (anon_vma_fork(tmp, mpnt))
80384 + goto fail_nomem_anon_vma_fork;
80385 + tmp->vm_flags &= ~VM_LOCKED;
80386 + tmp->vm_next = tmp->vm_prev = NULL;
80387 + tmp->vm_mirror = NULL;
80388 + file = tmp->vm_file;
80389 + if (file) {
80390 + struct inode *inode = file_inode(file);
80391 + struct address_space *mapping = file->f_mapping;
80392 +
80393 + get_file(file);
80394 + if (tmp->vm_flags & VM_DENYWRITE)
80395 + atomic_dec(&inode->i_writecount);
80396 + mutex_lock(&mapping->i_mmap_mutex);
80397 + if (tmp->vm_flags & VM_SHARED)
80398 + mapping->i_mmap_writable++;
80399 + flush_dcache_mmap_lock(mapping);
80400 + /* insert tmp into the share list, just after mpnt */
80401 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80402 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80403 + else
80404 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80405 + flush_dcache_mmap_unlock(mapping);
80406 + mutex_unlock(&mapping->i_mmap_mutex);
80407 + }
80408 +
80409 + /*
80410 + * Clear hugetlb-related page reserves for children. This only
80411 + * affects MAP_PRIVATE mappings. Faults generated by the child
80412 + * are not guaranteed to succeed, even if read-only
80413 + */
80414 + if (is_vm_hugetlb_page(tmp))
80415 + reset_vma_resv_huge_pages(tmp);
80416 +
80417 + return tmp;
80418 +
80419 +fail_nomem_anon_vma_fork:
80420 + mpol_put(pol);
80421 +fail_nomem_policy:
80422 + kmem_cache_free(vm_area_cachep, tmp);
80423 +fail_nomem:
80424 + vm_unacct_memory(charge);
80425 + return NULL;
80426 +}
80427 +
80428 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80429 +{
80430 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80431 + struct rb_node **rb_link, *rb_parent;
80432 + int retval;
80433
80434 uprobe_start_dup_mmap();
80435 down_write(&oldmm->mmap_sem);
80436 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80437
80438 prev = NULL;
80439 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80440 - struct file *file;
80441 -
80442 if (mpnt->vm_flags & VM_DONTCOPY) {
80443 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80444 -vma_pages(mpnt));
80445 continue;
80446 }
80447 - charge = 0;
80448 - if (mpnt->vm_flags & VM_ACCOUNT) {
80449 - unsigned long len = vma_pages(mpnt);
80450 -
80451 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80452 - goto fail_nomem;
80453 - charge = len;
80454 - }
80455 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80456 - if (!tmp)
80457 - goto fail_nomem;
80458 - *tmp = *mpnt;
80459 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80460 - pol = mpol_dup(vma_policy(mpnt));
80461 - retval = PTR_ERR(pol);
80462 - if (IS_ERR(pol))
80463 - goto fail_nomem_policy;
80464 - vma_set_policy(tmp, pol);
80465 - tmp->vm_mm = mm;
80466 - if (anon_vma_fork(tmp, mpnt))
80467 - goto fail_nomem_anon_vma_fork;
80468 - tmp->vm_flags &= ~VM_LOCKED;
80469 - tmp->vm_next = tmp->vm_prev = NULL;
80470 - file = tmp->vm_file;
80471 - if (file) {
80472 - struct inode *inode = file_inode(file);
80473 - struct address_space *mapping = file->f_mapping;
80474 -
80475 - get_file(file);
80476 - if (tmp->vm_flags & VM_DENYWRITE)
80477 - atomic_dec(&inode->i_writecount);
80478 - mutex_lock(&mapping->i_mmap_mutex);
80479 - if (tmp->vm_flags & VM_SHARED)
80480 - mapping->i_mmap_writable++;
80481 - flush_dcache_mmap_lock(mapping);
80482 - /* insert tmp into the share list, just after mpnt */
80483 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80484 - vma_nonlinear_insert(tmp,
80485 - &mapping->i_mmap_nonlinear);
80486 - else
80487 - vma_interval_tree_insert_after(tmp, mpnt,
80488 - &mapping->i_mmap);
80489 - flush_dcache_mmap_unlock(mapping);
80490 - mutex_unlock(&mapping->i_mmap_mutex);
80491 + tmp = dup_vma(mm, oldmm, mpnt);
80492 + if (!tmp) {
80493 + retval = -ENOMEM;
80494 + goto out;
80495 }
80496
80497 /*
80498 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80499 if (retval)
80500 goto out;
80501 }
80502 +
80503 +#ifdef CONFIG_PAX_SEGMEXEC
80504 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80505 + struct vm_area_struct *mpnt_m;
80506 +
80507 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80508 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80509 +
80510 + if (!mpnt->vm_mirror)
80511 + continue;
80512 +
80513 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80514 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80515 + mpnt->vm_mirror = mpnt_m;
80516 + } else {
80517 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80518 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80519 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80520 + mpnt->vm_mirror->vm_mirror = mpnt;
80521 + }
80522 + }
80523 + BUG_ON(mpnt_m);
80524 + }
80525 +#endif
80526 +
80527 /* a new mm has just been created */
80528 arch_dup_mmap(oldmm, mm);
80529 retval = 0;
80530 @@ -471,14 +522,6 @@ out:
80531 up_write(&oldmm->mmap_sem);
80532 uprobe_end_dup_mmap();
80533 return retval;
80534 -fail_nomem_anon_vma_fork:
80535 - mpol_put(pol);
80536 -fail_nomem_policy:
80537 - kmem_cache_free(vm_area_cachep, tmp);
80538 -fail_nomem:
80539 - retval = -ENOMEM;
80540 - vm_unacct_memory(charge);
80541 - goto out;
80542 }
80543
80544 static inline int mm_alloc_pgd(struct mm_struct *mm)
80545 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80546 return ERR_PTR(err);
80547
80548 mm = get_task_mm(task);
80549 - if (mm && mm != current->mm &&
80550 - !ptrace_may_access(task, mode)) {
80551 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80552 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80553 mmput(mm);
80554 mm = ERR_PTR(-EACCES);
80555 }
80556 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80557 spin_unlock(&fs->lock);
80558 return -EAGAIN;
80559 }
80560 - fs->users++;
80561 + atomic_inc(&fs->users);
80562 spin_unlock(&fs->lock);
80563 return 0;
80564 }
80565 tsk->fs = copy_fs_struct(fs);
80566 if (!tsk->fs)
80567 return -ENOMEM;
80568 + /* Carry through gr_chroot_dentry and is_chrooted instead
80569 + of recomputing it here. Already copied when the task struct
80570 + is duplicated. This allows pivot_root to not be treated as
80571 + a chroot
80572 + */
80573 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80574 +
80575 return 0;
80576 }
80577
80578 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80579 * parts of the process environment (as per the clone
80580 * flags). The actual kick-off is left to the caller.
80581 */
80582 -static struct task_struct *copy_process(unsigned long clone_flags,
80583 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80584 unsigned long stack_start,
80585 unsigned long stack_size,
80586 int __user *child_tidptr,
80587 @@ -1200,6 +1250,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80588 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80589 #endif
80590 retval = -EAGAIN;
80591 +
80592 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80593 +
80594 if (atomic_read(&p->real_cred->user->processes) >=
80595 task_rlimit(p, RLIMIT_NPROC)) {
80596 if (p->real_cred->user != INIT_USER &&
80597 @@ -1449,6 +1502,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80598 goto bad_fork_free_pid;
80599 }
80600
80601 + /* synchronizes with gr_set_acls()
80602 + we need to call this past the point of no return for fork()
80603 + */
80604 + gr_copy_label(p);
80605 +
80606 if (likely(p->pid)) {
80607 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80608
80609 @@ -1534,6 +1592,8 @@ bad_fork_cleanup_count:
80610 bad_fork_free:
80611 free_task(p);
80612 fork_out:
80613 + gr_log_forkfail(retval);
80614 +
80615 return ERR_PTR(retval);
80616 }
80617
80618 @@ -1604,6 +1664,7 @@ long do_fork(unsigned long clone_flags,
80619
80620 p = copy_process(clone_flags, stack_start, stack_size,
80621 child_tidptr, NULL, trace);
80622 + add_latent_entropy();
80623 /*
80624 * Do this prior waking up the new thread - the thread pointer
80625 * might get invalid after that point, if the thread exits quickly.
80626 @@ -1618,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
80627 if (clone_flags & CLONE_PARENT_SETTID)
80628 put_user(nr, parent_tidptr);
80629
80630 + gr_handle_brute_check();
80631 +
80632 if (clone_flags & CLONE_VFORK) {
80633 p->vfork_done = &vfork;
80634 init_completion(&vfork);
80635 @@ -1734,7 +1797,7 @@ void __init proc_caches_init(void)
80636 mm_cachep = kmem_cache_create("mm_struct",
80637 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80638 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80639 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80640 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80641 mmap_init();
80642 nsproxy_cache_init();
80643 }
80644 @@ -1774,7 +1837,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80645 return 0;
80646
80647 /* don't need lock here; in the worst case we'll do useless copy */
80648 - if (fs->users == 1)
80649 + if (atomic_read(&fs->users) == 1)
80650 return 0;
80651
80652 *new_fsp = copy_fs_struct(fs);
80653 @@ -1886,7 +1949,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80654 fs = current->fs;
80655 spin_lock(&fs->lock);
80656 current->fs = new_fs;
80657 - if (--fs->users)
80658 + gr_set_chroot_entries(current, &current->fs->root);
80659 + if (atomic_dec_return(&fs->users))
80660 new_fs = NULL;
80661 else
80662 new_fs = fs;
80663 diff --git a/kernel/futex.c b/kernel/futex.c
80664 index c3a1a55..e32b4a98 100644
80665 --- a/kernel/futex.c
80666 +++ b/kernel/futex.c
80667 @@ -54,6 +54,7 @@
80668 #include <linux/mount.h>
80669 #include <linux/pagemap.h>
80670 #include <linux/syscalls.h>
80671 +#include <linux/ptrace.h>
80672 #include <linux/signal.h>
80673 #include <linux/export.h>
80674 #include <linux/magic.h>
80675 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80676 struct page *page, *page_head;
80677 int err, ro = 0;
80678
80679 +#ifdef CONFIG_PAX_SEGMEXEC
80680 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80681 + return -EFAULT;
80682 +#endif
80683 +
80684 /*
80685 * The futex address must be "naturally" aligned.
80686 */
80687 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80688
80689 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80690 {
80691 - int ret;
80692 + unsigned long ret;
80693
80694 pagefault_disable();
80695 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80696 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80697 {
80698 u32 curval;
80699 int i;
80700 + mm_segment_t oldfs;
80701
80702 /*
80703 * This will fail and we want it. Some arch implementations do
80704 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80705 * implementation, the non-functional ones will return
80706 * -ENOSYS.
80707 */
80708 + oldfs = get_fs();
80709 + set_fs(USER_DS);
80710 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80711 futex_cmpxchg_enabled = 1;
80712 + set_fs(oldfs);
80713
80714 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80715 plist_head_init(&futex_queues[i].chain);
80716 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80717 index f9f44fd..29885e4 100644
80718 --- a/kernel/futex_compat.c
80719 +++ b/kernel/futex_compat.c
80720 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80721 return 0;
80722 }
80723
80724 -static void __user *futex_uaddr(struct robust_list __user *entry,
80725 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80726 compat_long_t futex_offset)
80727 {
80728 compat_uptr_t base = ptr_to_compat(entry);
80729 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80730 index 9b22d03..6295b62 100644
80731 --- a/kernel/gcov/base.c
80732 +++ b/kernel/gcov/base.c
80733 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80734 }
80735
80736 #ifdef CONFIG_MODULES
80737 -static inline int within(void *addr, void *start, unsigned long size)
80738 -{
80739 - return ((addr >= start) && (addr < start + size));
80740 -}
80741 -
80742 /* Update list and generate events when modules are unloaded. */
80743 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80744 void *data)
80745 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80746 prev = NULL;
80747 /* Remove entries located in module from linked list. */
80748 for (info = gcov_info_head; info; info = info->next) {
80749 - if (within(info, mod->module_core, mod->core_size)) {
80750 + if (within_module_core_rw((unsigned long)info, mod)) {
80751 if (prev)
80752 prev->next = info->next;
80753 else
80754 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80755 index 383319b..cd2b391 100644
80756 --- a/kernel/hrtimer.c
80757 +++ b/kernel/hrtimer.c
80758 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80759 local_irq_restore(flags);
80760 }
80761
80762 -static void run_hrtimer_softirq(struct softirq_action *h)
80763 +static void run_hrtimer_softirq(void)
80764 {
80765 hrtimer_peek_ahead_timers();
80766 }
80767 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80768 index 55fcce6..0e4cf34 100644
80769 --- a/kernel/irq_work.c
80770 +++ b/kernel/irq_work.c
80771 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80772 return NOTIFY_OK;
80773 }
80774
80775 -static struct notifier_block cpu_notify;
80776 +static struct notifier_block cpu_notify = {
80777 + .notifier_call = irq_work_cpu_notify,
80778 + .priority = 0,
80779 +};
80780
80781 static __init int irq_work_init_cpu_notifier(void)
80782 {
80783 - cpu_notify.notifier_call = irq_work_cpu_notify;
80784 - cpu_notify.priority = 0;
80785 register_cpu_notifier(&cpu_notify);
80786 return 0;
80787 }
80788 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80789 index 60f48fa..7f3a770 100644
80790 --- a/kernel/jump_label.c
80791 +++ b/kernel/jump_label.c
80792 @@ -13,6 +13,7 @@
80793 #include <linux/sort.h>
80794 #include <linux/err.h>
80795 #include <linux/static_key.h>
80796 +#include <linux/mm.h>
80797
80798 #ifdef HAVE_JUMP_LABEL
80799
80800 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80801
80802 size = (((unsigned long)stop - (unsigned long)start)
80803 / sizeof(struct jump_entry));
80804 + pax_open_kernel();
80805 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80806 + pax_close_kernel();
80807 }
80808
80809 static void jump_label_update(struct static_key *key, int enable);
80810 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80811 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80812 struct jump_entry *iter;
80813
80814 + pax_open_kernel();
80815 for (iter = iter_start; iter < iter_stop; iter++) {
80816 if (within_module_init(iter->code, mod))
80817 iter->code = 0;
80818 }
80819 + pax_close_kernel();
80820 }
80821
80822 static int
80823 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80824 index 3127ad5..159d880 100644
80825 --- a/kernel/kallsyms.c
80826 +++ b/kernel/kallsyms.c
80827 @@ -11,6 +11,9 @@
80828 * Changed the compression method from stem compression to "table lookup"
80829 * compression (see scripts/kallsyms.c for a more complete description)
80830 */
80831 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80832 +#define __INCLUDED_BY_HIDESYM 1
80833 +#endif
80834 #include <linux/kallsyms.h>
80835 #include <linux/module.h>
80836 #include <linux/init.h>
80837 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80838
80839 static inline int is_kernel_inittext(unsigned long addr)
80840 {
80841 + if (system_state != SYSTEM_BOOTING)
80842 + return 0;
80843 +
80844 if (addr >= (unsigned long)_sinittext
80845 && addr <= (unsigned long)_einittext)
80846 return 1;
80847 return 0;
80848 }
80849
80850 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80851 +#ifdef CONFIG_MODULES
80852 +static inline int is_module_text(unsigned long addr)
80853 +{
80854 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
80855 + return 1;
80856 +
80857 + addr = ktla_ktva(addr);
80858 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
80859 +}
80860 +#else
80861 +static inline int is_module_text(unsigned long addr)
80862 +{
80863 + return 0;
80864 +}
80865 +#endif
80866 +#endif
80867 +
80868 static inline int is_kernel_text(unsigned long addr)
80869 {
80870 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
80871 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
80872
80873 static inline int is_kernel(unsigned long addr)
80874 {
80875 +
80876 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80877 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
80878 + return 1;
80879 +
80880 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
80881 +#else
80882 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
80883 +#endif
80884 +
80885 return 1;
80886 return in_gate_area_no_mm(addr);
80887 }
80888
80889 static int is_ksym_addr(unsigned long addr)
80890 {
80891 +
80892 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80893 + if (is_module_text(addr))
80894 + return 0;
80895 +#endif
80896 +
80897 if (all_var)
80898 return is_kernel(addr);
80899
80900 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
80901
80902 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
80903 {
80904 - iter->name[0] = '\0';
80905 iter->nameoff = get_symbol_offset(new_pos);
80906 iter->pos = new_pos;
80907 }
80908 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
80909 {
80910 struct kallsym_iter *iter = m->private;
80911
80912 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80913 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
80914 + return 0;
80915 +#endif
80916 +
80917 /* Some debugging symbols have no name. Ignore them. */
80918 if (!iter->name[0])
80919 return 0;
80920 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
80921 */
80922 type = iter->exported ? toupper(iter->type) :
80923 tolower(iter->type);
80924 +
80925 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
80926 type, iter->name, iter->module_name);
80927 } else
80928 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
80929 struct kallsym_iter *iter;
80930 int ret;
80931
80932 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
80933 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
80934 if (!iter)
80935 return -ENOMEM;
80936 reset_iter(iter, 0);
80937 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
80938 index e30ac0f..3528cac 100644
80939 --- a/kernel/kcmp.c
80940 +++ b/kernel/kcmp.c
80941 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
80942 struct task_struct *task1, *task2;
80943 int ret;
80944
80945 +#ifdef CONFIG_GRKERNSEC
80946 + return -ENOSYS;
80947 +#endif
80948 +
80949 rcu_read_lock();
80950
80951 /*
80952 diff --git a/kernel/kexec.c b/kernel/kexec.c
80953 index 59f7b55..4022f65 100644
80954 --- a/kernel/kexec.c
80955 +++ b/kernel/kexec.c
80956 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
80957 unsigned long flags)
80958 {
80959 struct compat_kexec_segment in;
80960 - struct kexec_segment out, __user *ksegments;
80961 + struct kexec_segment out;
80962 + struct kexec_segment __user *ksegments;
80963 unsigned long i, result;
80964
80965 /* Don't allow clients that don't understand the native
80966 diff --git a/kernel/kmod.c b/kernel/kmod.c
80967 index fb32636..2fe8775 100644
80968 --- a/kernel/kmod.c
80969 +++ b/kernel/kmod.c
80970 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
80971 kfree(info->argv);
80972 }
80973
80974 -static int call_modprobe(char *module_name, int wait)
80975 +static int call_modprobe(char *module_name, char *module_param, int wait)
80976 {
80977 struct subprocess_info *info;
80978 static char *envp[] = {
80979 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
80980 NULL
80981 };
80982
80983 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
80984 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
80985 if (!argv)
80986 goto out;
80987
80988 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
80989 argv[1] = "-q";
80990 argv[2] = "--";
80991 argv[3] = module_name; /* check free_modprobe_argv() */
80992 - argv[4] = NULL;
80993 + argv[4] = module_param;
80994 + argv[5] = NULL;
80995
80996 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
80997 NULL, free_modprobe_argv, NULL);
80998 @@ -129,9 +130,8 @@ out:
80999 * If module auto-loading support is disabled then this function
81000 * becomes a no-operation.
81001 */
81002 -int __request_module(bool wait, const char *fmt, ...)
81003 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81004 {
81005 - va_list args;
81006 char module_name[MODULE_NAME_LEN];
81007 unsigned int max_modprobes;
81008 int ret;
81009 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81010 if (!modprobe_path[0])
81011 return 0;
81012
81013 - va_start(args, fmt);
81014 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
81015 - va_end(args);
81016 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
81017 if (ret >= MODULE_NAME_LEN)
81018 return -ENAMETOOLONG;
81019
81020 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
81021 if (ret)
81022 return ret;
81023
81024 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81025 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81026 + /* hack to workaround consolekit/udisks stupidity */
81027 + read_lock(&tasklist_lock);
81028 + if (!strcmp(current->comm, "mount") &&
81029 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
81030 + read_unlock(&tasklist_lock);
81031 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
81032 + return -EPERM;
81033 + }
81034 + read_unlock(&tasklist_lock);
81035 + }
81036 +#endif
81037 +
81038 /* If modprobe needs a service that is in a module, we get a recursive
81039 * loop. Limit the number of running kmod threads to max_threads/2 or
81040 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
81041 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
81042
81043 trace_module_request(module_name, wait, _RET_IP_);
81044
81045 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81046 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81047
81048 atomic_dec(&kmod_concurrent);
81049 return ret;
81050 }
81051 +
81052 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
81053 +{
81054 + va_list args;
81055 + int ret;
81056 +
81057 + va_start(args, fmt);
81058 + ret = ____request_module(wait, module_param, fmt, args);
81059 + va_end(args);
81060 +
81061 + return ret;
81062 +}
81063 +
81064 +int __request_module(bool wait, const char *fmt, ...)
81065 +{
81066 + va_list args;
81067 + int ret;
81068 +
81069 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81070 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81071 + char module_param[MODULE_NAME_LEN];
81072 +
81073 + memset(module_param, 0, sizeof(module_param));
81074 +
81075 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
81076 +
81077 + va_start(args, fmt);
81078 + ret = ____request_module(wait, module_param, fmt, args);
81079 + va_end(args);
81080 +
81081 + return ret;
81082 + }
81083 +#endif
81084 +
81085 + va_start(args, fmt);
81086 + ret = ____request_module(wait, NULL, fmt, args);
81087 + va_end(args);
81088 +
81089 + return ret;
81090 +}
81091 +
81092 EXPORT_SYMBOL(__request_module);
81093 #endif /* CONFIG_MODULES */
81094
81095 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
81096 *
81097 * Thus the __user pointer cast is valid here.
81098 */
81099 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
81100 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
81101
81102 /*
81103 * If ret is 0, either ____call_usermodehelper failed and the
81104 @@ -646,7 +699,7 @@ EXPORT_SYMBOL(call_usermodehelper);
81105 static int proc_cap_handler(struct ctl_table *table, int write,
81106 void __user *buffer, size_t *lenp, loff_t *ppos)
81107 {
81108 - struct ctl_table t;
81109 + ctl_table_no_const t;
81110 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
81111 kernel_cap_t new_cap;
81112 int err, i;
81113 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
81114 index 6e33498..3133bd3 100644
81115 --- a/kernel/kprobes.c
81116 +++ b/kernel/kprobes.c
81117 @@ -31,6 +31,9 @@
81118 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
81119 * <prasanna@in.ibm.com> added function-return probes.
81120 */
81121 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81122 +#define __INCLUDED_BY_HIDESYM 1
81123 +#endif
81124 #include <linux/kprobes.h>
81125 #include <linux/hash.h>
81126 #include <linux/init.h>
81127 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
81128 * kernel image and loaded module images reside. This is required
81129 * so x86_64 can correctly handle the %rip-relative fixups.
81130 */
81131 - kip->insns = module_alloc(PAGE_SIZE);
81132 + kip->insns = module_alloc_exec(PAGE_SIZE);
81133 if (!kip->insns) {
81134 kfree(kip);
81135 return NULL;
81136 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
81137 */
81138 if (!list_is_singular(&kip->list)) {
81139 list_del(&kip->list);
81140 - module_free(NULL, kip->insns);
81141 + module_free_exec(NULL, kip->insns);
81142 kfree(kip);
81143 }
81144 return 1;
81145 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
81146 {
81147 int i, err = 0;
81148 unsigned long offset = 0, size = 0;
81149 - char *modname, namebuf[128];
81150 + char *modname, namebuf[KSYM_NAME_LEN];
81151 const char *symbol_name;
81152 void *addr;
81153 struct kprobe_blackpoint *kb;
81154 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
81155 kprobe_type = "k";
81156
81157 if (sym)
81158 - seq_printf(pi, "%p %s %s+0x%x %s ",
81159 + seq_printf(pi, "%pK %s %s+0x%x %s ",
81160 p->addr, kprobe_type, sym, offset,
81161 (modname ? modname : " "));
81162 else
81163 - seq_printf(pi, "%p %s %p ",
81164 + seq_printf(pi, "%pK %s %pK ",
81165 p->addr, kprobe_type, p->addr);
81166
81167 if (!pp)
81168 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
81169 const char *sym = NULL;
81170 unsigned int i = *(loff_t *) v;
81171 unsigned long offset = 0;
81172 - char *modname, namebuf[128];
81173 + char *modname, namebuf[KSYM_NAME_LEN];
81174
81175 head = &kprobe_table[i];
81176 preempt_disable();
81177 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
81178 index 6ada93c..dce7d5d 100644
81179 --- a/kernel/ksysfs.c
81180 +++ b/kernel/ksysfs.c
81181 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
81182 {
81183 if (count+1 > UEVENT_HELPER_PATH_LEN)
81184 return -ENOENT;
81185 + if (!capable(CAP_SYS_ADMIN))
81186 + return -EPERM;
81187 memcpy(uevent_helper, buf, count);
81188 uevent_helper[count] = '\0';
81189 if (count && uevent_helper[count-1] == '\n')
81190 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
81191 return count;
81192 }
81193
81194 -static struct bin_attribute notes_attr = {
81195 +static bin_attribute_no_const notes_attr __read_only = {
81196 .attr = {
81197 .name = "notes",
81198 .mode = S_IRUGO,
81199 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81200 index e16c45b..6f49c48 100644
81201 --- a/kernel/lockdep.c
81202 +++ b/kernel/lockdep.c
81203 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81204 end = (unsigned long) &_end,
81205 addr = (unsigned long) obj;
81206
81207 +#ifdef CONFIG_PAX_KERNEXEC
81208 + start = ktla_ktva(start);
81209 +#endif
81210 +
81211 /*
81212 * static variable?
81213 */
81214 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81215 if (!static_obj(lock->key)) {
81216 debug_locks_off();
81217 printk("INFO: trying to register non-static key.\n");
81218 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81219 printk("the code is fine but needs lockdep annotation.\n");
81220 printk("turning off the locking correctness validator.\n");
81221 dump_stack();
81222 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81223 if (!class)
81224 return 0;
81225 }
81226 - atomic_inc((atomic_t *)&class->ops);
81227 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81228 if (very_verbose(class)) {
81229 printk("\nacquire class [%p] %s", class->key, class->name);
81230 if (class->name_version > 1)
81231 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81232 index b2c71c5..7b88d63 100644
81233 --- a/kernel/lockdep_proc.c
81234 +++ b/kernel/lockdep_proc.c
81235 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81236 return 0;
81237 }
81238
81239 - seq_printf(m, "%p", class->key);
81240 + seq_printf(m, "%pK", class->key);
81241 #ifdef CONFIG_DEBUG_LOCKDEP
81242 seq_printf(m, " OPS:%8ld", class->ops);
81243 #endif
81244 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81245
81246 list_for_each_entry(entry, &class->locks_after, entry) {
81247 if (entry->distance == 1) {
81248 - seq_printf(m, " -> [%p] ", entry->class->key);
81249 + seq_printf(m, " -> [%pK] ", entry->class->key);
81250 print_name(m, entry->class);
81251 seq_puts(m, "\n");
81252 }
81253 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81254 if (!class->key)
81255 continue;
81256
81257 - seq_printf(m, "[%p] ", class->key);
81258 + seq_printf(m, "[%pK] ", class->key);
81259 print_name(m, class);
81260 seq_puts(m, "\n");
81261 }
81262 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81263 if (!i)
81264 seq_line(m, '-', 40-namelen, namelen);
81265
81266 - snprintf(ip, sizeof(ip), "[<%p>]",
81267 + snprintf(ip, sizeof(ip), "[<%pK>]",
81268 (void *)class->contention_point[i]);
81269 seq_printf(m, "%40s %14lu %29s %pS\n",
81270 name, stats->contention_point[i],
81271 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81272 if (!i)
81273 seq_line(m, '-', 40-namelen, namelen);
81274
81275 - snprintf(ip, sizeof(ip), "[<%p>]",
81276 + snprintf(ip, sizeof(ip), "[<%pK>]",
81277 (void *)class->contending_point[i]);
81278 seq_printf(m, "%40s %14lu %29s %pS\n",
81279 name, stats->contending_point[i],
81280 diff --git a/kernel/module.c b/kernel/module.c
81281 index 2069158..71101bb 100644
81282 --- a/kernel/module.c
81283 +++ b/kernel/module.c
81284 @@ -61,6 +61,7 @@
81285 #include <linux/pfn.h>
81286 #include <linux/bsearch.h>
81287 #include <linux/fips.h>
81288 +#include <linux/grsecurity.h>
81289 #include <uapi/linux/module.h>
81290 #include "module-internal.h"
81291
81292 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81293
81294 /* Bounds of module allocation, for speeding __module_address.
81295 * Protected by module_mutex. */
81296 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81297 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81298 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81299
81300 int register_module_notifier(struct notifier_block * nb)
81301 {
81302 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81303 return true;
81304
81305 list_for_each_entry_rcu(mod, &modules, list) {
81306 - struct symsearch arr[] = {
81307 + struct symsearch modarr[] = {
81308 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81309 NOT_GPL_ONLY, false },
81310 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81311 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81312 if (mod->state == MODULE_STATE_UNFORMED)
81313 continue;
81314
81315 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81316 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81317 return true;
81318 }
81319 return false;
81320 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81321 if (!pcpusec->sh_size)
81322 return 0;
81323
81324 - if (align > PAGE_SIZE) {
81325 + if (align-1 >= PAGE_SIZE) {
81326 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81327 mod->name, align, PAGE_SIZE);
81328 align = PAGE_SIZE;
81329 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81330 static ssize_t show_coresize(struct module_attribute *mattr,
81331 struct module_kobject *mk, char *buffer)
81332 {
81333 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81334 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81335 }
81336
81337 static struct module_attribute modinfo_coresize =
81338 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81339 static ssize_t show_initsize(struct module_attribute *mattr,
81340 struct module_kobject *mk, char *buffer)
81341 {
81342 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81343 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81344 }
81345
81346 static struct module_attribute modinfo_initsize =
81347 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81348 */
81349 #ifdef CONFIG_SYSFS
81350
81351 -#ifdef CONFIG_KALLSYMS
81352 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81353 static inline bool sect_empty(const Elf_Shdr *sect)
81354 {
81355 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81356 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81357 {
81358 unsigned int notes, loaded, i;
81359 struct module_notes_attrs *notes_attrs;
81360 - struct bin_attribute *nattr;
81361 + bin_attribute_no_const *nattr;
81362
81363 /* failed to create section attributes, so can't create notes */
81364 if (!mod->sect_attrs)
81365 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81366 static int module_add_modinfo_attrs(struct module *mod)
81367 {
81368 struct module_attribute *attr;
81369 - struct module_attribute *temp_attr;
81370 + module_attribute_no_const *temp_attr;
81371 int error = 0;
81372 int i;
81373
81374 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81375
81376 static void unset_module_core_ro_nx(struct module *mod)
81377 {
81378 - set_page_attributes(mod->module_core + mod->core_text_size,
81379 - mod->module_core + mod->core_size,
81380 + set_page_attributes(mod->module_core_rw,
81381 + mod->module_core_rw + mod->core_size_rw,
81382 set_memory_x);
81383 - set_page_attributes(mod->module_core,
81384 - mod->module_core + mod->core_ro_size,
81385 + set_page_attributes(mod->module_core_rx,
81386 + mod->module_core_rx + mod->core_size_rx,
81387 set_memory_rw);
81388 }
81389
81390 static void unset_module_init_ro_nx(struct module *mod)
81391 {
81392 - set_page_attributes(mod->module_init + mod->init_text_size,
81393 - mod->module_init + mod->init_size,
81394 + set_page_attributes(mod->module_init_rw,
81395 + mod->module_init_rw + mod->init_size_rw,
81396 set_memory_x);
81397 - set_page_attributes(mod->module_init,
81398 - mod->module_init + mod->init_ro_size,
81399 + set_page_attributes(mod->module_init_rx,
81400 + mod->module_init_rx + mod->init_size_rx,
81401 set_memory_rw);
81402 }
81403
81404 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81405 list_for_each_entry_rcu(mod, &modules, list) {
81406 if (mod->state == MODULE_STATE_UNFORMED)
81407 continue;
81408 - if ((mod->module_core) && (mod->core_text_size)) {
81409 - set_page_attributes(mod->module_core,
81410 - mod->module_core + mod->core_text_size,
81411 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81412 + set_page_attributes(mod->module_core_rx,
81413 + mod->module_core_rx + mod->core_size_rx,
81414 set_memory_rw);
81415 }
81416 - if ((mod->module_init) && (mod->init_text_size)) {
81417 - set_page_attributes(mod->module_init,
81418 - mod->module_init + mod->init_text_size,
81419 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81420 + set_page_attributes(mod->module_init_rx,
81421 + mod->module_init_rx + mod->init_size_rx,
81422 set_memory_rw);
81423 }
81424 }
81425 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81426 list_for_each_entry_rcu(mod, &modules, list) {
81427 if (mod->state == MODULE_STATE_UNFORMED)
81428 continue;
81429 - if ((mod->module_core) && (mod->core_text_size)) {
81430 - set_page_attributes(mod->module_core,
81431 - mod->module_core + mod->core_text_size,
81432 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81433 + set_page_attributes(mod->module_core_rx,
81434 + mod->module_core_rx + mod->core_size_rx,
81435 set_memory_ro);
81436 }
81437 - if ((mod->module_init) && (mod->init_text_size)) {
81438 - set_page_attributes(mod->module_init,
81439 - mod->module_init + mod->init_text_size,
81440 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81441 + set_page_attributes(mod->module_init_rx,
81442 + mod->module_init_rx + mod->init_size_rx,
81443 set_memory_ro);
81444 }
81445 }
81446 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81447
81448 /* This may be NULL, but that's OK */
81449 unset_module_init_ro_nx(mod);
81450 - module_free(mod, mod->module_init);
81451 + module_free(mod, mod->module_init_rw);
81452 + module_free_exec(mod, mod->module_init_rx);
81453 kfree(mod->args);
81454 percpu_modfree(mod);
81455
81456 /* Free lock-classes: */
81457 - lockdep_free_key_range(mod->module_core, mod->core_size);
81458 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81459 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81460
81461 /* Finally, free the core (containing the module structure) */
81462 unset_module_core_ro_nx(mod);
81463 - module_free(mod, mod->module_core);
81464 + module_free_exec(mod, mod->module_core_rx);
81465 + module_free(mod, mod->module_core_rw);
81466
81467 #ifdef CONFIG_MPU
81468 update_protections(current->mm);
81469 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81470 int ret = 0;
81471 const struct kernel_symbol *ksym;
81472
81473 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81474 + int is_fs_load = 0;
81475 + int register_filesystem_found = 0;
81476 + char *p;
81477 +
81478 + p = strstr(mod->args, "grsec_modharden_fs");
81479 + if (p) {
81480 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81481 + /* copy \0 as well */
81482 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81483 + is_fs_load = 1;
81484 + }
81485 +#endif
81486 +
81487 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81488 const char *name = info->strtab + sym[i].st_name;
81489
81490 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81491 + /* it's a real shame this will never get ripped and copied
81492 + upstream! ;(
81493 + */
81494 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81495 + register_filesystem_found = 1;
81496 +#endif
81497 +
81498 switch (sym[i].st_shndx) {
81499 case SHN_COMMON:
81500 /* We compiled with -fno-common. These are not
81501 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81502 ksym = resolve_symbol_wait(mod, info, name);
81503 /* Ok if resolved. */
81504 if (ksym && !IS_ERR(ksym)) {
81505 + pax_open_kernel();
81506 sym[i].st_value = ksym->value;
81507 + pax_close_kernel();
81508 break;
81509 }
81510
81511 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81512 secbase = (unsigned long)mod_percpu(mod);
81513 else
81514 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81515 + pax_open_kernel();
81516 sym[i].st_value += secbase;
81517 + pax_close_kernel();
81518 break;
81519 }
81520 }
81521
81522 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81523 + if (is_fs_load && !register_filesystem_found) {
81524 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81525 + ret = -EPERM;
81526 + }
81527 +#endif
81528 +
81529 return ret;
81530 }
81531
81532 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81533 || s->sh_entsize != ~0UL
81534 || strstarts(sname, ".init"))
81535 continue;
81536 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81537 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81538 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81539 + else
81540 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81541 pr_debug("\t%s\n", sname);
81542 }
81543 - switch (m) {
81544 - case 0: /* executable */
81545 - mod->core_size = debug_align(mod->core_size);
81546 - mod->core_text_size = mod->core_size;
81547 - break;
81548 - case 1: /* RO: text and ro-data */
81549 - mod->core_size = debug_align(mod->core_size);
81550 - mod->core_ro_size = mod->core_size;
81551 - break;
81552 - case 3: /* whole core */
81553 - mod->core_size = debug_align(mod->core_size);
81554 - break;
81555 - }
81556 }
81557
81558 pr_debug("Init section allocation order:\n");
81559 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81560 || s->sh_entsize != ~0UL
81561 || !strstarts(sname, ".init"))
81562 continue;
81563 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81564 - | INIT_OFFSET_MASK);
81565 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81566 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81567 + else
81568 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81569 + s->sh_entsize |= INIT_OFFSET_MASK;
81570 pr_debug("\t%s\n", sname);
81571 }
81572 - switch (m) {
81573 - case 0: /* executable */
81574 - mod->init_size = debug_align(mod->init_size);
81575 - mod->init_text_size = mod->init_size;
81576 - break;
81577 - case 1: /* RO: text and ro-data */
81578 - mod->init_size = debug_align(mod->init_size);
81579 - mod->init_ro_size = mod->init_size;
81580 - break;
81581 - case 3: /* whole init */
81582 - mod->init_size = debug_align(mod->init_size);
81583 - break;
81584 - }
81585 }
81586 }
81587
81588 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81589
81590 /* Put symbol section at end of init part of module. */
81591 symsect->sh_flags |= SHF_ALLOC;
81592 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81593 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81594 info->index.sym) | INIT_OFFSET_MASK;
81595 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81596
81597 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81598 }
81599
81600 /* Append room for core symbols at end of core part. */
81601 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81602 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81603 - mod->core_size += strtab_size;
81604 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81605 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81606 + mod->core_size_rx += strtab_size;
81607
81608 /* Put string table section at end of init part of module. */
81609 strsect->sh_flags |= SHF_ALLOC;
81610 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81611 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81612 info->index.str) | INIT_OFFSET_MASK;
81613 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81614 }
81615 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81616 /* Make sure we get permanent strtab: don't use info->strtab. */
81617 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81618
81619 + pax_open_kernel();
81620 +
81621 /* Set types up while we still have access to sections. */
81622 for (i = 0; i < mod->num_symtab; i++)
81623 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81624
81625 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81626 - mod->core_strtab = s = mod->module_core + info->stroffs;
81627 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81628 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81629 src = mod->symtab;
81630 for (ndst = i = 0; i < mod->num_symtab; i++) {
81631 if (i == 0 ||
81632 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81633 }
81634 }
81635 mod->core_num_syms = ndst;
81636 +
81637 + pax_close_kernel();
81638 }
81639 #else
81640 static inline void layout_symtab(struct module *mod, struct load_info *info)
81641 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81642 return vmalloc_exec(size);
81643 }
81644
81645 -static void *module_alloc_update_bounds(unsigned long size)
81646 +static void *module_alloc_update_bounds_rw(unsigned long size)
81647 {
81648 void *ret = module_alloc(size);
81649
81650 if (ret) {
81651 mutex_lock(&module_mutex);
81652 /* Update module bounds. */
81653 - if ((unsigned long)ret < module_addr_min)
81654 - module_addr_min = (unsigned long)ret;
81655 - if ((unsigned long)ret + size > module_addr_max)
81656 - module_addr_max = (unsigned long)ret + size;
81657 + if ((unsigned long)ret < module_addr_min_rw)
81658 + module_addr_min_rw = (unsigned long)ret;
81659 + if ((unsigned long)ret + size > module_addr_max_rw)
81660 + module_addr_max_rw = (unsigned long)ret + size;
81661 + mutex_unlock(&module_mutex);
81662 + }
81663 + return ret;
81664 +}
81665 +
81666 +static void *module_alloc_update_bounds_rx(unsigned long size)
81667 +{
81668 + void *ret = module_alloc_exec(size);
81669 +
81670 + if (ret) {
81671 + mutex_lock(&module_mutex);
81672 + /* Update module bounds. */
81673 + if ((unsigned long)ret < module_addr_min_rx)
81674 + module_addr_min_rx = (unsigned long)ret;
81675 + if ((unsigned long)ret + size > module_addr_max_rx)
81676 + module_addr_max_rx = (unsigned long)ret + size;
81677 mutex_unlock(&module_mutex);
81678 }
81679 return ret;
81680 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81681 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81682 {
81683 const char *modmagic = get_modinfo(info, "vermagic");
81684 + const char *license = get_modinfo(info, "license");
81685 int err;
81686
81687 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81688 + if (!license || !license_is_gpl_compatible(license))
81689 + return -ENOEXEC;
81690 +#endif
81691 +
81692 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81693 modmagic = NULL;
81694
81695 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81696 }
81697
81698 /* Set up license info based on the info section */
81699 - set_license(mod, get_modinfo(info, "license"));
81700 + set_license(mod, license);
81701
81702 return 0;
81703 }
81704 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81705 void *ptr;
81706
81707 /* Do the allocs. */
81708 - ptr = module_alloc_update_bounds(mod->core_size);
81709 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81710 /*
81711 * The pointer to this block is stored in the module structure
81712 * which is inside the block. Just mark it as not being a
81713 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81714 if (!ptr)
81715 return -ENOMEM;
81716
81717 - memset(ptr, 0, mod->core_size);
81718 - mod->module_core = ptr;
81719 + memset(ptr, 0, mod->core_size_rw);
81720 + mod->module_core_rw = ptr;
81721
81722 - if (mod->init_size) {
81723 - ptr = module_alloc_update_bounds(mod->init_size);
81724 + if (mod->init_size_rw) {
81725 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81726 /*
81727 * The pointer to this block is stored in the module structure
81728 * which is inside the block. This block doesn't need to be
81729 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81730 */
81731 kmemleak_ignore(ptr);
81732 if (!ptr) {
81733 - module_free(mod, mod->module_core);
81734 + module_free(mod, mod->module_core_rw);
81735 return -ENOMEM;
81736 }
81737 - memset(ptr, 0, mod->init_size);
81738 - mod->module_init = ptr;
81739 + memset(ptr, 0, mod->init_size_rw);
81740 + mod->module_init_rw = ptr;
81741 } else
81742 - mod->module_init = NULL;
81743 + mod->module_init_rw = NULL;
81744 +
81745 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81746 + kmemleak_not_leak(ptr);
81747 + if (!ptr) {
81748 + if (mod->module_init_rw)
81749 + module_free(mod, mod->module_init_rw);
81750 + module_free(mod, mod->module_core_rw);
81751 + return -ENOMEM;
81752 + }
81753 +
81754 + pax_open_kernel();
81755 + memset(ptr, 0, mod->core_size_rx);
81756 + pax_close_kernel();
81757 + mod->module_core_rx = ptr;
81758 +
81759 + if (mod->init_size_rx) {
81760 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81761 + kmemleak_ignore(ptr);
81762 + if (!ptr && mod->init_size_rx) {
81763 + module_free_exec(mod, mod->module_core_rx);
81764 + if (mod->module_init_rw)
81765 + module_free(mod, mod->module_init_rw);
81766 + module_free(mod, mod->module_core_rw);
81767 + return -ENOMEM;
81768 + }
81769 +
81770 + pax_open_kernel();
81771 + memset(ptr, 0, mod->init_size_rx);
81772 + pax_close_kernel();
81773 + mod->module_init_rx = ptr;
81774 + } else
81775 + mod->module_init_rx = NULL;
81776
81777 /* Transfer each section which specifies SHF_ALLOC */
81778 pr_debug("final section addresses:\n");
81779 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81780 if (!(shdr->sh_flags & SHF_ALLOC))
81781 continue;
81782
81783 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81784 - dest = mod->module_init
81785 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81786 - else
81787 - dest = mod->module_core + shdr->sh_entsize;
81788 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81789 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81790 + dest = mod->module_init_rw
81791 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81792 + else
81793 + dest = mod->module_init_rx
81794 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81795 + } else {
81796 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81797 + dest = mod->module_core_rw + shdr->sh_entsize;
81798 + else
81799 + dest = mod->module_core_rx + shdr->sh_entsize;
81800 + }
81801 +
81802 + if (shdr->sh_type != SHT_NOBITS) {
81803 +
81804 +#ifdef CONFIG_PAX_KERNEXEC
81805 +#ifdef CONFIG_X86_64
81806 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81807 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81808 +#endif
81809 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81810 + pax_open_kernel();
81811 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81812 + pax_close_kernel();
81813 + } else
81814 +#endif
81815
81816 - if (shdr->sh_type != SHT_NOBITS)
81817 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81818 + }
81819 /* Update sh_addr to point to copy in image. */
81820 - shdr->sh_addr = (unsigned long)dest;
81821 +
81822 +#ifdef CONFIG_PAX_KERNEXEC
81823 + if (shdr->sh_flags & SHF_EXECINSTR)
81824 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81825 + else
81826 +#endif
81827 +
81828 + shdr->sh_addr = (unsigned long)dest;
81829 pr_debug("\t0x%lx %s\n",
81830 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81831 }
81832 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81833 * Do it before processing of module parameters, so the module
81834 * can provide parameter accessor functions of its own.
81835 */
81836 - if (mod->module_init)
81837 - flush_icache_range((unsigned long)mod->module_init,
81838 - (unsigned long)mod->module_init
81839 - + mod->init_size);
81840 - flush_icache_range((unsigned long)mod->module_core,
81841 - (unsigned long)mod->module_core + mod->core_size);
81842 + if (mod->module_init_rx)
81843 + flush_icache_range((unsigned long)mod->module_init_rx,
81844 + (unsigned long)mod->module_init_rx
81845 + + mod->init_size_rx);
81846 + flush_icache_range((unsigned long)mod->module_core_rx,
81847 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
81848
81849 set_fs(old_fs);
81850 }
81851 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
81852 static void module_deallocate(struct module *mod, struct load_info *info)
81853 {
81854 percpu_modfree(mod);
81855 - module_free(mod, mod->module_init);
81856 - module_free(mod, mod->module_core);
81857 + module_free_exec(mod, mod->module_init_rx);
81858 + module_free_exec(mod, mod->module_core_rx);
81859 + module_free(mod, mod->module_init_rw);
81860 + module_free(mod, mod->module_core_rw);
81861 }
81862
81863 int __weak module_finalize(const Elf_Ehdr *hdr,
81864 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
81865 static int post_relocation(struct module *mod, const struct load_info *info)
81866 {
81867 /* Sort exception table now relocations are done. */
81868 + pax_open_kernel();
81869 sort_extable(mod->extable, mod->extable + mod->num_exentries);
81870 + pax_close_kernel();
81871
81872 /* Copy relocated percpu area over. */
81873 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
81874 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
81875 MODULE_STATE_COMING, mod);
81876
81877 /* Set RO and NX regions for core */
81878 - set_section_ro_nx(mod->module_core,
81879 - mod->core_text_size,
81880 - mod->core_ro_size,
81881 - mod->core_size);
81882 + set_section_ro_nx(mod->module_core_rx,
81883 + mod->core_size_rx,
81884 + mod->core_size_rx,
81885 + mod->core_size_rx);
81886
81887 /* Set RO and NX regions for init */
81888 - set_section_ro_nx(mod->module_init,
81889 - mod->init_text_size,
81890 - mod->init_ro_size,
81891 - mod->init_size);
81892 + set_section_ro_nx(mod->module_init_rx,
81893 + mod->init_size_rx,
81894 + mod->init_size_rx,
81895 + mod->init_size_rx);
81896
81897 do_mod_ctors(mod);
81898 /* Start the module */
81899 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
81900 mod->strtab = mod->core_strtab;
81901 #endif
81902 unset_module_init_ro_nx(mod);
81903 - module_free(mod, mod->module_init);
81904 - mod->module_init = NULL;
81905 - mod->init_size = 0;
81906 - mod->init_ro_size = 0;
81907 - mod->init_text_size = 0;
81908 + module_free(mod, mod->module_init_rw);
81909 + module_free_exec(mod, mod->module_init_rx);
81910 + mod->module_init_rw = NULL;
81911 + mod->module_init_rx = NULL;
81912 + mod->init_size_rw = 0;
81913 + mod->init_size_rx = 0;
81914 mutex_unlock(&module_mutex);
81915 wake_up_all(&module_wq);
81916
81917 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
81918 if (err)
81919 goto free_unload;
81920
81921 + /* Now copy in args */
81922 + mod->args = strndup_user(uargs, ~0UL >> 1);
81923 + if (IS_ERR(mod->args)) {
81924 + err = PTR_ERR(mod->args);
81925 + goto free_unload;
81926 + }
81927 +
81928 /* Set up MODINFO_ATTR fields */
81929 setup_modinfo(mod, info);
81930
81931 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81932 + {
81933 + char *p, *p2;
81934 +
81935 + if (strstr(mod->args, "grsec_modharden_netdev")) {
81936 + 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);
81937 + err = -EPERM;
81938 + goto free_modinfo;
81939 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
81940 + p += sizeof("grsec_modharden_normal") - 1;
81941 + p2 = strstr(p, "_");
81942 + if (p2) {
81943 + *p2 = '\0';
81944 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
81945 + *p2 = '_';
81946 + }
81947 + err = -EPERM;
81948 + goto free_modinfo;
81949 + }
81950 + }
81951 +#endif
81952 +
81953 /* Fix up syms, so that st_value is a pointer to location. */
81954 err = simplify_symbols(mod, info);
81955 if (err < 0)
81956 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
81957
81958 flush_module_icache(mod);
81959
81960 - /* Now copy in args */
81961 - mod->args = strndup_user(uargs, ~0UL >> 1);
81962 - if (IS_ERR(mod->args)) {
81963 - err = PTR_ERR(mod->args);
81964 - goto free_arch_cleanup;
81965 - }
81966 -
81967 dynamic_debug_setup(info->debug, info->num_debug);
81968
81969 /* Finally it's fully formed, ready to start executing. */
81970 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
81971 ddebug_cleanup:
81972 dynamic_debug_remove(info->debug);
81973 synchronize_sched();
81974 - kfree(mod->args);
81975 - free_arch_cleanup:
81976 module_arch_cleanup(mod);
81977 free_modinfo:
81978 free_modinfo(mod);
81979 + kfree(mod->args);
81980 free_unload:
81981 module_unload_free(mod);
81982 unlink_mod:
81983 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
81984 unsigned long nextval;
81985
81986 /* At worse, next value is at end of module */
81987 - if (within_module_init(addr, mod))
81988 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
81989 + if (within_module_init_rx(addr, mod))
81990 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
81991 + else if (within_module_init_rw(addr, mod))
81992 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
81993 + else if (within_module_core_rx(addr, mod))
81994 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
81995 + else if (within_module_core_rw(addr, mod))
81996 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
81997 else
81998 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
81999 + return NULL;
82000
82001 /* Scan for closest preceding symbol, and next symbol. (ELF
82002 starts real symbols at 1). */
82003 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
82004 return 0;
82005
82006 seq_printf(m, "%s %u",
82007 - mod->name, mod->init_size + mod->core_size);
82008 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
82009 print_unload_info(m, mod);
82010
82011 /* Informative for users. */
82012 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
82013 mod->state == MODULE_STATE_COMING ? "Loading":
82014 "Live");
82015 /* Used by oprofile and other similar tools. */
82016 - seq_printf(m, " 0x%pK", mod->module_core);
82017 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
82018
82019 /* Taints info */
82020 if (mod->taints)
82021 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
82022
82023 static int __init proc_modules_init(void)
82024 {
82025 +#ifndef CONFIG_GRKERNSEC_HIDESYM
82026 +#ifdef CONFIG_GRKERNSEC_PROC_USER
82027 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82028 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82029 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
82030 +#else
82031 proc_create("modules", 0, NULL, &proc_modules_operations);
82032 +#endif
82033 +#else
82034 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82035 +#endif
82036 return 0;
82037 }
82038 module_init(proc_modules_init);
82039 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
82040 {
82041 struct module *mod;
82042
82043 - if (addr < module_addr_min || addr > module_addr_max)
82044 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
82045 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
82046 return NULL;
82047
82048 list_for_each_entry_rcu(mod, &modules, list) {
82049 if (mod->state == MODULE_STATE_UNFORMED)
82050 continue;
82051 - if (within_module_core(addr, mod)
82052 - || within_module_init(addr, mod))
82053 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
82054 return mod;
82055 }
82056 return NULL;
82057 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
82058 */
82059 struct module *__module_text_address(unsigned long addr)
82060 {
82061 - struct module *mod = __module_address(addr);
82062 + struct module *mod;
82063 +
82064 +#ifdef CONFIG_X86_32
82065 + addr = ktla_ktva(addr);
82066 +#endif
82067 +
82068 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
82069 + return NULL;
82070 +
82071 + mod = __module_address(addr);
82072 +
82073 if (mod) {
82074 /* Make sure it's within the text section. */
82075 - if (!within(addr, mod->module_init, mod->init_text_size)
82076 - && !within(addr, mod->module_core, mod->core_text_size))
82077 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
82078 mod = NULL;
82079 }
82080 return mod;
82081 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
82082 index 7e3443f..b2a1e6b 100644
82083 --- a/kernel/mutex-debug.c
82084 +++ b/kernel/mutex-debug.c
82085 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
82086 }
82087
82088 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82089 - struct thread_info *ti)
82090 + struct task_struct *task)
82091 {
82092 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
82093
82094 /* Mark the current thread as blocked on the lock: */
82095 - ti->task->blocked_on = waiter;
82096 + task->blocked_on = waiter;
82097 }
82098
82099 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82100 - struct thread_info *ti)
82101 + struct task_struct *task)
82102 {
82103 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
82104 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
82105 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
82106 - ti->task->blocked_on = NULL;
82107 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
82108 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
82109 + task->blocked_on = NULL;
82110
82111 list_del_init(&waiter->list);
82112 waiter->task = NULL;
82113 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
82114 index 0799fd3..d06ae3b 100644
82115 --- a/kernel/mutex-debug.h
82116 +++ b/kernel/mutex-debug.h
82117 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
82118 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
82119 extern void debug_mutex_add_waiter(struct mutex *lock,
82120 struct mutex_waiter *waiter,
82121 - struct thread_info *ti);
82122 + struct task_struct *task);
82123 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82124 - struct thread_info *ti);
82125 + struct task_struct *task);
82126 extern void debug_mutex_unlock(struct mutex *lock);
82127 extern void debug_mutex_init(struct mutex *lock, const char *name,
82128 struct lock_class_key *key);
82129 diff --git a/kernel/mutex.c b/kernel/mutex.c
82130 index a52ee7bb..f361f16 100644
82131 --- a/kernel/mutex.c
82132 +++ b/kernel/mutex.c
82133 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
82134 node->locked = 1;
82135 return;
82136 }
82137 - ACCESS_ONCE(prev->next) = node;
82138 + ACCESS_ONCE_RW(prev->next) = node;
82139 smp_wmb();
82140 /* Wait until the lock holder passes the lock down */
82141 while (!ACCESS_ONCE(node->locked))
82142 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
82143 while (!(next = ACCESS_ONCE(node->next)))
82144 arch_mutex_cpu_relax();
82145 }
82146 - ACCESS_ONCE(next->locked) = 1;
82147 + ACCESS_ONCE_RW(next->locked) = 1;
82148 smp_wmb();
82149 }
82150
82151 @@ -514,7 +514,7 @@ slowpath:
82152 spin_lock_mutex(&lock->wait_lock, flags);
82153
82154 debug_mutex_lock_common(lock, &waiter);
82155 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
82156 + debug_mutex_add_waiter(lock, &waiter, task);
82157
82158 /* add waiting tasks to the end of the waitqueue (FIFO): */
82159 list_add_tail(&waiter.list, &lock->wait_list);
82160 @@ -565,7 +565,7 @@ slowpath:
82161 done:
82162 lock_acquired(&lock->dep_map, ip);
82163 /* got the lock - rejoice! */
82164 - mutex_remove_waiter(lock, &waiter, current_thread_info());
82165 + mutex_remove_waiter(lock, &waiter, task);
82166 mutex_set_owner(lock);
82167
82168 if (!__builtin_constant_p(ww_ctx == NULL)) {
82169 @@ -604,7 +604,7 @@ done:
82170 return 0;
82171
82172 err:
82173 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
82174 + mutex_remove_waiter(lock, &waiter, task);
82175 spin_unlock_mutex(&lock->wait_lock, flags);
82176 debug_mutex_free_waiter(&waiter);
82177 mutex_release(&lock->dep_map, 1, ip);
82178 diff --git a/kernel/notifier.c b/kernel/notifier.c
82179 index 2d5cc4c..d9ea600 100644
82180 --- a/kernel/notifier.c
82181 +++ b/kernel/notifier.c
82182 @@ -5,6 +5,7 @@
82183 #include <linux/rcupdate.h>
82184 #include <linux/vmalloc.h>
82185 #include <linux/reboot.h>
82186 +#include <linux/mm.h>
82187
82188 /*
82189 * Notifier list for kernel code which wants to be called
82190 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
82191 while ((*nl) != NULL) {
82192 if (n->priority > (*nl)->priority)
82193 break;
82194 - nl = &((*nl)->next);
82195 + nl = (struct notifier_block **)&((*nl)->next);
82196 }
82197 - n->next = *nl;
82198 + pax_open_kernel();
82199 + *(const void **)&n->next = *nl;
82200 rcu_assign_pointer(*nl, n);
82201 + pax_close_kernel();
82202 return 0;
82203 }
82204
82205 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82206 return 0;
82207 if (n->priority > (*nl)->priority)
82208 break;
82209 - nl = &((*nl)->next);
82210 + nl = (struct notifier_block **)&((*nl)->next);
82211 }
82212 - n->next = *nl;
82213 + pax_open_kernel();
82214 + *(const void **)&n->next = *nl;
82215 rcu_assign_pointer(*nl, n);
82216 + pax_close_kernel();
82217 return 0;
82218 }
82219
82220 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82221 {
82222 while ((*nl) != NULL) {
82223 if ((*nl) == n) {
82224 + pax_open_kernel();
82225 rcu_assign_pointer(*nl, n->next);
82226 + pax_close_kernel();
82227 return 0;
82228 }
82229 - nl = &((*nl)->next);
82230 + nl = (struct notifier_block **)&((*nl)->next);
82231 }
82232 return -ENOENT;
82233 }
82234 diff --git a/kernel/panic.c b/kernel/panic.c
82235 index 8018646..b6a5b4f 100644
82236 --- a/kernel/panic.c
82237 +++ b/kernel/panic.c
82238 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82239 disable_trace_on_warning();
82240
82241 pr_warn("------------[ cut here ]------------\n");
82242 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82243 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82244 raw_smp_processor_id(), current->pid, file, line, caller);
82245
82246 if (args)
82247 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82248 */
82249 void __stack_chk_fail(void)
82250 {
82251 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82252 + dump_stack();
82253 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82254 __builtin_return_address(0));
82255 }
82256 EXPORT_SYMBOL(__stack_chk_fail);
82257 diff --git a/kernel/pid.c b/kernel/pid.c
82258 index 66505c1..87af12c 100644
82259 --- a/kernel/pid.c
82260 +++ b/kernel/pid.c
82261 @@ -33,6 +33,7 @@
82262 #include <linux/rculist.h>
82263 #include <linux/bootmem.h>
82264 #include <linux/hash.h>
82265 +#include <linux/security.h>
82266 #include <linux/pid_namespace.h>
82267 #include <linux/init_task.h>
82268 #include <linux/syscalls.h>
82269 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82270
82271 int pid_max = PID_MAX_DEFAULT;
82272
82273 -#define RESERVED_PIDS 300
82274 +#define RESERVED_PIDS 500
82275
82276 int pid_max_min = RESERVED_PIDS + 1;
82277 int pid_max_max = PID_MAX_LIMIT;
82278 @@ -439,10 +440,18 @@ EXPORT_SYMBOL(pid_task);
82279 */
82280 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82281 {
82282 + struct task_struct *task;
82283 +
82284 rcu_lockdep_assert(rcu_read_lock_held(),
82285 "find_task_by_pid_ns() needs rcu_read_lock()"
82286 " protection");
82287 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82288 +
82289 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82290 +
82291 + if (gr_pid_is_chrooted(task))
82292 + return NULL;
82293 +
82294 + return task;
82295 }
82296
82297 struct task_struct *find_task_by_vpid(pid_t vnr)
82298 @@ -450,6 +459,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82299 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82300 }
82301
82302 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82303 +{
82304 + rcu_lockdep_assert(rcu_read_lock_held(),
82305 + "find_task_by_pid_ns() needs rcu_read_lock()"
82306 + " protection");
82307 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82308 +}
82309 +
82310 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82311 {
82312 struct pid *pid;
82313 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82314 index 601bb36..f7e6f34 100644
82315 --- a/kernel/pid_namespace.c
82316 +++ b/kernel/pid_namespace.c
82317 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82318 void __user *buffer, size_t *lenp, loff_t *ppos)
82319 {
82320 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82321 - struct ctl_table tmp = *table;
82322 + ctl_table_no_const tmp = *table;
82323
82324 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82325 return -EPERM;
82326 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82327 index c7f31aa..2b44977 100644
82328 --- a/kernel/posix-cpu-timers.c
82329 +++ b/kernel/posix-cpu-timers.c
82330 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82331
82332 static __init int init_posix_cpu_timers(void)
82333 {
82334 - struct k_clock process = {
82335 + static struct k_clock process = {
82336 .clock_getres = process_cpu_clock_getres,
82337 .clock_get = process_cpu_clock_get,
82338 .timer_create = process_cpu_timer_create,
82339 .nsleep = process_cpu_nsleep,
82340 .nsleep_restart = process_cpu_nsleep_restart,
82341 };
82342 - struct k_clock thread = {
82343 + static struct k_clock thread = {
82344 .clock_getres = thread_cpu_clock_getres,
82345 .clock_get = thread_cpu_clock_get,
82346 .timer_create = thread_cpu_timer_create,
82347 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82348 index 424c2d4..679242f 100644
82349 --- a/kernel/posix-timers.c
82350 +++ b/kernel/posix-timers.c
82351 @@ -43,6 +43,7 @@
82352 #include <linux/hash.h>
82353 #include <linux/posix-clock.h>
82354 #include <linux/posix-timers.h>
82355 +#include <linux/grsecurity.h>
82356 #include <linux/syscalls.h>
82357 #include <linux/wait.h>
82358 #include <linux/workqueue.h>
82359 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82360 * which we beg off on and pass to do_sys_settimeofday().
82361 */
82362
82363 -static struct k_clock posix_clocks[MAX_CLOCKS];
82364 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82365
82366 /*
82367 * These ones are defined below.
82368 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82369 */
82370 static __init int init_posix_timers(void)
82371 {
82372 - struct k_clock clock_realtime = {
82373 + static struct k_clock clock_realtime = {
82374 .clock_getres = hrtimer_get_res,
82375 .clock_get = posix_clock_realtime_get,
82376 .clock_set = posix_clock_realtime_set,
82377 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82378 .timer_get = common_timer_get,
82379 .timer_del = common_timer_del,
82380 };
82381 - struct k_clock clock_monotonic = {
82382 + static struct k_clock clock_monotonic = {
82383 .clock_getres = hrtimer_get_res,
82384 .clock_get = posix_ktime_get_ts,
82385 .nsleep = common_nsleep,
82386 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82387 .timer_get = common_timer_get,
82388 .timer_del = common_timer_del,
82389 };
82390 - struct k_clock clock_monotonic_raw = {
82391 + static struct k_clock clock_monotonic_raw = {
82392 .clock_getres = hrtimer_get_res,
82393 .clock_get = posix_get_monotonic_raw,
82394 };
82395 - struct k_clock clock_realtime_coarse = {
82396 + static struct k_clock clock_realtime_coarse = {
82397 .clock_getres = posix_get_coarse_res,
82398 .clock_get = posix_get_realtime_coarse,
82399 };
82400 - struct k_clock clock_monotonic_coarse = {
82401 + static struct k_clock clock_monotonic_coarse = {
82402 .clock_getres = posix_get_coarse_res,
82403 .clock_get = posix_get_monotonic_coarse,
82404 };
82405 - struct k_clock clock_tai = {
82406 + static struct k_clock clock_tai = {
82407 .clock_getres = hrtimer_get_res,
82408 .clock_get = posix_get_tai,
82409 .nsleep = common_nsleep,
82410 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82411 .timer_get = common_timer_get,
82412 .timer_del = common_timer_del,
82413 };
82414 - struct k_clock clock_boottime = {
82415 + static struct k_clock clock_boottime = {
82416 .clock_getres = hrtimer_get_res,
82417 .clock_get = posix_get_boottime,
82418 .nsleep = common_nsleep,
82419 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82420 return;
82421 }
82422
82423 - posix_clocks[clock_id] = *new_clock;
82424 + posix_clocks[clock_id] = new_clock;
82425 }
82426 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82427
82428 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82429 return (id & CLOCKFD_MASK) == CLOCKFD ?
82430 &clock_posix_dynamic : &clock_posix_cpu;
82431
82432 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82433 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82434 return NULL;
82435 - return &posix_clocks[id];
82436 + return posix_clocks[id];
82437 }
82438
82439 static int common_timer_create(struct k_itimer *new_timer)
82440 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82441 struct k_clock *kc = clockid_to_kclock(which_clock);
82442 struct k_itimer *new_timer;
82443 int error, new_timer_id;
82444 - sigevent_t event;
82445 + sigevent_t event = { };
82446 int it_id_set = IT_ID_NOT_SET;
82447
82448 if (!kc)
82449 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82450 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82451 return -EFAULT;
82452
82453 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82454 + have their clock_set fptr set to a nosettime dummy function
82455 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82456 + call common_clock_set, which calls do_sys_settimeofday, which
82457 + we hook
82458 + */
82459 +
82460 return kc->clock_set(which_clock, &new_tp);
82461 }
82462
82463 diff --git a/kernel/power/process.c b/kernel/power/process.c
82464 index 06ec886..9dba35e 100644
82465 --- a/kernel/power/process.c
82466 +++ b/kernel/power/process.c
82467 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82468 unsigned int elapsed_msecs;
82469 bool wakeup = false;
82470 int sleep_usecs = USEC_PER_MSEC;
82471 + bool timedout = false;
82472
82473 do_gettimeofday(&start);
82474
82475 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82476
82477 while (true) {
82478 todo = 0;
82479 + if (time_after(jiffies, end_time))
82480 + timedout = true;
82481 read_lock(&tasklist_lock);
82482 do_each_thread(g, p) {
82483 if (p == current || !freeze_task(p))
82484 continue;
82485
82486 - if (!freezer_should_skip(p))
82487 + if (!freezer_should_skip(p)) {
82488 todo++;
82489 + if (timedout) {
82490 + printk(KERN_ERR "Task refusing to freeze:\n");
82491 + sched_show_task(p);
82492 + }
82493 + }
82494 } while_each_thread(g, p);
82495 read_unlock(&tasklist_lock);
82496
82497 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82498 todo += wq_busy;
82499 }
82500
82501 - if (!todo || time_after(jiffies, end_time))
82502 + if (!todo || timedout)
82503 break;
82504
82505 if (pm_wakeup_pending()) {
82506 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82507 index 5b5a708..ec7637e 100644
82508 --- a/kernel/printk/printk.c
82509 +++ b/kernel/printk/printk.c
82510 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82511 if (from_file && type != SYSLOG_ACTION_OPEN)
82512 return 0;
82513
82514 +#ifdef CONFIG_GRKERNSEC_DMESG
82515 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82516 + return -EPERM;
82517 +#endif
82518 +
82519 if (syslog_action_restricted(type)) {
82520 if (capable(CAP_SYSLOG))
82521 return 0;
82522 diff --git a/kernel/profile.c b/kernel/profile.c
82523 index 6631e1e..310c266 100644
82524 --- a/kernel/profile.c
82525 +++ b/kernel/profile.c
82526 @@ -37,7 +37,7 @@ struct profile_hit {
82527 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82528 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82529
82530 -static atomic_t *prof_buffer;
82531 +static atomic_unchecked_t *prof_buffer;
82532 static unsigned long prof_len, prof_shift;
82533
82534 int prof_on __read_mostly;
82535 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82536 hits[i].pc = 0;
82537 continue;
82538 }
82539 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82540 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82541 hits[i].hits = hits[i].pc = 0;
82542 }
82543 }
82544 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82545 * Add the current hit(s) and flush the write-queue out
82546 * to the global buffer:
82547 */
82548 - atomic_add(nr_hits, &prof_buffer[pc]);
82549 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82550 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82551 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82552 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82553 hits[i].pc = hits[i].hits = 0;
82554 }
82555 out:
82556 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82557 {
82558 unsigned long pc;
82559 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82560 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82561 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82562 }
82563 #endif /* !CONFIG_SMP */
82564
82565 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82566 return -EFAULT;
82567 buf++; p++; count--; read++;
82568 }
82569 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82570 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82571 if (copy_to_user(buf, (void *)pnt, count))
82572 return -EFAULT;
82573 read += count;
82574 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82575 }
82576 #endif
82577 profile_discard_flip_buffers();
82578 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82579 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82580 return count;
82581 }
82582
82583 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82584 index a146ee3..ffed4c3 100644
82585 --- a/kernel/ptrace.c
82586 +++ b/kernel/ptrace.c
82587 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82588 if (seize)
82589 flags |= PT_SEIZED;
82590 rcu_read_lock();
82591 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82592 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82593 flags |= PT_PTRACE_CAP;
82594 rcu_read_unlock();
82595 task->ptrace = flags;
82596 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82597 break;
82598 return -EIO;
82599 }
82600 - if (copy_to_user(dst, buf, retval))
82601 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82602 return -EFAULT;
82603 copied += retval;
82604 src += retval;
82605 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82606 bool seized = child->ptrace & PT_SEIZED;
82607 int ret = -EIO;
82608 siginfo_t siginfo, *si;
82609 - void __user *datavp = (void __user *) data;
82610 + void __user *datavp = (__force void __user *) data;
82611 unsigned long __user *datalp = datavp;
82612 unsigned long flags;
82613
82614 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82615 goto out;
82616 }
82617
82618 + if (gr_handle_ptrace(child, request)) {
82619 + ret = -EPERM;
82620 + goto out_put_task_struct;
82621 + }
82622 +
82623 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82624 ret = ptrace_attach(child, request, addr, data);
82625 /*
82626 * Some architectures need to do book-keeping after
82627 * a ptrace attach.
82628 */
82629 - if (!ret)
82630 + if (!ret) {
82631 arch_ptrace_attach(child);
82632 + gr_audit_ptrace(child);
82633 + }
82634 goto out_put_task_struct;
82635 }
82636
82637 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82638 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82639 if (copied != sizeof(tmp))
82640 return -EIO;
82641 - return put_user(tmp, (unsigned long __user *)data);
82642 + return put_user(tmp, (__force unsigned long __user *)data);
82643 }
82644
82645 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82646 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82647 }
82648
82649 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82650 - compat_long_t addr, compat_long_t data)
82651 + compat_ulong_t addr, compat_ulong_t data)
82652 {
82653 struct task_struct *child;
82654 long ret;
82655 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82656 goto out;
82657 }
82658
82659 + if (gr_handle_ptrace(child, request)) {
82660 + ret = -EPERM;
82661 + goto out_put_task_struct;
82662 + }
82663 +
82664 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82665 ret = ptrace_attach(child, request, addr, data);
82666 /*
82667 * Some architectures need to do book-keeping after
82668 * a ptrace attach.
82669 */
82670 - if (!ret)
82671 + if (!ret) {
82672 arch_ptrace_attach(child);
82673 + gr_audit_ptrace(child);
82674 + }
82675 goto out_put_task_struct;
82676 }
82677
82678 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82679 index cce6ba8..7c758b1f 100644
82680 --- a/kernel/rcupdate.c
82681 +++ b/kernel/rcupdate.c
82682 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82683 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82684 */
82685 if (till_stall_check < 3) {
82686 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82687 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82688 till_stall_check = 3;
82689 } else if (till_stall_check > 300) {
82690 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82691 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82692 till_stall_check = 300;
82693 }
82694 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82695 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82696 index aa34411..78e5ccb 100644
82697 --- a/kernel/rcutiny.c
82698 +++ b/kernel/rcutiny.c
82699 @@ -45,7 +45,7 @@
82700 /* Forward declarations for rcutiny_plugin.h. */
82701 struct rcu_ctrlblk;
82702 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82703 -static void rcu_process_callbacks(struct softirq_action *unused);
82704 +static void rcu_process_callbacks(void);
82705 static void __call_rcu(struct rcu_head *head,
82706 void (*func)(struct rcu_head *rcu),
82707 struct rcu_ctrlblk *rcp);
82708 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82709 false));
82710 }
82711
82712 -static void rcu_process_callbacks(struct softirq_action *unused)
82713 +static void rcu_process_callbacks(void)
82714 {
82715 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82716 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82717 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82718 index f4871e5..8ef5741 100644
82719 --- a/kernel/rcutorture.c
82720 +++ b/kernel/rcutorture.c
82721 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82722 { 0 };
82723 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82724 { 0 };
82725 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82726 -static atomic_t n_rcu_torture_alloc;
82727 -static atomic_t n_rcu_torture_alloc_fail;
82728 -static atomic_t n_rcu_torture_free;
82729 -static atomic_t n_rcu_torture_mberror;
82730 -static atomic_t n_rcu_torture_error;
82731 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82732 +static atomic_unchecked_t n_rcu_torture_alloc;
82733 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82734 +static atomic_unchecked_t n_rcu_torture_free;
82735 +static atomic_unchecked_t n_rcu_torture_mberror;
82736 +static atomic_unchecked_t n_rcu_torture_error;
82737 static long n_rcu_torture_barrier_error;
82738 static long n_rcu_torture_boost_ktrerror;
82739 static long n_rcu_torture_boost_rterror;
82740 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82741
82742 spin_lock_bh(&rcu_torture_lock);
82743 if (list_empty(&rcu_torture_freelist)) {
82744 - atomic_inc(&n_rcu_torture_alloc_fail);
82745 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82746 spin_unlock_bh(&rcu_torture_lock);
82747 return NULL;
82748 }
82749 - atomic_inc(&n_rcu_torture_alloc);
82750 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82751 p = rcu_torture_freelist.next;
82752 list_del_init(p);
82753 spin_unlock_bh(&rcu_torture_lock);
82754 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82755 static void
82756 rcu_torture_free(struct rcu_torture *p)
82757 {
82758 - atomic_inc(&n_rcu_torture_free);
82759 + atomic_inc_unchecked(&n_rcu_torture_free);
82760 spin_lock_bh(&rcu_torture_lock);
82761 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82762 spin_unlock_bh(&rcu_torture_lock);
82763 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82764 i = rp->rtort_pipe_count;
82765 if (i > RCU_TORTURE_PIPE_LEN)
82766 i = RCU_TORTURE_PIPE_LEN;
82767 - atomic_inc(&rcu_torture_wcount[i]);
82768 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82769 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82770 rp->rtort_mbtest = 0;
82771 rcu_torture_free(rp);
82772 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82773 i = rp->rtort_pipe_count;
82774 if (i > RCU_TORTURE_PIPE_LEN)
82775 i = RCU_TORTURE_PIPE_LEN;
82776 - atomic_inc(&rcu_torture_wcount[i]);
82777 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82778 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82779 rp->rtort_mbtest = 0;
82780 list_del(&rp->rtort_free);
82781 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82782 i = old_rp->rtort_pipe_count;
82783 if (i > RCU_TORTURE_PIPE_LEN)
82784 i = RCU_TORTURE_PIPE_LEN;
82785 - atomic_inc(&rcu_torture_wcount[i]);
82786 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82787 old_rp->rtort_pipe_count++;
82788 cur_ops->deferred_free(old_rp);
82789 }
82790 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82791 return;
82792 }
82793 if (p->rtort_mbtest == 0)
82794 - atomic_inc(&n_rcu_torture_mberror);
82795 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82796 spin_lock(&rand_lock);
82797 cur_ops->read_delay(&rand);
82798 n_rcu_torture_timers++;
82799 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82800 continue;
82801 }
82802 if (p->rtort_mbtest == 0)
82803 - atomic_inc(&n_rcu_torture_mberror);
82804 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82805 cur_ops->read_delay(&rand);
82806 preempt_disable();
82807 pipe_count = p->rtort_pipe_count;
82808 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82809 rcu_torture_current,
82810 rcu_torture_current_version,
82811 list_empty(&rcu_torture_freelist),
82812 - atomic_read(&n_rcu_torture_alloc),
82813 - atomic_read(&n_rcu_torture_alloc_fail),
82814 - atomic_read(&n_rcu_torture_free));
82815 + atomic_read_unchecked(&n_rcu_torture_alloc),
82816 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82817 + atomic_read_unchecked(&n_rcu_torture_free));
82818 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82819 - atomic_read(&n_rcu_torture_mberror),
82820 + atomic_read_unchecked(&n_rcu_torture_mberror),
82821 n_rcu_torture_boost_ktrerror,
82822 n_rcu_torture_boost_rterror);
82823 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82824 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82825 n_barrier_attempts,
82826 n_rcu_torture_barrier_error);
82827 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82828 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82829 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82830 n_rcu_torture_barrier_error != 0 ||
82831 n_rcu_torture_boost_ktrerror != 0 ||
82832 n_rcu_torture_boost_rterror != 0 ||
82833 n_rcu_torture_boost_failure != 0 ||
82834 i > 1) {
82835 cnt += sprintf(&page[cnt], "!!! ");
82836 - atomic_inc(&n_rcu_torture_error);
82837 + atomic_inc_unchecked(&n_rcu_torture_error);
82838 WARN_ON_ONCE(1);
82839 }
82840 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82841 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82842 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82843 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82844 cnt += sprintf(&page[cnt], " %d",
82845 - atomic_read(&rcu_torture_wcount[i]));
82846 + atomic_read_unchecked(&rcu_torture_wcount[i]));
82847 }
82848 cnt += sprintf(&page[cnt], "\n");
82849 if (cur_ops->stats)
82850 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
82851
82852 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
82853
82854 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82855 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82856 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
82857 else if (n_online_successes != n_online_attempts ||
82858 n_offline_successes != n_offline_attempts)
82859 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
82860
82861 rcu_torture_current = NULL;
82862 rcu_torture_current_version = 0;
82863 - atomic_set(&n_rcu_torture_alloc, 0);
82864 - atomic_set(&n_rcu_torture_alloc_fail, 0);
82865 - atomic_set(&n_rcu_torture_free, 0);
82866 - atomic_set(&n_rcu_torture_mberror, 0);
82867 - atomic_set(&n_rcu_torture_error, 0);
82868 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
82869 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
82870 + atomic_set_unchecked(&n_rcu_torture_free, 0);
82871 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
82872 + atomic_set_unchecked(&n_rcu_torture_error, 0);
82873 n_rcu_torture_barrier_error = 0;
82874 n_rcu_torture_boost_ktrerror = 0;
82875 n_rcu_torture_boost_rterror = 0;
82876 n_rcu_torture_boost_failure = 0;
82877 n_rcu_torture_boosts = 0;
82878 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
82879 - atomic_set(&rcu_torture_wcount[i], 0);
82880 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
82881 for_each_possible_cpu(cpu) {
82882 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82883 per_cpu(rcu_torture_count, cpu)[i] = 0;
82884 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
82885 index 068de3a..df7da65 100644
82886 --- a/kernel/rcutree.c
82887 +++ b/kernel/rcutree.c
82888 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
82889 rcu_prepare_for_idle(smp_processor_id());
82890 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82891 smp_mb__before_atomic_inc(); /* See above. */
82892 - atomic_inc(&rdtp->dynticks);
82893 + atomic_inc_unchecked(&rdtp->dynticks);
82894 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
82895 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82896 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82897
82898 /*
82899 * It is illegal to enter an extended quiescent state while
82900 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
82901 int user)
82902 {
82903 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
82904 - atomic_inc(&rdtp->dynticks);
82905 + atomic_inc_unchecked(&rdtp->dynticks);
82906 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82907 smp_mb__after_atomic_inc(); /* See above. */
82908 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82909 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82910 rcu_cleanup_after_idle(smp_processor_id());
82911 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
82912 if (!user && !is_idle_task(current)) {
82913 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
82914 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
82915
82916 if (rdtp->dynticks_nmi_nesting == 0 &&
82917 - (atomic_read(&rdtp->dynticks) & 0x1))
82918 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
82919 return;
82920 rdtp->dynticks_nmi_nesting++;
82921 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
82922 - atomic_inc(&rdtp->dynticks);
82923 + atomic_inc_unchecked(&rdtp->dynticks);
82924 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82925 smp_mb__after_atomic_inc(); /* See above. */
82926 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82927 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82928 }
82929
82930 /**
82931 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
82932 return;
82933 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82934 smp_mb__before_atomic_inc(); /* See above. */
82935 - atomic_inc(&rdtp->dynticks);
82936 + atomic_inc_unchecked(&rdtp->dynticks);
82937 smp_mb__after_atomic_inc(); /* Force delay to next write. */
82938 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82939 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82940 }
82941
82942 /**
82943 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
82944 int ret;
82945
82946 preempt_disable();
82947 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82948 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82949 preempt_enable();
82950 return ret;
82951 }
82952 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
82953 */
82954 static int dyntick_save_progress_counter(struct rcu_data *rdp)
82955 {
82956 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
82957 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82958 return (rdp->dynticks_snap & 0x1) == 0;
82959 }
82960
82961 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
82962 unsigned int curr;
82963 unsigned int snap;
82964
82965 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
82966 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82967 snap = (unsigned int)rdp->dynticks_snap;
82968
82969 /*
82970 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
82971 rdp = this_cpu_ptr(rsp->rda);
82972 rcu_preempt_check_blocked_tasks(rnp);
82973 rnp->qsmask = rnp->qsmaskinit;
82974 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
82975 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
82976 WARN_ON_ONCE(rnp->completed != rsp->completed);
82977 - ACCESS_ONCE(rnp->completed) = rsp->completed;
82978 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
82979 if (rnp == rdp->mynode)
82980 __note_gp_changes(rsp, rnp, rdp);
82981 rcu_preempt_boost_start_gp(rnp);
82982 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
82983 */
82984 rcu_for_each_node_breadth_first(rsp, rnp) {
82985 raw_spin_lock_irq(&rnp->lock);
82986 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
82987 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
82988 rdp = this_cpu_ptr(rsp->rda);
82989 if (rnp == rdp->mynode)
82990 __note_gp_changes(rsp, rnp, rdp);
82991 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
82992 rsp->qlen += rdp->qlen;
82993 rdp->n_cbs_orphaned += rdp->qlen;
82994 rdp->qlen_lazy = 0;
82995 - ACCESS_ONCE(rdp->qlen) = 0;
82996 + ACCESS_ONCE_RW(rdp->qlen) = 0;
82997 }
82998
82999 /*
83000 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
83001 }
83002 smp_mb(); /* List handling before counting for rcu_barrier(). */
83003 rdp->qlen_lazy -= count_lazy;
83004 - ACCESS_ONCE(rdp->qlen) -= count;
83005 + ACCESS_ONCE_RW(rdp->qlen) -= count;
83006 rdp->n_cbs_invoked += count;
83007
83008 /* Reinstate batch limit if we have worked down the excess. */
83009 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
83010 /*
83011 * Do RCU core processing for the current CPU.
83012 */
83013 -static void rcu_process_callbacks(struct softirq_action *unused)
83014 +static void rcu_process_callbacks(void)
83015 {
83016 struct rcu_state *rsp;
83017
83018 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
83019 local_irq_restore(flags);
83020 return;
83021 }
83022 - ACCESS_ONCE(rdp->qlen)++;
83023 + ACCESS_ONCE_RW(rdp->qlen)++;
83024 if (lazy)
83025 rdp->qlen_lazy++;
83026 else
83027 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
83028 * counter wrap on a 32-bit system. Quite a few more CPUs would of
83029 * course be required on a 64-bit system.
83030 */
83031 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
83032 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
83033 (ulong)atomic_long_read(&rsp->expedited_done) +
83034 ULONG_MAX / 8)) {
83035 synchronize_sched();
83036 - atomic_long_inc(&rsp->expedited_wrap);
83037 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
83038 return;
83039 }
83040
83041 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
83042 * Take a ticket. Note that atomic_inc_return() implies a
83043 * full memory barrier.
83044 */
83045 - snap = atomic_long_inc_return(&rsp->expedited_start);
83046 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
83047 firstsnap = snap;
83048 get_online_cpus();
83049 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
83050 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
83051 synchronize_sched_expedited_cpu_stop,
83052 NULL) == -EAGAIN) {
83053 put_online_cpus();
83054 - atomic_long_inc(&rsp->expedited_tryfail);
83055 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
83056
83057 /* Check to see if someone else did our work for us. */
83058 s = atomic_long_read(&rsp->expedited_done);
83059 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83060 /* ensure test happens before caller kfree */
83061 smp_mb__before_atomic_inc(); /* ^^^ */
83062 - atomic_long_inc(&rsp->expedited_workdone1);
83063 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
83064 return;
83065 }
83066
83067 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
83068 udelay(trycount * num_online_cpus());
83069 } else {
83070 wait_rcu_gp(call_rcu_sched);
83071 - atomic_long_inc(&rsp->expedited_normal);
83072 + atomic_long_inc_unchecked(&rsp->expedited_normal);
83073 return;
83074 }
83075
83076 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
83077 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83078 /* ensure test happens before caller kfree */
83079 smp_mb__before_atomic_inc(); /* ^^^ */
83080 - atomic_long_inc(&rsp->expedited_workdone2);
83081 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
83082 return;
83083 }
83084
83085 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
83086 * period works for us.
83087 */
83088 get_online_cpus();
83089 - snap = atomic_long_read(&rsp->expedited_start);
83090 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
83091 smp_mb(); /* ensure read is before try_stop_cpus(). */
83092 }
83093 - atomic_long_inc(&rsp->expedited_stoppedcpus);
83094 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
83095
83096 /*
83097 * Everyone up to our most recent fetch is covered by our grace
83098 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
83099 * than we did already did their update.
83100 */
83101 do {
83102 - atomic_long_inc(&rsp->expedited_done_tries);
83103 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
83104 s = atomic_long_read(&rsp->expedited_done);
83105 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
83106 /* ensure test happens before caller kfree */
83107 smp_mb__before_atomic_inc(); /* ^^^ */
83108 - atomic_long_inc(&rsp->expedited_done_lost);
83109 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
83110 break;
83111 }
83112 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
83113 - atomic_long_inc(&rsp->expedited_done_exit);
83114 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
83115
83116 put_online_cpus();
83117 }
83118 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83119 * ACCESS_ONCE() to prevent the compiler from speculating
83120 * the increment to precede the early-exit check.
83121 */
83122 - ACCESS_ONCE(rsp->n_barrier_done)++;
83123 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83124 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
83125 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
83126 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
83127 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83128
83129 /* Increment ->n_barrier_done to prevent duplicate work. */
83130 smp_mb(); /* Keep increment after above mechanism. */
83131 - ACCESS_ONCE(rsp->n_barrier_done)++;
83132 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83133 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
83134 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
83135 smp_mb(); /* Keep increment before caller's subsequent code. */
83136 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
83137 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
83138 init_callback_list(rdp);
83139 rdp->qlen_lazy = 0;
83140 - ACCESS_ONCE(rdp->qlen) = 0;
83141 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83142 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
83143 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
83144 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
83145 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
83146 rdp->cpu = cpu;
83147 rdp->rsp = rsp;
83148 rcu_boot_init_nocb_percpu_data(rdp);
83149 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
83150 rdp->blimit = blimit;
83151 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
83152 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
83153 - atomic_set(&rdp->dynticks->dynticks,
83154 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
83155 + atomic_set_unchecked(&rdp->dynticks->dynticks,
83156 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
83157 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
83158
83159 /* Add CPU to rcu_node bitmasks. */
83160 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
83161 index b383258..2440c1e 100644
83162 --- a/kernel/rcutree.h
83163 +++ b/kernel/rcutree.h
83164 @@ -87,7 +87,7 @@ struct rcu_dynticks {
83165 long long dynticks_nesting; /* Track irq/process nesting level. */
83166 /* Process level is worth LLONG_MAX/2. */
83167 int dynticks_nmi_nesting; /* Track NMI nesting level. */
83168 - atomic_t dynticks; /* Even value for idle, else odd. */
83169 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
83170 #ifdef CONFIG_RCU_FAST_NO_HZ
83171 bool all_lazy; /* Are all CPU's CBs lazy? */
83172 unsigned long nonlazy_posted;
83173 @@ -419,17 +419,17 @@ struct rcu_state {
83174 /* _rcu_barrier(). */
83175 /* End of fields guarded by barrier_mutex. */
83176
83177 - atomic_long_t expedited_start; /* Starting ticket. */
83178 - atomic_long_t expedited_done; /* Done ticket. */
83179 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
83180 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
83181 - atomic_long_t expedited_workdone1; /* # done by others #1. */
83182 - atomic_long_t expedited_workdone2; /* # done by others #2. */
83183 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
83184 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
83185 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
83186 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
83187 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
83188 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
83189 + atomic_long_t expedited_done; /* Done ticket. */
83190 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
83191 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
83192 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
83193 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83194 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83195 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83196 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83197 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83198 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83199
83200 unsigned long jiffies_force_qs; /* Time at which to invoke */
83201 /* force_quiescent_state(). */
83202 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83203 index 769e12e..7b2139b 100644
83204 --- a/kernel/rcutree_plugin.h
83205 +++ b/kernel/rcutree_plugin.h
83206 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83207
83208 /* Clean up and exit. */
83209 smp_mb(); /* ensure expedited GP seen before counter increment. */
83210 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83211 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83212 unlock_mb_ret:
83213 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83214 mb_ret:
83215 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83216 free_cpumask_var(cm);
83217 }
83218
83219 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83220 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83221 .store = &rcu_cpu_kthread_task,
83222 .thread_should_run = rcu_cpu_kthread_should_run,
83223 .thread_fn = rcu_cpu_kthread,
83224 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83225 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83226 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83227 cpu, ticks_value, ticks_title,
83228 - atomic_read(&rdtp->dynticks) & 0xfff,
83229 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83230 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83231 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83232 fast_no_hz);
83233 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83234
83235 /* Enqueue the callback on the nocb list and update counts. */
83236 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83237 - ACCESS_ONCE(*old_rhpp) = rhp;
83238 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83239 atomic_long_add(rhcount, &rdp->nocb_q_count);
83240 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83241
83242 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83243 * Extract queued callbacks, update counts, and wait
83244 * for a grace period to elapse.
83245 */
83246 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83247 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83248 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83249 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83250 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83251 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83252 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83253 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83254 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83255 rcu_nocb_wait_gp(rdp);
83256
83257 /* Each pass through the following loop invokes a callback. */
83258 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83259 list = next;
83260 }
83261 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83262 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83263 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83264 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83265 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83266 rdp->n_nocbs_invoked += c;
83267 }
83268 return 0;
83269 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83270 t = kthread_run(rcu_nocb_kthread, rdp,
83271 "rcuo%c/%d", rsp->abbr, cpu);
83272 BUG_ON(IS_ERR(t));
83273 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83274 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83275 }
83276 }
83277
83278 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83279 index cf6c174..a8f4b50 100644
83280 --- a/kernel/rcutree_trace.c
83281 +++ b/kernel/rcutree_trace.c
83282 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83283 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83284 rdp->passed_quiesce, rdp->qs_pending);
83285 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83286 - atomic_read(&rdp->dynticks->dynticks),
83287 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83288 rdp->dynticks->dynticks_nesting,
83289 rdp->dynticks->dynticks_nmi_nesting,
83290 rdp->dynticks_fqs);
83291 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83292 struct rcu_state *rsp = (struct rcu_state *)m->private;
83293
83294 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",
83295 - atomic_long_read(&rsp->expedited_start),
83296 + atomic_long_read_unchecked(&rsp->expedited_start),
83297 atomic_long_read(&rsp->expedited_done),
83298 - atomic_long_read(&rsp->expedited_wrap),
83299 - atomic_long_read(&rsp->expedited_tryfail),
83300 - atomic_long_read(&rsp->expedited_workdone1),
83301 - atomic_long_read(&rsp->expedited_workdone2),
83302 - atomic_long_read(&rsp->expedited_normal),
83303 - atomic_long_read(&rsp->expedited_stoppedcpus),
83304 - atomic_long_read(&rsp->expedited_done_tries),
83305 - atomic_long_read(&rsp->expedited_done_lost),
83306 - atomic_long_read(&rsp->expedited_done_exit));
83307 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83308 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83309 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83310 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83311 + atomic_long_read_unchecked(&rsp->expedited_normal),
83312 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83313 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83314 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83315 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83316 return 0;
83317 }
83318
83319 diff --git a/kernel/resource.c b/kernel/resource.c
83320 index 3f285dc..5755f62 100644
83321 --- a/kernel/resource.c
83322 +++ b/kernel/resource.c
83323 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83324
83325 static int __init ioresources_init(void)
83326 {
83327 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83328 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83329 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83330 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83331 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83332 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83333 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83334 +#endif
83335 +#else
83336 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83337 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83338 +#endif
83339 return 0;
83340 }
83341 __initcall(ioresources_init);
83342 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83343 index 1d96dd0..994ff19 100644
83344 --- a/kernel/rtmutex-tester.c
83345 +++ b/kernel/rtmutex-tester.c
83346 @@ -22,7 +22,7 @@
83347 #define MAX_RT_TEST_MUTEXES 8
83348
83349 static spinlock_t rttest_lock;
83350 -static atomic_t rttest_event;
83351 +static atomic_unchecked_t rttest_event;
83352
83353 struct test_thread_data {
83354 int opcode;
83355 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83356
83357 case RTTEST_LOCKCONT:
83358 td->mutexes[td->opdata] = 1;
83359 - td->event = atomic_add_return(1, &rttest_event);
83360 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83361 return 0;
83362
83363 case RTTEST_RESET:
83364 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83365 return 0;
83366
83367 case RTTEST_RESETEVENT:
83368 - atomic_set(&rttest_event, 0);
83369 + atomic_set_unchecked(&rttest_event, 0);
83370 return 0;
83371
83372 default:
83373 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83374 return ret;
83375
83376 td->mutexes[id] = 1;
83377 - td->event = atomic_add_return(1, &rttest_event);
83378 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83379 rt_mutex_lock(&mutexes[id]);
83380 - td->event = atomic_add_return(1, &rttest_event);
83381 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83382 td->mutexes[id] = 4;
83383 return 0;
83384
83385 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83386 return ret;
83387
83388 td->mutexes[id] = 1;
83389 - td->event = atomic_add_return(1, &rttest_event);
83390 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83391 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83392 - td->event = atomic_add_return(1, &rttest_event);
83393 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83394 td->mutexes[id] = ret ? 0 : 4;
83395 return ret ? -EINTR : 0;
83396
83397 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83398 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83399 return ret;
83400
83401 - td->event = atomic_add_return(1, &rttest_event);
83402 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83403 rt_mutex_unlock(&mutexes[id]);
83404 - td->event = atomic_add_return(1, &rttest_event);
83405 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83406 td->mutexes[id] = 0;
83407 return 0;
83408
83409 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83410 break;
83411
83412 td->mutexes[dat] = 2;
83413 - td->event = atomic_add_return(1, &rttest_event);
83414 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83415 break;
83416
83417 default:
83418 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83419 return;
83420
83421 td->mutexes[dat] = 3;
83422 - td->event = atomic_add_return(1, &rttest_event);
83423 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83424 break;
83425
83426 case RTTEST_LOCKNOWAIT:
83427 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83428 return;
83429
83430 td->mutexes[dat] = 1;
83431 - td->event = atomic_add_return(1, &rttest_event);
83432 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83433 return;
83434
83435 default:
83436 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83437 index 4a07353..66b5291 100644
83438 --- a/kernel/sched/auto_group.c
83439 +++ b/kernel/sched/auto_group.c
83440 @@ -11,7 +11,7 @@
83441
83442 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83443 static struct autogroup autogroup_default;
83444 -static atomic_t autogroup_seq_nr;
83445 +static atomic_unchecked_t autogroup_seq_nr;
83446
83447 void __init autogroup_init(struct task_struct *init_task)
83448 {
83449 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83450
83451 kref_init(&ag->kref);
83452 init_rwsem(&ag->lock);
83453 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83454 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83455 ag->tg = tg;
83456 #ifdef CONFIG_RT_GROUP_SCHED
83457 /*
83458 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83459 index 05c39f0..442e6fe 100644
83460 --- a/kernel/sched/core.c
83461 +++ b/kernel/sched/core.c
83462 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83463 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83464 * or number of jiffies left till timeout) if completed.
83465 */
83466 -long __sched
83467 +long __sched __intentional_overflow(-1)
83468 wait_for_completion_interruptible_timeout(struct completion *x,
83469 unsigned long timeout)
83470 {
83471 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83472 *
83473 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83474 */
83475 -int __sched wait_for_completion_killable(struct completion *x)
83476 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83477 {
83478 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83479 if (t == -ERESTARTSYS)
83480 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83481 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83482 * or number of jiffies left till timeout) if completed.
83483 */
83484 -long __sched
83485 +long __sched __intentional_overflow(-1)
83486 wait_for_completion_killable_timeout(struct completion *x,
83487 unsigned long timeout)
83488 {
83489 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83490 /* convert nice value [19,-20] to rlimit style value [1,40] */
83491 int nice_rlim = 20 - nice;
83492
83493 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83494 +
83495 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83496 capable(CAP_SYS_NICE));
83497 }
83498 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83499 if (nice > 19)
83500 nice = 19;
83501
83502 - if (increment < 0 && !can_nice(current, nice))
83503 + if (increment < 0 && (!can_nice(current, nice) ||
83504 + gr_handle_chroot_nice()))
83505 return -EPERM;
83506
83507 retval = security_task_setnice(current, nice);
83508 @@ -3344,6 +3347,7 @@ recheck:
83509 unsigned long rlim_rtprio =
83510 task_rlimit(p, RLIMIT_RTPRIO);
83511
83512 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83513 /* can't set/change the rt policy */
83514 if (policy != p->policy && !rlim_rtprio)
83515 return -EPERM;
83516 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83517
83518 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83519
83520 -static struct ctl_table sd_ctl_dir[] = {
83521 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83522 {
83523 .procname = "sched_domain",
83524 .mode = 0555,
83525 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83526 {}
83527 };
83528
83529 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83530 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83531 {
83532 - struct ctl_table *entry =
83533 + ctl_table_no_const *entry =
83534 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83535
83536 return entry;
83537 }
83538
83539 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83540 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83541 {
83542 - struct ctl_table *entry;
83543 + ctl_table_no_const *entry;
83544
83545 /*
83546 * In the intermediate directories, both the child directory and
83547 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83548 * will always be set. In the lowest directory the names are
83549 * static strings and all have proc handlers.
83550 */
83551 - for (entry = *tablep; entry->mode; entry++) {
83552 - if (entry->child)
83553 - sd_free_ctl_entry(&entry->child);
83554 + for (entry = tablep; entry->mode; entry++) {
83555 + if (entry->child) {
83556 + sd_free_ctl_entry(entry->child);
83557 + pax_open_kernel();
83558 + entry->child = NULL;
83559 + pax_close_kernel();
83560 + }
83561 if (entry->proc_handler == NULL)
83562 kfree(entry->procname);
83563 }
83564
83565 - kfree(*tablep);
83566 - *tablep = NULL;
83567 + kfree(tablep);
83568 }
83569
83570 static int min_load_idx = 0;
83571 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83572
83573 static void
83574 -set_table_entry(struct ctl_table *entry,
83575 +set_table_entry(ctl_table_no_const *entry,
83576 const char *procname, void *data, int maxlen,
83577 umode_t mode, proc_handler *proc_handler,
83578 bool load_idx)
83579 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83580 static struct ctl_table *
83581 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83582 {
83583 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83584 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83585
83586 if (table == NULL)
83587 return NULL;
83588 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83589 return table;
83590 }
83591
83592 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83593 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83594 {
83595 - struct ctl_table *entry, *table;
83596 + ctl_table_no_const *entry, *table;
83597 struct sched_domain *sd;
83598 int domain_num = 0, i;
83599 char buf[32];
83600 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83601 static void register_sched_domain_sysctl(void)
83602 {
83603 int i, cpu_num = num_possible_cpus();
83604 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83605 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83606 char buf[32];
83607
83608 WARN_ON(sd_ctl_dir[0].child);
83609 + pax_open_kernel();
83610 sd_ctl_dir[0].child = entry;
83611 + pax_close_kernel();
83612
83613 if (entry == NULL)
83614 return;
83615 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83616 if (sd_sysctl_header)
83617 unregister_sysctl_table(sd_sysctl_header);
83618 sd_sysctl_header = NULL;
83619 - if (sd_ctl_dir[0].child)
83620 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83621 + if (sd_ctl_dir[0].child) {
83622 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83623 + pax_open_kernel();
83624 + sd_ctl_dir[0].child = NULL;
83625 + pax_close_kernel();
83626 + }
83627 }
83628 #else
83629 static void register_sched_domain_sysctl(void)
83630 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83631 index 68f1609..640ba13 100644
83632 --- a/kernel/sched/fair.c
83633 +++ b/kernel/sched/fair.c
83634 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83635
83636 static void reset_ptenuma_scan(struct task_struct *p)
83637 {
83638 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83639 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83640 p->mm->numa_scan_offset = 0;
83641 }
83642
83643 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83644 * run_rebalance_domains is triggered when needed from the scheduler tick.
83645 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83646 */
83647 -static void run_rebalance_domains(struct softirq_action *h)
83648 +static void run_rebalance_domains(void)
83649 {
83650 int this_cpu = smp_processor_id();
83651 struct rq *this_rq = cpu_rq(this_cpu);
83652 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83653 index ef0a7b2..1b728c1 100644
83654 --- a/kernel/sched/sched.h
83655 +++ b/kernel/sched/sched.h
83656 @@ -1004,7 +1004,7 @@ struct sched_class {
83657 #ifdef CONFIG_FAIR_GROUP_SCHED
83658 void (*task_move_group) (struct task_struct *p, int on_rq);
83659 #endif
83660 -};
83661 +} __do_const;
83662
83663 #define sched_class_highest (&stop_sched_class)
83664 #define for_each_class(class) \
83665 diff --git a/kernel/signal.c b/kernel/signal.c
83666 index 50e4107..08bcb94 100644
83667 --- a/kernel/signal.c
83668 +++ b/kernel/signal.c
83669 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83670
83671 int print_fatal_signals __read_mostly;
83672
83673 -static void __user *sig_handler(struct task_struct *t, int sig)
83674 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83675 {
83676 return t->sighand->action[sig - 1].sa.sa_handler;
83677 }
83678
83679 -static int sig_handler_ignored(void __user *handler, int sig)
83680 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83681 {
83682 /* Is it explicitly or implicitly ignored? */
83683 return handler == SIG_IGN ||
83684 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83685
83686 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83687 {
83688 - void __user *handler;
83689 + __sighandler_t handler;
83690
83691 handler = sig_handler(t, sig);
83692
83693 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83694 atomic_inc(&user->sigpending);
83695 rcu_read_unlock();
83696
83697 + if (!override_rlimit)
83698 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83699 +
83700 if (override_rlimit ||
83701 atomic_read(&user->sigpending) <=
83702 task_rlimit(t, RLIMIT_SIGPENDING)) {
83703 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83704
83705 int unhandled_signal(struct task_struct *tsk, int sig)
83706 {
83707 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83708 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83709 if (is_global_init(tsk))
83710 return 1;
83711 if (handler != SIG_IGN && handler != SIG_DFL)
83712 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83713 }
83714 }
83715
83716 + /* allow glibc communication via tgkill to other threads in our
83717 + thread group */
83718 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83719 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83720 + && gr_handle_signal(t, sig))
83721 + return -EPERM;
83722 +
83723 return security_task_kill(t, info, sig, 0);
83724 }
83725
83726 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83727 return send_signal(sig, info, p, 1);
83728 }
83729
83730 -static int
83731 +int
83732 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83733 {
83734 return send_signal(sig, info, t, 0);
83735 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83736 unsigned long int flags;
83737 int ret, blocked, ignored;
83738 struct k_sigaction *action;
83739 + int is_unhandled = 0;
83740
83741 spin_lock_irqsave(&t->sighand->siglock, flags);
83742 action = &t->sighand->action[sig-1];
83743 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83744 }
83745 if (action->sa.sa_handler == SIG_DFL)
83746 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83747 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83748 + is_unhandled = 1;
83749 ret = specific_send_sig_info(sig, info, t);
83750 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83751
83752 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83753 + normal operation */
83754 + if (is_unhandled) {
83755 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83756 + gr_handle_crash(t, sig);
83757 + }
83758 +
83759 return ret;
83760 }
83761
83762 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83763 ret = check_kill_permission(sig, info, p);
83764 rcu_read_unlock();
83765
83766 - if (!ret && sig)
83767 + if (!ret && sig) {
83768 ret = do_send_sig_info(sig, info, p, true);
83769 + if (!ret)
83770 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83771 + }
83772
83773 return ret;
83774 }
83775 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83776 int error = -ESRCH;
83777
83778 rcu_read_lock();
83779 - p = find_task_by_vpid(pid);
83780 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83781 + /* allow glibc communication via tgkill to other threads in our
83782 + thread group */
83783 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83784 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83785 + p = find_task_by_vpid_unrestricted(pid);
83786 + else
83787 +#endif
83788 + p = find_task_by_vpid(pid);
83789 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83790 error = check_kill_permission(sig, info, p);
83791 /*
83792 @@ -3219,6 +3250,16 @@ int __save_altstack(stack_t __user *uss, unsigned long sp)
83793 __put_user(t->sas_ss_size, &uss->ss_size);
83794 }
83795
83796 +#ifdef CONFIG_X86
83797 +void __save_altstack_ex(stack_t __user *uss, unsigned long sp)
83798 +{
83799 + struct task_struct *t = current;
83800 + put_user_ex((void __user *)t->sas_ss_sp, &uss->ss_sp);
83801 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
83802 + put_user_ex(t->sas_ss_size, &uss->ss_size);
83803 +}
83804 +#endif
83805 +
83806 #ifdef CONFIG_COMPAT
83807 COMPAT_SYSCALL_DEFINE2(sigaltstack,
83808 const compat_stack_t __user *, uss_ptr,
83809 @@ -3240,8 +3281,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83810 }
83811 seg = get_fs();
83812 set_fs(KERNEL_DS);
83813 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83814 - (stack_t __force __user *) &uoss,
83815 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83816 + (stack_t __force_user *) &uoss,
83817 compat_user_stack_pointer());
83818 set_fs(seg);
83819 if (ret >= 0 && uoss_ptr) {
83820 @@ -3268,6 +3309,16 @@ int __compat_save_altstack(compat_stack_t __user *uss, unsigned long sp)
83821 __put_user(sas_ss_flags(sp), &uss->ss_flags) |
83822 __put_user(t->sas_ss_size, &uss->ss_size);
83823 }
83824 +
83825 +#ifdef CONFIG_X86
83826 +void __compat_save_altstack_ex(compat_stack_t __user *uss, unsigned long sp)
83827 +{
83828 + struct task_struct *t = current;
83829 + put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &uss->ss_sp);
83830 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
83831 + put_user_ex(t->sas_ss_size, &uss->ss_size);
83832 +}
83833 +#endif
83834 #endif
83835
83836 #ifdef __ARCH_WANT_SYS_SIGPENDING
83837 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83838 index eb89e18..a4e6792 100644
83839 --- a/kernel/smpboot.c
83840 +++ b/kernel/smpboot.c
83841 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83842 }
83843 smpboot_unpark_thread(plug_thread, cpu);
83844 }
83845 - list_add(&plug_thread->list, &hotplug_threads);
83846 + pax_list_add(&plug_thread->list, &hotplug_threads);
83847 out:
83848 mutex_unlock(&smpboot_threads_lock);
83849 return ret;
83850 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83851 {
83852 get_online_cpus();
83853 mutex_lock(&smpboot_threads_lock);
83854 - list_del(&plug_thread->list);
83855 + pax_list_del(&plug_thread->list);
83856 smpboot_destroy_threads(plug_thread);
83857 mutex_unlock(&smpboot_threads_lock);
83858 put_online_cpus();
83859 diff --git a/kernel/softirq.c b/kernel/softirq.c
83860 index be3d351..9e4d5f2 100644
83861 --- a/kernel/softirq.c
83862 +++ b/kernel/softirq.c
83863 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83864 EXPORT_SYMBOL(irq_stat);
83865 #endif
83866
83867 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83868 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83869
83870 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83871
83872 -char *softirq_to_name[NR_SOFTIRQS] = {
83873 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83874 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83875 "TASKLET", "SCHED", "HRTIMER", "RCU"
83876 };
83877 @@ -248,7 +248,7 @@ restart:
83878 kstat_incr_softirqs_this_cpu(vec_nr);
83879
83880 trace_softirq_entry(vec_nr);
83881 - h->action(h);
83882 + h->action();
83883 trace_softirq_exit(vec_nr);
83884 if (unlikely(prev_count != preempt_count())) {
83885 printk(KERN_ERR "huh, entered softirq %u %s %p"
83886 @@ -403,7 +403,7 @@ void __raise_softirq_irqoff(unsigned int nr)
83887 or_softirq_pending(1UL << nr);
83888 }
83889
83890 -void open_softirq(int nr, void (*action)(struct softirq_action *))
83891 +void __init open_softirq(int nr, void (*action)(void))
83892 {
83893 softirq_vec[nr].action = action;
83894 }
83895 @@ -459,7 +459,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
83896
83897 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
83898
83899 -static void tasklet_action(struct softirq_action *a)
83900 +static void tasklet_action(void)
83901 {
83902 struct tasklet_struct *list;
83903
83904 @@ -494,7 +494,7 @@ static void tasklet_action(struct softirq_action *a)
83905 }
83906 }
83907
83908 -static void tasklet_hi_action(struct softirq_action *a)
83909 +static void tasklet_hi_action(void)
83910 {
83911 struct tasklet_struct *list;
83912
83913 @@ -849,7 +849,7 @@ static struct notifier_block cpu_nfb = {
83914 .notifier_call = cpu_callback
83915 };
83916
83917 -static struct smp_hotplug_thread softirq_threads = {
83918 +static struct smp_hotplug_thread softirq_threads __read_only = {
83919 .store = &ksoftirqd,
83920 .thread_should_run = ksoftirqd_should_run,
83921 .thread_fn = run_ksoftirqd,
83922 diff --git a/kernel/srcu.c b/kernel/srcu.c
83923 index 01d5ccb..cdcbee6 100644
83924 --- a/kernel/srcu.c
83925 +++ b/kernel/srcu.c
83926 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
83927
83928 idx = ACCESS_ONCE(sp->completed) & 0x1;
83929 preempt_disable();
83930 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83931 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83932 smp_mb(); /* B */ /* Avoid leaking the critical section. */
83933 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83934 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83935 preempt_enable();
83936 return idx;
83937 }
83938 diff --git a/kernel/sys.c b/kernel/sys.c
83939 index 771129b..dc0c7e3 100644
83940 --- a/kernel/sys.c
83941 +++ b/kernel/sys.c
83942 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
83943 error = -EACCES;
83944 goto out;
83945 }
83946 +
83947 + if (gr_handle_chroot_setpriority(p, niceval)) {
83948 + error = -EACCES;
83949 + goto out;
83950 + }
83951 +
83952 no_nice = security_task_setnice(p, niceval);
83953 if (no_nice) {
83954 error = no_nice;
83955 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
83956 goto error;
83957 }
83958
83959 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
83960 + goto error;
83961 +
83962 if (rgid != (gid_t) -1 ||
83963 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
83964 new->sgid = new->egid;
83965 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
83966 old = current_cred();
83967
83968 retval = -EPERM;
83969 +
83970 + if (gr_check_group_change(kgid, kgid, kgid))
83971 + goto error;
83972 +
83973 if (nsown_capable(CAP_SETGID))
83974 new->gid = new->egid = new->sgid = new->fsgid = kgid;
83975 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
83976 @@ -404,7 +417,7 @@ error:
83977 /*
83978 * change the user struct in a credentials set to match the new UID
83979 */
83980 -static int set_user(struct cred *new)
83981 +int set_user(struct cred *new)
83982 {
83983 struct user_struct *new_user;
83984
83985 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
83986 goto error;
83987 }
83988
83989 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
83990 + goto error;
83991 +
83992 if (!uid_eq(new->uid, old->uid)) {
83993 retval = set_user(new);
83994 if (retval < 0)
83995 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
83996 old = current_cred();
83997
83998 retval = -EPERM;
83999 +
84000 + if (gr_check_crash_uid(kuid))
84001 + goto error;
84002 + if (gr_check_user_change(kuid, kuid, kuid))
84003 + goto error;
84004 +
84005 if (nsown_capable(CAP_SETUID)) {
84006 new->suid = new->uid = kuid;
84007 if (!uid_eq(kuid, old->uid)) {
84008 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
84009 goto error;
84010 }
84011
84012 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
84013 + goto error;
84014 +
84015 if (ruid != (uid_t) -1) {
84016 new->uid = kruid;
84017 if (!uid_eq(kruid, old->uid)) {
84018 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
84019 goto error;
84020 }
84021
84022 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
84023 + goto error;
84024 +
84025 if (rgid != (gid_t) -1)
84026 new->gid = krgid;
84027 if (egid != (gid_t) -1)
84028 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
84029 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
84030 nsown_capable(CAP_SETUID)) {
84031 if (!uid_eq(kuid, old->fsuid)) {
84032 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
84033 + goto error;
84034 +
84035 new->fsuid = kuid;
84036 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
84037 goto change_okay;
84038 }
84039 }
84040
84041 +error:
84042 abort_creds(new);
84043 return old_fsuid;
84044
84045 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
84046 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
84047 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
84048 nsown_capable(CAP_SETGID)) {
84049 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
84050 + goto error;
84051 +
84052 if (!gid_eq(kgid, old->fsgid)) {
84053 new->fsgid = kgid;
84054 goto change_okay;
84055 }
84056 }
84057
84058 +error:
84059 abort_creds(new);
84060 return old_fsgid;
84061
84062 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
84063 return -EFAULT;
84064
84065 down_read(&uts_sem);
84066 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
84067 + error = __copy_to_user(name->sysname, &utsname()->sysname,
84068 __OLD_UTS_LEN);
84069 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
84070 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
84071 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
84072 __OLD_UTS_LEN);
84073 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
84074 - error |= __copy_to_user(&name->release, &utsname()->release,
84075 + error |= __copy_to_user(name->release, &utsname()->release,
84076 __OLD_UTS_LEN);
84077 error |= __put_user(0, name->release + __OLD_UTS_LEN);
84078 - error |= __copy_to_user(&name->version, &utsname()->version,
84079 + error |= __copy_to_user(name->version, &utsname()->version,
84080 __OLD_UTS_LEN);
84081 error |= __put_user(0, name->version + __OLD_UTS_LEN);
84082 - error |= __copy_to_user(&name->machine, &utsname()->machine,
84083 + error |= __copy_to_user(name->machine, &utsname()->machine,
84084 __OLD_UTS_LEN);
84085 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
84086 up_read(&uts_sem);
84087 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
84088 */
84089 new_rlim->rlim_cur = 1;
84090 }
84091 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
84092 + is changed to a lower value. Since tasks can be created by the same
84093 + user in between this limit change and an execve by this task, force
84094 + a recheck only for this task by setting PF_NPROC_EXCEEDED
84095 + */
84096 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
84097 + tsk->flags |= PF_NPROC_EXCEEDED;
84098 }
84099 if (!retval) {
84100 if (old_rlim)
84101 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
84102 index 07f6fc4..65fb3d4 100644
84103 --- a/kernel/sysctl.c
84104 +++ b/kernel/sysctl.c
84105 @@ -93,7 +93,6 @@
84106
84107
84108 #if defined(CONFIG_SYSCTL)
84109 -
84110 /* External variables not in a header file. */
84111 extern int sysctl_overcommit_memory;
84112 extern int sysctl_overcommit_ratio;
84113 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
84114
84115 /* Constants used for minimum and maximum */
84116 #ifdef CONFIG_LOCKUP_DETECTOR
84117 -static int sixty = 60;
84118 +static int sixty __read_only = 60;
84119 #endif
84120
84121 -static int zero;
84122 -static int __maybe_unused one = 1;
84123 -static int __maybe_unused two = 2;
84124 -static int __maybe_unused three = 3;
84125 -static unsigned long one_ul = 1;
84126 -static int one_hundred = 100;
84127 +static int neg_one __read_only = -1;
84128 +static int zero __read_only = 0;
84129 +static int __maybe_unused one __read_only = 1;
84130 +static int __maybe_unused two __read_only = 2;
84131 +static int __maybe_unused three __read_only = 3;
84132 +static unsigned long one_ul __read_only = 1;
84133 +static int one_hundred __read_only = 100;
84134 #ifdef CONFIG_PRINTK
84135 -static int ten_thousand = 10000;
84136 +static int ten_thousand __read_only = 10000;
84137 #endif
84138
84139 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
84140 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
84141 void __user *buffer, size_t *lenp, loff_t *ppos);
84142 #endif
84143
84144 -#ifdef CONFIG_PRINTK
84145 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84146 void __user *buffer, size_t *lenp, loff_t *ppos);
84147 -#endif
84148
84149 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
84150 void __user *buffer, size_t *lenp, loff_t *ppos);
84151 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
84152
84153 #endif
84154
84155 +extern struct ctl_table grsecurity_table[];
84156 +
84157 static struct ctl_table kern_table[];
84158 static struct ctl_table vm_table[];
84159 static struct ctl_table fs_table[];
84160 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
84161 int sysctl_legacy_va_layout;
84162 #endif
84163
84164 +#ifdef CONFIG_PAX_SOFTMODE
84165 +static ctl_table pax_table[] = {
84166 + {
84167 + .procname = "softmode",
84168 + .data = &pax_softmode,
84169 + .maxlen = sizeof(unsigned int),
84170 + .mode = 0600,
84171 + .proc_handler = &proc_dointvec,
84172 + },
84173 +
84174 + { }
84175 +};
84176 +#endif
84177 +
84178 /* The default sysctl tables: */
84179
84180 static struct ctl_table sysctl_base_table[] = {
84181 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
84182 #endif
84183
84184 static struct ctl_table kern_table[] = {
84185 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
84186 + {
84187 + .procname = "grsecurity",
84188 + .mode = 0500,
84189 + .child = grsecurity_table,
84190 + },
84191 +#endif
84192 +
84193 +#ifdef CONFIG_PAX_SOFTMODE
84194 + {
84195 + .procname = "pax",
84196 + .mode = 0500,
84197 + .child = pax_table,
84198 + },
84199 +#endif
84200 +
84201 {
84202 .procname = "sched_child_runs_first",
84203 .data = &sysctl_sched_child_runs_first,
84204 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
84205 .data = &modprobe_path,
84206 .maxlen = KMOD_PATH_LEN,
84207 .mode = 0644,
84208 - .proc_handler = proc_dostring,
84209 + .proc_handler = proc_dostring_modpriv,
84210 },
84211 {
84212 .procname = "modules_disabled",
84213 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
84214 .extra1 = &zero,
84215 .extra2 = &one,
84216 },
84217 +#endif
84218 {
84219 .procname = "kptr_restrict",
84220 .data = &kptr_restrict,
84221 .maxlen = sizeof(int),
84222 .mode = 0644,
84223 .proc_handler = proc_dointvec_minmax_sysadmin,
84224 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84225 + .extra1 = &two,
84226 +#else
84227 .extra1 = &zero,
84228 +#endif
84229 .extra2 = &two,
84230 },
84231 -#endif
84232 {
84233 .procname = "ngroups_max",
84234 .data = &ngroups_max,
84235 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84236 */
84237 {
84238 .procname = "perf_event_paranoid",
84239 - .data = &sysctl_perf_event_paranoid,
84240 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84241 + .data = &sysctl_perf_event_legitimately_concerned,
84242 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84243 .mode = 0644,
84244 - .proc_handler = proc_dointvec,
84245 + /* go ahead, be a hero */
84246 + .proc_handler = proc_dointvec_minmax_sysadmin,
84247 + .extra1 = &neg_one,
84248 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84249 + .extra2 = &three,
84250 +#else
84251 + .extra2 = &two,
84252 +#endif
84253 },
84254 {
84255 .procname = "perf_event_mlock_kb",
84256 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84257 .proc_handler = proc_dointvec_minmax,
84258 .extra1 = &zero,
84259 },
84260 + {
84261 + .procname = "heap_stack_gap",
84262 + .data = &sysctl_heap_stack_gap,
84263 + .maxlen = sizeof(sysctl_heap_stack_gap),
84264 + .mode = 0644,
84265 + .proc_handler = proc_doulongvec_minmax,
84266 + },
84267 #else
84268 {
84269 .procname = "nr_trim_pages",
84270 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84271 buffer, lenp, ppos);
84272 }
84273
84274 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84275 + void __user *buffer, size_t *lenp, loff_t *ppos)
84276 +{
84277 + if (write && !capable(CAP_SYS_MODULE))
84278 + return -EPERM;
84279 +
84280 + return _proc_do_string(table->data, table->maxlen, write,
84281 + buffer, lenp, ppos);
84282 +}
84283 +
84284 static size_t proc_skip_spaces(char **buf)
84285 {
84286 size_t ret;
84287 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84288 len = strlen(tmp);
84289 if (len > *size)
84290 len = *size;
84291 + if (len > sizeof(tmp))
84292 + len = sizeof(tmp);
84293 if (copy_to_user(*buf, tmp, len))
84294 return -EFAULT;
84295 *size -= len;
84296 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84297 static int proc_taint(struct ctl_table *table, int write,
84298 void __user *buffer, size_t *lenp, loff_t *ppos)
84299 {
84300 - struct ctl_table t;
84301 + ctl_table_no_const t;
84302 unsigned long tmptaint = get_taint();
84303 int err;
84304
84305 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84306 return err;
84307 }
84308
84309 -#ifdef CONFIG_PRINTK
84310 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84311 void __user *buffer, size_t *lenp, loff_t *ppos)
84312 {
84313 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84314
84315 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84316 }
84317 -#endif
84318
84319 struct do_proc_dointvec_minmax_conv_param {
84320 int *min;
84321 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84322 *i = val;
84323 } else {
84324 val = convdiv * (*i) / convmul;
84325 - if (!first)
84326 + if (!first) {
84327 err = proc_put_char(&buffer, &left, '\t');
84328 + if (err)
84329 + break;
84330 + }
84331 err = proc_put_long(&buffer, &left, val, false);
84332 if (err)
84333 break;
84334 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84335 return -ENOSYS;
84336 }
84337
84338 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84339 + void __user *buffer, size_t *lenp, loff_t *ppos)
84340 +{
84341 + return -ENOSYS;
84342 +}
84343 +
84344 int proc_dointvec(struct ctl_table *table, int write,
84345 void __user *buffer, size_t *lenp, loff_t *ppos)
84346 {
84347 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84348 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84349 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84350 EXPORT_SYMBOL(proc_dostring);
84351 +EXPORT_SYMBOL(proc_dostring_modpriv);
84352 EXPORT_SYMBOL(proc_doulongvec_minmax);
84353 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84354 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84355 index 145bb4d..b2aa969 100644
84356 --- a/kernel/taskstats.c
84357 +++ b/kernel/taskstats.c
84358 @@ -28,9 +28,12 @@
84359 #include <linux/fs.h>
84360 #include <linux/file.h>
84361 #include <linux/pid_namespace.h>
84362 +#include <linux/grsecurity.h>
84363 #include <net/genetlink.h>
84364 #include <linux/atomic.h>
84365
84366 +extern int gr_is_taskstats_denied(int pid);
84367 +
84368 /*
84369 * Maximum length of a cpumask that can be specified in
84370 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84371 @@ -570,6 +573,9 @@ err:
84372
84373 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84374 {
84375 + if (gr_is_taskstats_denied(current->pid))
84376 + return -EACCES;
84377 +
84378 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84379 return cmd_attr_register_cpumask(info);
84380 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84381 diff --git a/kernel/time.c b/kernel/time.c
84382 index 7c7964c..784a599 100644
84383 --- a/kernel/time.c
84384 +++ b/kernel/time.c
84385 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84386 return error;
84387
84388 if (tz) {
84389 + /* we log in do_settimeofday called below, so don't log twice
84390 + */
84391 + if (!tv)
84392 + gr_log_timechange();
84393 +
84394 sys_tz = *tz;
84395 update_vsyscall_tz();
84396 if (firsttime) {
84397 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84398 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84399 * value to a scaled second value.
84400 */
84401 -unsigned long
84402 +unsigned long __intentional_overflow(-1)
84403 timespec_to_jiffies(const struct timespec *value)
84404 {
84405 unsigned long sec = value->tv_sec;
84406 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84407 index eec50fc..65e5df6 100644
84408 --- a/kernel/time/alarmtimer.c
84409 +++ b/kernel/time/alarmtimer.c
84410 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84411 struct platform_device *pdev;
84412 int error = 0;
84413 int i;
84414 - struct k_clock alarm_clock = {
84415 + static struct k_clock alarm_clock = {
84416 .clock_getres = alarm_clock_getres,
84417 .clock_get = alarm_clock_get,
84418 .timer_create = alarm_timer_create,
84419 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84420 index 48b9fff..9e07e5f 100644
84421 --- a/kernel/time/timekeeping.c
84422 +++ b/kernel/time/timekeeping.c
84423 @@ -15,6 +15,7 @@
84424 #include <linux/init.h>
84425 #include <linux/mm.h>
84426 #include <linux/sched.h>
84427 +#include <linux/grsecurity.h>
84428 #include <linux/syscore_ops.h>
84429 #include <linux/clocksource.h>
84430 #include <linux/jiffies.h>
84431 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84432 if (!timespec_valid_strict(tv))
84433 return -EINVAL;
84434
84435 + gr_log_timechange();
84436 +
84437 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84438 write_seqcount_begin(&timekeeper_seq);
84439
84440 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84441 index 61ed862..3b52c65 100644
84442 --- a/kernel/time/timer_list.c
84443 +++ b/kernel/time/timer_list.c
84444 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84445
84446 static void print_name_offset(struct seq_file *m, void *sym)
84447 {
84448 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84449 + SEQ_printf(m, "<%p>", NULL);
84450 +#else
84451 char symname[KSYM_NAME_LEN];
84452
84453 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84454 SEQ_printf(m, "<%pK>", sym);
84455 else
84456 SEQ_printf(m, "%s", symname);
84457 +#endif
84458 }
84459
84460 static void
84461 @@ -119,7 +123,11 @@ next_one:
84462 static void
84463 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84464 {
84465 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84466 + SEQ_printf(m, " .base: %p\n", NULL);
84467 +#else
84468 SEQ_printf(m, " .base: %pK\n", base);
84469 +#endif
84470 SEQ_printf(m, " .index: %d\n",
84471 base->index);
84472 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84473 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84474 {
84475 struct proc_dir_entry *pe;
84476
84477 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84478 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84479 +#else
84480 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84481 +#endif
84482 if (!pe)
84483 return -ENOMEM;
84484 return 0;
84485 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84486 index 0b537f2..40d6c20 100644
84487 --- a/kernel/time/timer_stats.c
84488 +++ b/kernel/time/timer_stats.c
84489 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84490 static unsigned long nr_entries;
84491 static struct entry entries[MAX_ENTRIES];
84492
84493 -static atomic_t overflow_count;
84494 +static atomic_unchecked_t overflow_count;
84495
84496 /*
84497 * The entries are in a hash-table, for fast lookup:
84498 @@ -140,7 +140,7 @@ static void reset_entries(void)
84499 nr_entries = 0;
84500 memset(entries, 0, sizeof(entries));
84501 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84502 - atomic_set(&overflow_count, 0);
84503 + atomic_set_unchecked(&overflow_count, 0);
84504 }
84505
84506 static struct entry *alloc_entry(void)
84507 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84508 if (likely(entry))
84509 entry->count++;
84510 else
84511 - atomic_inc(&overflow_count);
84512 + atomic_inc_unchecked(&overflow_count);
84513
84514 out_unlock:
84515 raw_spin_unlock_irqrestore(lock, flags);
84516 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84517
84518 static void print_name_offset(struct seq_file *m, unsigned long addr)
84519 {
84520 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84521 + seq_printf(m, "<%p>", NULL);
84522 +#else
84523 char symname[KSYM_NAME_LEN];
84524
84525 if (lookup_symbol_name(addr, symname) < 0)
84526 - seq_printf(m, "<%p>", (void *)addr);
84527 + seq_printf(m, "<%pK>", (void *)addr);
84528 else
84529 seq_printf(m, "%s", symname);
84530 +#endif
84531 }
84532
84533 static int tstats_show(struct seq_file *m, void *v)
84534 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84535
84536 seq_puts(m, "Timer Stats Version: v0.2\n");
84537 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84538 - if (atomic_read(&overflow_count))
84539 + if (atomic_read_unchecked(&overflow_count))
84540 seq_printf(m, "Overflow: %d entries\n",
84541 - atomic_read(&overflow_count));
84542 + atomic_read_unchecked(&overflow_count));
84543
84544 for (i = 0; i < nr_entries; i++) {
84545 entry = entries + i;
84546 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84547 {
84548 struct proc_dir_entry *pe;
84549
84550 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84551 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84552 +#else
84553 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84554 +#endif
84555 if (!pe)
84556 return -ENOMEM;
84557 return 0;
84558 diff --git a/kernel/timer.c b/kernel/timer.c
84559 index 4296d13..8998609 100644
84560 --- a/kernel/timer.c
84561 +++ b/kernel/timer.c
84562 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84563 /*
84564 * This function runs timers and the timer-tq in bottom half context.
84565 */
84566 -static void run_timer_softirq(struct softirq_action *h)
84567 +static void run_timer_softirq(void)
84568 {
84569 struct tvec_base *base = __this_cpu_read(tvec_bases);
84570
84571 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84572 *
84573 * In all cases the return value is guaranteed to be non-negative.
84574 */
84575 -signed long __sched schedule_timeout(signed long timeout)
84576 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84577 {
84578 struct timer_list timer;
84579 unsigned long expire;
84580 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84581 index b8b8560..75b1a09 100644
84582 --- a/kernel/trace/blktrace.c
84583 +++ b/kernel/trace/blktrace.c
84584 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84585 struct blk_trace *bt = filp->private_data;
84586 char buf[16];
84587
84588 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84589 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84590
84591 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84592 }
84593 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84594 return 1;
84595
84596 bt = buf->chan->private_data;
84597 - atomic_inc(&bt->dropped);
84598 + atomic_inc_unchecked(&bt->dropped);
84599 return 0;
84600 }
84601
84602 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84603
84604 bt->dir = dir;
84605 bt->dev = dev;
84606 - atomic_set(&bt->dropped, 0);
84607 + atomic_set_unchecked(&bt->dropped, 0);
84608
84609 ret = -EIO;
84610 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84611 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84612 index a6d098c..bb8cf65 100644
84613 --- a/kernel/trace/ftrace.c
84614 +++ b/kernel/trace/ftrace.c
84615 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84616 if (unlikely(ftrace_disabled))
84617 return 0;
84618
84619 + ret = ftrace_arch_code_modify_prepare();
84620 + FTRACE_WARN_ON(ret);
84621 + if (ret)
84622 + return 0;
84623 +
84624 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84625 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84626 if (ret) {
84627 ftrace_bug(ret, ip);
84628 - return 0;
84629 }
84630 - return 1;
84631 + return ret ? 0 : 1;
84632 }
84633
84634 /*
84635 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84636 if (!count)
84637 return 0;
84638
84639 + pax_open_kernel();
84640 sort(start, count, sizeof(*start),
84641 ftrace_cmp_ips, ftrace_swap_ips);
84642 + pax_close_kernel();
84643
84644 start_pg = ftrace_allocate_pages(count);
84645 if (!start_pg)
84646 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84647 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84648
84649 static int ftrace_graph_active;
84650 -static struct notifier_block ftrace_suspend_notifier;
84651 -
84652 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84653 {
84654 return 0;
84655 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84656 return NOTIFY_DONE;
84657 }
84658
84659 +static struct notifier_block ftrace_suspend_notifier = {
84660 + .notifier_call = ftrace_suspend_notifier_call
84661 +};
84662 +
84663 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84664 trace_func_graph_ent_t entryfunc)
84665 {
84666 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84667 goto out;
84668 }
84669
84670 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84671 register_pm_notifier(&ftrace_suspend_notifier);
84672
84673 ftrace_graph_active++;
84674 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84675 index cc2f66f..05edd54 100644
84676 --- a/kernel/trace/ring_buffer.c
84677 +++ b/kernel/trace/ring_buffer.c
84678 @@ -352,9 +352,9 @@ struct buffer_data_page {
84679 */
84680 struct buffer_page {
84681 struct list_head list; /* list of buffer pages */
84682 - local_t write; /* index for next write */
84683 + local_unchecked_t write; /* index for next write */
84684 unsigned read; /* index for next read */
84685 - local_t entries; /* entries on this page */
84686 + local_unchecked_t entries; /* entries on this page */
84687 unsigned long real_end; /* real end of data */
84688 struct buffer_data_page *page; /* Actual data page */
84689 };
84690 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84691 unsigned long last_overrun;
84692 local_t entries_bytes;
84693 local_t entries;
84694 - local_t overrun;
84695 - local_t commit_overrun;
84696 + local_unchecked_t overrun;
84697 + local_unchecked_t commit_overrun;
84698 local_t dropped_events;
84699 local_t committing;
84700 local_t commits;
84701 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84702 *
84703 * We add a counter to the write field to denote this.
84704 */
84705 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84706 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84707 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84708 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84709
84710 /*
84711 * Just make sure we have seen our old_write and synchronize
84712 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84713 * cmpxchg to only update if an interrupt did not already
84714 * do it for us. If the cmpxchg fails, we don't care.
84715 */
84716 - (void)local_cmpxchg(&next_page->write, old_write, val);
84717 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84718 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84719 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84720
84721 /*
84722 * No need to worry about races with clearing out the commit.
84723 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84724
84725 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84726 {
84727 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84728 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84729 }
84730
84731 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84732 {
84733 - return local_read(&bpage->write) & RB_WRITE_MASK;
84734 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84735 }
84736
84737 static int
84738 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84739 * bytes consumed in ring buffer from here.
84740 * Increment overrun to account for the lost events.
84741 */
84742 - local_add(page_entries, &cpu_buffer->overrun);
84743 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84744 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84745 }
84746
84747 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84748 * it is our responsibility to update
84749 * the counters.
84750 */
84751 - local_add(entries, &cpu_buffer->overrun);
84752 + local_add_unchecked(entries, &cpu_buffer->overrun);
84753 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84754
84755 /*
84756 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84757 if (tail == BUF_PAGE_SIZE)
84758 tail_page->real_end = 0;
84759
84760 - local_sub(length, &tail_page->write);
84761 + local_sub_unchecked(length, &tail_page->write);
84762 return;
84763 }
84764
84765 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84766 rb_event_set_padding(event);
84767
84768 /* Set the write back to the previous setting */
84769 - local_sub(length, &tail_page->write);
84770 + local_sub_unchecked(length, &tail_page->write);
84771 return;
84772 }
84773
84774 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84775
84776 /* Set write to end of buffer */
84777 length = (tail + length) - BUF_PAGE_SIZE;
84778 - local_sub(length, &tail_page->write);
84779 + local_sub_unchecked(length, &tail_page->write);
84780 }
84781
84782 /*
84783 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84784 * about it.
84785 */
84786 if (unlikely(next_page == commit_page)) {
84787 - local_inc(&cpu_buffer->commit_overrun);
84788 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84789 goto out_reset;
84790 }
84791
84792 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84793 cpu_buffer->tail_page) &&
84794 (cpu_buffer->commit_page ==
84795 cpu_buffer->reader_page))) {
84796 - local_inc(&cpu_buffer->commit_overrun);
84797 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84798 goto out_reset;
84799 }
84800 }
84801 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84802 length += RB_LEN_TIME_EXTEND;
84803
84804 tail_page = cpu_buffer->tail_page;
84805 - write = local_add_return(length, &tail_page->write);
84806 + write = local_add_return_unchecked(length, &tail_page->write);
84807
84808 /* set write to only the index of the write */
84809 write &= RB_WRITE_MASK;
84810 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84811 kmemcheck_annotate_bitfield(event, bitfield);
84812 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84813
84814 - local_inc(&tail_page->entries);
84815 + local_inc_unchecked(&tail_page->entries);
84816
84817 /*
84818 * If this is the first commit on the page, then update
84819 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84820
84821 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84822 unsigned long write_mask =
84823 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84824 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84825 unsigned long event_length = rb_event_length(event);
84826 /*
84827 * This is on the tail page. It is possible that
84828 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84829 */
84830 old_index += write_mask;
84831 new_index += write_mask;
84832 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84833 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84834 if (index == old_index) {
84835 /* update counters */
84836 local_sub(event_length, &cpu_buffer->entries_bytes);
84837 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84838
84839 /* Do the likely case first */
84840 if (likely(bpage->page == (void *)addr)) {
84841 - local_dec(&bpage->entries);
84842 + local_dec_unchecked(&bpage->entries);
84843 return;
84844 }
84845
84846 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84847 start = bpage;
84848 do {
84849 if (bpage->page == (void *)addr) {
84850 - local_dec(&bpage->entries);
84851 + local_dec_unchecked(&bpage->entries);
84852 return;
84853 }
84854 rb_inc_page(cpu_buffer, &bpage);
84855 @@ -3139,7 +3139,7 @@ static inline unsigned long
84856 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84857 {
84858 return local_read(&cpu_buffer->entries) -
84859 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84860 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84861 }
84862
84863 /**
84864 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84865 return 0;
84866
84867 cpu_buffer = buffer->buffers[cpu];
84868 - ret = local_read(&cpu_buffer->overrun);
84869 + ret = local_read_unchecked(&cpu_buffer->overrun);
84870
84871 return ret;
84872 }
84873 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84874 return 0;
84875
84876 cpu_buffer = buffer->buffers[cpu];
84877 - ret = local_read(&cpu_buffer->commit_overrun);
84878 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84879
84880 return ret;
84881 }
84882 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
84883 /* if you care about this being correct, lock the buffer */
84884 for_each_buffer_cpu(buffer, cpu) {
84885 cpu_buffer = buffer->buffers[cpu];
84886 - overruns += local_read(&cpu_buffer->overrun);
84887 + overruns += local_read_unchecked(&cpu_buffer->overrun);
84888 }
84889
84890 return overruns;
84891 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84892 /*
84893 * Reset the reader page to size zero.
84894 */
84895 - local_set(&cpu_buffer->reader_page->write, 0);
84896 - local_set(&cpu_buffer->reader_page->entries, 0);
84897 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84898 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84899 local_set(&cpu_buffer->reader_page->page->commit, 0);
84900 cpu_buffer->reader_page->real_end = 0;
84901
84902 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84903 * want to compare with the last_overrun.
84904 */
84905 smp_mb();
84906 - overwrite = local_read(&(cpu_buffer->overrun));
84907 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
84908
84909 /*
84910 * Here's the tricky part.
84911 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84912
84913 cpu_buffer->head_page
84914 = list_entry(cpu_buffer->pages, struct buffer_page, list);
84915 - local_set(&cpu_buffer->head_page->write, 0);
84916 - local_set(&cpu_buffer->head_page->entries, 0);
84917 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
84918 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
84919 local_set(&cpu_buffer->head_page->page->commit, 0);
84920
84921 cpu_buffer->head_page->read = 0;
84922 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84923
84924 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
84925 INIT_LIST_HEAD(&cpu_buffer->new_pages);
84926 - local_set(&cpu_buffer->reader_page->write, 0);
84927 - local_set(&cpu_buffer->reader_page->entries, 0);
84928 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84929 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84930 local_set(&cpu_buffer->reader_page->page->commit, 0);
84931 cpu_buffer->reader_page->read = 0;
84932
84933 local_set(&cpu_buffer->entries_bytes, 0);
84934 - local_set(&cpu_buffer->overrun, 0);
84935 - local_set(&cpu_buffer->commit_overrun, 0);
84936 + local_set_unchecked(&cpu_buffer->overrun, 0);
84937 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
84938 local_set(&cpu_buffer->dropped_events, 0);
84939 local_set(&cpu_buffer->entries, 0);
84940 local_set(&cpu_buffer->committing, 0);
84941 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
84942 rb_init_page(bpage);
84943 bpage = reader->page;
84944 reader->page = *data_page;
84945 - local_set(&reader->write, 0);
84946 - local_set(&reader->entries, 0);
84947 + local_set_unchecked(&reader->write, 0);
84948 + local_set_unchecked(&reader->entries, 0);
84949 reader->read = 0;
84950 *data_page = bpage;
84951
84952 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
84953 index 496f94d..754aeea 100644
84954 --- a/kernel/trace/trace.c
84955 +++ b/kernel/trace/trace.c
84956 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
84957 return 0;
84958 }
84959
84960 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
84961 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
84962 {
84963 /* do nothing if flag is already set */
84964 if (!!(trace_flags & mask) == !!enabled)
84965 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
84966 index afaae41..64871f8 100644
84967 --- a/kernel/trace/trace.h
84968 +++ b/kernel/trace/trace.h
84969 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
84970 void trace_printk_init_buffers(void);
84971 void trace_printk_start_comm(void);
84972 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
84973 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
84974 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
84975
84976 /*
84977 * Normal trace_printk() and friends allocates special buffers
84978 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
84979 index 26dc348..8708ca7 100644
84980 --- a/kernel/trace/trace_clock.c
84981 +++ b/kernel/trace/trace_clock.c
84982 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
84983 return now;
84984 }
84985
84986 -static atomic64_t trace_counter;
84987 +static atomic64_unchecked_t trace_counter;
84988
84989 /*
84990 * trace_clock_counter(): simply an atomic counter.
84991 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
84992 */
84993 u64 notrace trace_clock_counter(void)
84994 {
84995 - return atomic64_add_return(1, &trace_counter);
84996 + return atomic64_inc_return_unchecked(&trace_counter);
84997 }
84998 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
84999 index 29a7ebc..eb473cf 100644
85000 --- a/kernel/trace/trace_events.c
85001 +++ b/kernel/trace/trace_events.c
85002 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
85003 struct ftrace_module_file_ops {
85004 struct list_head list;
85005 struct module *mod;
85006 - struct file_operations id;
85007 - struct file_operations enable;
85008 - struct file_operations format;
85009 - struct file_operations filter;
85010 };
85011
85012 static struct ftrace_module_file_ops *
85013 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
85014
85015 file_ops->mod = mod;
85016
85017 - file_ops->id = ftrace_event_id_fops;
85018 - file_ops->id.owner = mod;
85019 -
85020 - file_ops->enable = ftrace_enable_fops;
85021 - file_ops->enable.owner = mod;
85022 -
85023 - file_ops->filter = ftrace_event_filter_fops;
85024 - file_ops->filter.owner = mod;
85025 -
85026 - file_ops->format = ftrace_event_format_fops;
85027 - file_ops->format.owner = mod;
85028 + pax_open_kernel();
85029 + mod->trace_id.owner = mod;
85030 + mod->trace_enable.owner = mod;
85031 + mod->trace_filter.owner = mod;
85032 + mod->trace_format.owner = mod;
85033 + pax_close_kernel();
85034
85035 list_add(&file_ops->list, &ftrace_module_file_list);
85036
85037 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
85038 struct ftrace_module_file_ops *file_ops)
85039 {
85040 return __trace_add_new_event(call, tr,
85041 - &file_ops->id, &file_ops->enable,
85042 - &file_ops->filter, &file_ops->format);
85043 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
85044 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
85045 }
85046
85047 #else
85048 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
85049 index b3dcfb2..ebee344 100644
85050 --- a/kernel/trace/trace_mmiotrace.c
85051 +++ b/kernel/trace/trace_mmiotrace.c
85052 @@ -24,7 +24,7 @@ struct header_iter {
85053 static struct trace_array *mmio_trace_array;
85054 static bool overrun_detected;
85055 static unsigned long prev_overruns;
85056 -static atomic_t dropped_count;
85057 +static atomic_unchecked_t dropped_count;
85058
85059 static void mmio_reset_data(struct trace_array *tr)
85060 {
85061 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
85062
85063 static unsigned long count_overruns(struct trace_iterator *iter)
85064 {
85065 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
85066 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
85067 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
85068
85069 if (over > prev_overruns)
85070 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
85071 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
85072 sizeof(*entry), 0, pc);
85073 if (!event) {
85074 - atomic_inc(&dropped_count);
85075 + atomic_inc_unchecked(&dropped_count);
85076 return;
85077 }
85078 entry = ring_buffer_event_data(event);
85079 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
85080 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
85081 sizeof(*entry), 0, pc);
85082 if (!event) {
85083 - atomic_inc(&dropped_count);
85084 + atomic_inc_unchecked(&dropped_count);
85085 return;
85086 }
85087 entry = ring_buffer_event_data(event);
85088 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
85089 index 34e7cba..6f9a729 100644
85090 --- a/kernel/trace/trace_output.c
85091 +++ b/kernel/trace/trace_output.c
85092 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
85093
85094 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
85095 if (!IS_ERR(p)) {
85096 - p = mangle_path(s->buffer + s->len, p, "\n");
85097 + p = mangle_path(s->buffer + s->len, p, "\n\\");
85098 if (p) {
85099 s->len = p - s->buffer;
85100 return 1;
85101 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
85102 goto out;
85103 }
85104
85105 + pax_open_kernel();
85106 if (event->funcs->trace == NULL)
85107 - event->funcs->trace = trace_nop_print;
85108 + *(void **)&event->funcs->trace = trace_nop_print;
85109 if (event->funcs->raw == NULL)
85110 - event->funcs->raw = trace_nop_print;
85111 + *(void **)&event->funcs->raw = trace_nop_print;
85112 if (event->funcs->hex == NULL)
85113 - event->funcs->hex = trace_nop_print;
85114 + *(void **)&event->funcs->hex = trace_nop_print;
85115 if (event->funcs->binary == NULL)
85116 - event->funcs->binary = trace_nop_print;
85117 + *(void **)&event->funcs->binary = trace_nop_print;
85118 + pax_close_kernel();
85119
85120 key = event->type & (EVENT_HASHSIZE - 1);
85121
85122 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
85123 index b20428c..4845a10 100644
85124 --- a/kernel/trace/trace_stack.c
85125 +++ b/kernel/trace/trace_stack.c
85126 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
85127 return;
85128
85129 /* we do not handle interrupt stacks yet */
85130 - if (!object_is_on_stack(stack))
85131 + if (!object_starts_on_stack(stack))
85132 return;
85133
85134 local_irq_save(flags);
85135 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
85136 index 9064b91..1f5d2f8 100644
85137 --- a/kernel/user_namespace.c
85138 +++ b/kernel/user_namespace.c
85139 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
85140 !kgid_has_mapping(parent_ns, group))
85141 return -EPERM;
85142
85143 +#ifdef CONFIG_GRKERNSEC
85144 + /*
85145 + * This doesn't really inspire confidence:
85146 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
85147 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
85148 + * Increases kernel attack surface in areas developers
85149 + * previously cared little about ("low importance due
85150 + * to requiring "root" capability")
85151 + * To be removed when this code receives *proper* review
85152 + */
85153 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
85154 + !capable(CAP_SETGID))
85155 + return -EPERM;
85156 +#endif
85157 +
85158 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
85159 if (!ns)
85160 return -ENOMEM;
85161 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
85162 if (atomic_read(&current->mm->mm_users) > 1)
85163 return -EINVAL;
85164
85165 - if (current->fs->users != 1)
85166 + if (atomic_read(&current->fs->users) != 1)
85167 return -EINVAL;
85168
85169 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
85170 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
85171 index 4f69f9a..7c6f8f8 100644
85172 --- a/kernel/utsname_sysctl.c
85173 +++ b/kernel/utsname_sysctl.c
85174 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
85175 static int proc_do_uts_string(ctl_table *table, int write,
85176 void __user *buffer, size_t *lenp, loff_t *ppos)
85177 {
85178 - struct ctl_table uts_table;
85179 + ctl_table_no_const uts_table;
85180 int r;
85181 memcpy(&uts_table, table, sizeof(uts_table));
85182 uts_table.data = get_uts(table, write);
85183 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
85184 index 1241d8c..d5cfc28 100644
85185 --- a/kernel/watchdog.c
85186 +++ b/kernel/watchdog.c
85187 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
85188 static void watchdog_nmi_disable(unsigned int cpu) { return; }
85189 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
85190
85191 -static struct smp_hotplug_thread watchdog_threads = {
85192 +static struct smp_hotplug_thread watchdog_threads __read_only = {
85193 .store = &softlockup_watchdog,
85194 .thread_should_run = watchdog_should_run,
85195 .thread_fn = watchdog,
85196 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
85197 index e93f7b9..989fcd7 100644
85198 --- a/kernel/workqueue.c
85199 +++ b/kernel/workqueue.c
85200 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
85201 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
85202 worker_flags |= WORKER_REBOUND;
85203 worker_flags &= ~WORKER_UNBOUND;
85204 - ACCESS_ONCE(worker->flags) = worker_flags;
85205 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
85206 }
85207
85208 spin_unlock_irq(&pool->lock);
85209 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
85210 index 1501aa5..e771896 100644
85211 --- a/lib/Kconfig.debug
85212 +++ b/lib/Kconfig.debug
85213 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
85214
85215 config DEBUG_WW_MUTEX_SLOWPATH
85216 bool "Wait/wound mutex debugging: Slowpath testing"
85217 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85218 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85219 select DEBUG_LOCK_ALLOC
85220 select DEBUG_SPINLOCK
85221 select DEBUG_MUTEXES
85222 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
85223
85224 config DEBUG_LOCK_ALLOC
85225 bool "Lock debugging: detect incorrect freeing of live locks"
85226 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85227 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85228 select DEBUG_SPINLOCK
85229 select DEBUG_MUTEXES
85230 select LOCKDEP
85231 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85232
85233 config PROVE_LOCKING
85234 bool "Lock debugging: prove locking correctness"
85235 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85236 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85237 select LOCKDEP
85238 select DEBUG_SPINLOCK
85239 select DEBUG_MUTEXES
85240 @@ -914,7 +914,7 @@ config LOCKDEP
85241
85242 config LOCK_STAT
85243 bool "Lock usage statistics"
85244 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85245 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85246 select LOCKDEP
85247 select DEBUG_SPINLOCK
85248 select DEBUG_MUTEXES
85249 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85250 depends on DEBUG_KERNEL
85251 depends on STACKTRACE_SUPPORT
85252 depends on PROC_FS
85253 + depends on !GRKERNSEC_HIDESYM
85254 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85255 select KALLSYMS
85256 select KALLSYMS_ALL
85257 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85258 config DEBUG_STRICT_USER_COPY_CHECKS
85259 bool "Strict user copy size checks"
85260 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85261 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85262 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85263 help
85264 Enabling this option turns a certain set of sanity checks for user
85265 copy operations into compile time failures.
85266 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85267
85268 config PROVIDE_OHCI1394_DMA_INIT
85269 bool "Remote debugging over FireWire early on boot"
85270 - depends on PCI && X86
85271 + depends on PCI && X86 && !GRKERNSEC
85272 help
85273 If you want to debug problems which hang or crash the kernel early
85274 on boot and the crashing machine has a FireWire port, you can use
85275 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85276
85277 config FIREWIRE_OHCI_REMOTE_DMA
85278 bool "Remote debugging over FireWire with firewire-ohci"
85279 - depends on FIREWIRE_OHCI
85280 + depends on FIREWIRE_OHCI && !GRKERNSEC
85281 help
85282 This option lets you use the FireWire bus for remote debugging
85283 with help of the firewire-ohci driver. It enables unfiltered
85284 diff --git a/lib/Makefile b/lib/Makefile
85285 index 7baccfd..3ceb95f 100644
85286 --- a/lib/Makefile
85287 +++ b/lib/Makefile
85288 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85289
85290 obj-$(CONFIG_BTREE) += btree.o
85291 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85292 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85293 +obj-y += list_debug.o
85294 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85295
85296 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85297 diff --git a/lib/bitmap.c b/lib/bitmap.c
85298 index 06f7e4f..f3cf2b0 100644
85299 --- a/lib/bitmap.c
85300 +++ b/lib/bitmap.c
85301 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85302 {
85303 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85304 u32 chunk;
85305 - const char __user __force *ubuf = (const char __user __force *)buf;
85306 + const char __user *ubuf = (const char __force_user *)buf;
85307
85308 bitmap_zero(maskp, nmaskbits);
85309
85310 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85311 {
85312 if (!access_ok(VERIFY_READ, ubuf, ulen))
85313 return -EFAULT;
85314 - return __bitmap_parse((const char __force *)ubuf,
85315 + return __bitmap_parse((const char __force_kernel *)ubuf,
85316 ulen, 1, maskp, nmaskbits);
85317
85318 }
85319 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85320 {
85321 unsigned a, b;
85322 int c, old_c, totaldigits;
85323 - const char __user __force *ubuf = (const char __user __force *)buf;
85324 + const char __user *ubuf = (const char __force_user *)buf;
85325 int exp_digit, in_range;
85326
85327 totaldigits = c = 0;
85328 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85329 {
85330 if (!access_ok(VERIFY_READ, ubuf, ulen))
85331 return -EFAULT;
85332 - return __bitmap_parselist((const char __force *)ubuf,
85333 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85334 ulen, 1, maskp, nmaskbits);
85335 }
85336 EXPORT_SYMBOL(bitmap_parselist_user);
85337 diff --git a/lib/bug.c b/lib/bug.c
85338 index 1686034..a9c00c8 100644
85339 --- a/lib/bug.c
85340 +++ b/lib/bug.c
85341 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85342 return BUG_TRAP_TYPE_NONE;
85343
85344 bug = find_bug(bugaddr);
85345 + if (!bug)
85346 + return BUG_TRAP_TYPE_NONE;
85347
85348 file = NULL;
85349 line = 0;
85350 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85351 index 37061ed..da83f48 100644
85352 --- a/lib/debugobjects.c
85353 +++ b/lib/debugobjects.c
85354 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85355 if (limit > 4)
85356 return;
85357
85358 - is_on_stack = object_is_on_stack(addr);
85359 + is_on_stack = object_starts_on_stack(addr);
85360 if (is_on_stack == onstack)
85361 return;
85362
85363 diff --git a/lib/devres.c b/lib/devres.c
85364 index 8235331..5881053 100644
85365 --- a/lib/devres.c
85366 +++ b/lib/devres.c
85367 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85368 void devm_iounmap(struct device *dev, void __iomem *addr)
85369 {
85370 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85371 - (void *)addr));
85372 + (void __force *)addr));
85373 iounmap(addr);
85374 }
85375 EXPORT_SYMBOL(devm_iounmap);
85376 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85377 {
85378 ioport_unmap(addr);
85379 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85380 - devm_ioport_map_match, (void *)addr));
85381 + devm_ioport_map_match, (void __force *)addr));
85382 }
85383 EXPORT_SYMBOL(devm_ioport_unmap);
85384 #endif /* CONFIG_HAS_IOPORT */
85385 diff --git a/lib/div64.c b/lib/div64.c
85386 index a163b6c..9618fa5 100644
85387 --- a/lib/div64.c
85388 +++ b/lib/div64.c
85389 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85390 EXPORT_SYMBOL(__div64_32);
85391
85392 #ifndef div_s64_rem
85393 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85394 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85395 {
85396 u64 quotient;
85397
85398 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85399 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85400 */
85401 #ifndef div64_u64
85402 -u64 div64_u64(u64 dividend, u64 divisor)
85403 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85404 {
85405 u32 high = divisor >> 32;
85406 u64 quot;
85407 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85408 index d87a17a..ac0d79a 100644
85409 --- a/lib/dma-debug.c
85410 +++ b/lib/dma-debug.c
85411 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85412
85413 void dma_debug_add_bus(struct bus_type *bus)
85414 {
85415 - struct notifier_block *nb;
85416 + notifier_block_no_const *nb;
85417
85418 if (global_disable)
85419 return;
85420 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85421
85422 static void check_for_stack(struct device *dev, void *addr)
85423 {
85424 - if (object_is_on_stack(addr))
85425 + if (object_starts_on_stack(addr))
85426 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85427 "stack [addr=%p]\n", addr);
85428 }
85429 diff --git a/lib/inflate.c b/lib/inflate.c
85430 index 013a761..c28f3fc 100644
85431 --- a/lib/inflate.c
85432 +++ b/lib/inflate.c
85433 @@ -269,7 +269,7 @@ static void free(void *where)
85434 malloc_ptr = free_mem_ptr;
85435 }
85436 #else
85437 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85438 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85439 #define free(a) kfree(a)
85440 #endif
85441
85442 diff --git a/lib/ioremap.c b/lib/ioremap.c
85443 index 0c9216c..863bd89 100644
85444 --- a/lib/ioremap.c
85445 +++ b/lib/ioremap.c
85446 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85447 unsigned long next;
85448
85449 phys_addr -= addr;
85450 - pmd = pmd_alloc(&init_mm, pud, addr);
85451 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85452 if (!pmd)
85453 return -ENOMEM;
85454 do {
85455 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85456 unsigned long next;
85457
85458 phys_addr -= addr;
85459 - pud = pud_alloc(&init_mm, pgd, addr);
85460 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85461 if (!pud)
85462 return -ENOMEM;
85463 do {
85464 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85465 index bd2bea9..6b3c95e 100644
85466 --- a/lib/is_single_threaded.c
85467 +++ b/lib/is_single_threaded.c
85468 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85469 struct task_struct *p, *t;
85470 bool ret;
85471
85472 + if (!mm)
85473 + return true;
85474 +
85475 if (atomic_read(&task->signal->live) != 1)
85476 return false;
85477
85478 diff --git a/lib/kobject.c b/lib/kobject.c
85479 index 4a1f33d..2f3ca75 100644
85480 --- a/lib/kobject.c
85481 +++ b/lib/kobject.c
85482 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85483
85484
85485 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85486 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85487 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85488
85489 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85490 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85491 {
85492 enum kobj_ns_type type = ops->type;
85493 int error;
85494 diff --git a/lib/list_debug.c b/lib/list_debug.c
85495 index c24c2f7..06e070b 100644
85496 --- a/lib/list_debug.c
85497 +++ b/lib/list_debug.c
85498 @@ -11,7 +11,9 @@
85499 #include <linux/bug.h>
85500 #include <linux/kernel.h>
85501 #include <linux/rculist.h>
85502 +#include <linux/mm.h>
85503
85504 +#ifdef CONFIG_DEBUG_LIST
85505 /*
85506 * Insert a new entry between two known consecutive entries.
85507 *
85508 @@ -19,21 +21,32 @@
85509 * the prev/next entries already!
85510 */
85511
85512 -void __list_add(struct list_head *new,
85513 - struct list_head *prev,
85514 - struct list_head *next)
85515 +static bool __list_add_debug(struct list_head *new,
85516 + struct list_head *prev,
85517 + struct list_head *next)
85518 {
85519 - WARN(next->prev != prev,
85520 + if (WARN(next->prev != prev,
85521 "list_add corruption. next->prev should be "
85522 "prev (%p), but was %p. (next=%p).\n",
85523 - prev, next->prev, next);
85524 - WARN(prev->next != next,
85525 + prev, next->prev, next) ||
85526 + WARN(prev->next != next,
85527 "list_add corruption. prev->next should be "
85528 "next (%p), but was %p. (prev=%p).\n",
85529 - next, prev->next, prev);
85530 - WARN(new == prev || new == next,
85531 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85532 - new, prev, next);
85533 + next, prev->next, prev) ||
85534 + WARN(new == prev || new == next,
85535 + "list_add double add: new=%p, prev=%p, next=%p.\n",
85536 + new, prev, next))
85537 + return false;
85538 + return true;
85539 +}
85540 +
85541 +void __list_add(struct list_head *new,
85542 + struct list_head *prev,
85543 + struct list_head *next)
85544 +{
85545 + if (!__list_add_debug(new, prev, next))
85546 + return;
85547 +
85548 next->prev = new;
85549 new->next = next;
85550 new->prev = prev;
85551 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
85552 }
85553 EXPORT_SYMBOL(__list_add);
85554
85555 -void __list_del_entry(struct list_head *entry)
85556 +static bool __list_del_entry_debug(struct list_head *entry)
85557 {
85558 struct list_head *prev, *next;
85559
85560 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
85561 WARN(next->prev != entry,
85562 "list_del corruption. next->prev should be %p, "
85563 "but was %p\n", entry, next->prev))
85564 + return false;
85565 + return true;
85566 +}
85567 +
85568 +void __list_del_entry(struct list_head *entry)
85569 +{
85570 + if (!__list_del_entry_debug(entry))
85571 return;
85572
85573 - __list_del(prev, next);
85574 + __list_del(entry->prev, entry->next);
85575 }
85576 EXPORT_SYMBOL(__list_del_entry);
85577
85578 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
85579 void __list_add_rcu(struct list_head *new,
85580 struct list_head *prev, struct list_head *next)
85581 {
85582 - WARN(next->prev != prev,
85583 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85584 - prev, next->prev, next);
85585 - WARN(prev->next != next,
85586 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85587 - next, prev->next, prev);
85588 + if (!__list_add_debug(new, prev, next))
85589 + return;
85590 +
85591 new->next = next;
85592 new->prev = prev;
85593 rcu_assign_pointer(list_next_rcu(prev), new);
85594 next->prev = new;
85595 }
85596 EXPORT_SYMBOL(__list_add_rcu);
85597 +#endif
85598 +
85599 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85600 +{
85601 +#ifdef CONFIG_DEBUG_LIST
85602 + if (!__list_add_debug(new, prev, next))
85603 + return;
85604 +#endif
85605 +
85606 + pax_open_kernel();
85607 + next->prev = new;
85608 + new->next = next;
85609 + new->prev = prev;
85610 + prev->next = new;
85611 + pax_close_kernel();
85612 +}
85613 +EXPORT_SYMBOL(__pax_list_add);
85614 +
85615 +void pax_list_del(struct list_head *entry)
85616 +{
85617 +#ifdef CONFIG_DEBUG_LIST
85618 + if (!__list_del_entry_debug(entry))
85619 + return;
85620 +#endif
85621 +
85622 + pax_open_kernel();
85623 + __list_del(entry->prev, entry->next);
85624 + entry->next = LIST_POISON1;
85625 + entry->prev = LIST_POISON2;
85626 + pax_close_kernel();
85627 +}
85628 +EXPORT_SYMBOL(pax_list_del);
85629 +
85630 +void pax_list_del_init(struct list_head *entry)
85631 +{
85632 + pax_open_kernel();
85633 + __list_del(entry->prev, entry->next);
85634 + INIT_LIST_HEAD(entry);
85635 + pax_close_kernel();
85636 +}
85637 +EXPORT_SYMBOL(pax_list_del_init);
85638 +
85639 +void __pax_list_add_rcu(struct list_head *new,
85640 + struct list_head *prev, struct list_head *next)
85641 +{
85642 +#ifdef CONFIG_DEBUG_LIST
85643 + if (!__list_add_debug(new, prev, next))
85644 + return;
85645 +#endif
85646 +
85647 + pax_open_kernel();
85648 + new->next = next;
85649 + new->prev = prev;
85650 + rcu_assign_pointer(list_next_rcu(prev), new);
85651 + next->prev = new;
85652 + pax_close_kernel();
85653 +}
85654 +EXPORT_SYMBOL(__pax_list_add_rcu);
85655 +
85656 +void pax_list_del_rcu(struct list_head *entry)
85657 +{
85658 +#ifdef CONFIG_DEBUG_LIST
85659 + if (!__list_del_entry_debug(entry))
85660 + return;
85661 +#endif
85662 +
85663 + pax_open_kernel();
85664 + __list_del(entry->prev, entry->next);
85665 + entry->next = LIST_POISON1;
85666 + entry->prev = LIST_POISON2;
85667 + pax_close_kernel();
85668 +}
85669 +EXPORT_SYMBOL(pax_list_del_rcu);
85670 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85671 index e796429..6e38f9f 100644
85672 --- a/lib/radix-tree.c
85673 +++ b/lib/radix-tree.c
85674 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85675 int nr;
85676 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85677 };
85678 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85679 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85680
85681 static inline void *ptr_to_indirect(void *ptr)
85682 {
85683 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85684 index bb2b201..46abaf9 100644
85685 --- a/lib/strncpy_from_user.c
85686 +++ b/lib/strncpy_from_user.c
85687 @@ -21,7 +21,7 @@
85688 */
85689 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
85690 {
85691 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85692 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85693 long res = 0;
85694
85695 /*
85696 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85697 index a28df52..3d55877 100644
85698 --- a/lib/strnlen_user.c
85699 +++ b/lib/strnlen_user.c
85700 @@ -26,7 +26,7 @@
85701 */
85702 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85703 {
85704 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85705 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85706 long align, res = 0;
85707 unsigned long c;
85708
85709 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85710 index d23762e..e21eab2 100644
85711 --- a/lib/swiotlb.c
85712 +++ b/lib/swiotlb.c
85713 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85714
85715 void
85716 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85717 - dma_addr_t dev_addr)
85718 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85719 {
85720 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85721
85722 diff --git a/lib/usercopy.c b/lib/usercopy.c
85723 index 4f5b1dd..7cab418 100644
85724 --- a/lib/usercopy.c
85725 +++ b/lib/usercopy.c
85726 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85727 WARN(1, "Buffer overflow detected!\n");
85728 }
85729 EXPORT_SYMBOL(copy_from_user_overflow);
85730 +
85731 +void copy_to_user_overflow(void)
85732 +{
85733 + WARN(1, "Buffer overflow detected!\n");
85734 +}
85735 +EXPORT_SYMBOL(copy_to_user_overflow);
85736 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85737 index 739a363..aa668d7 100644
85738 --- a/lib/vsprintf.c
85739 +++ b/lib/vsprintf.c
85740 @@ -16,6 +16,9 @@
85741 * - scnprintf and vscnprintf
85742 */
85743
85744 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85745 +#define __INCLUDED_BY_HIDESYM 1
85746 +#endif
85747 #include <stdarg.h>
85748 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85749 #include <linux/types.h>
85750 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85751 return number(buf, end, *(const netdev_features_t *)addr, spec);
85752 }
85753
85754 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85755 +int kptr_restrict __read_mostly = 2;
85756 +#else
85757 int kptr_restrict __read_mostly;
85758 +#endif
85759
85760 /*
85761 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85762 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85763 * - 'f' For simple symbolic function names without offset
85764 * - 'S' For symbolic direct pointers with offset
85765 * - 's' For symbolic direct pointers without offset
85766 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85767 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85768 * - 'B' For backtraced symbolic direct pointers with offset
85769 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85770 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85771
85772 if (!ptr && *fmt != 'K') {
85773 /*
85774 - * Print (null) with the same width as a pointer so it makes
85775 + * Print (nil) with the same width as a pointer so it makes
85776 * tabular output look nice.
85777 */
85778 if (spec.field_width == -1)
85779 spec.field_width = default_width;
85780 - return string(buf, end, "(null)", spec);
85781 + return string(buf, end, "(nil)", spec);
85782 }
85783
85784 switch (*fmt) {
85785 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85786 /* Fallthrough */
85787 case 'S':
85788 case 's':
85789 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85790 + break;
85791 +#else
85792 + return symbol_string(buf, end, ptr, spec, fmt);
85793 +#endif
85794 + case 'A':
85795 case 'B':
85796 return symbol_string(buf, end, ptr, spec, fmt);
85797 case 'R':
85798 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85799 va_end(va);
85800 return buf;
85801 }
85802 + case 'P':
85803 + break;
85804 case 'K':
85805 /*
85806 * %pK cannot be used in IRQ context because its test
85807 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85808 return number(buf, end,
85809 (unsigned long long) *((phys_addr_t *)ptr), spec);
85810 }
85811 +
85812 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85813 + /* 'P' = approved pointers to copy to userland,
85814 + as in the /proc/kallsyms case, as we make it display nothing
85815 + for non-root users, and the real contents for root users
85816 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85817 + above
85818 + */
85819 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85820 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85821 + dump_stack();
85822 + ptr = NULL;
85823 + }
85824 +#endif
85825 +
85826 spec.flags |= SMALL;
85827 if (spec.field_width == -1) {
85828 spec.field_width = default_width;
85829 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85830 typeof(type) value; \
85831 if (sizeof(type) == 8) { \
85832 args = PTR_ALIGN(args, sizeof(u32)); \
85833 - *(u32 *)&value = *(u32 *)args; \
85834 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85835 + *(u32 *)&value = *(const u32 *)args; \
85836 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85837 } else { \
85838 args = PTR_ALIGN(args, sizeof(type)); \
85839 - value = *(typeof(type) *)args; \
85840 + value = *(const typeof(type) *)args; \
85841 } \
85842 args += sizeof(type); \
85843 value; \
85844 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85845 case FORMAT_TYPE_STR: {
85846 const char *str_arg = args;
85847 args += strlen(str_arg) + 1;
85848 - str = string(str, end, (char *)str_arg, spec);
85849 + str = string(str, end, str_arg, spec);
85850 break;
85851 }
85852
85853 diff --git a/localversion-grsec b/localversion-grsec
85854 new file mode 100644
85855 index 0000000..7cd6065
85856 --- /dev/null
85857 +++ b/localversion-grsec
85858 @@ -0,0 +1 @@
85859 +-grsec
85860 diff --git a/mm/Kconfig b/mm/Kconfig
85861 index 8028dcc..9a2dbe7 100644
85862 --- a/mm/Kconfig
85863 +++ b/mm/Kconfig
85864 @@ -317,10 +317,10 @@ config KSM
85865 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
85866
85867 config DEFAULT_MMAP_MIN_ADDR
85868 - int "Low address space to protect from user allocation"
85869 + int "Low address space to protect from user allocation"
85870 depends on MMU
85871 - default 4096
85872 - help
85873 + default 65536
85874 + help
85875 This is the portion of low virtual memory which should be protected
85876 from userspace allocation. Keeping a user from writing to low pages
85877 can help reduce the impact of kernel NULL pointer bugs.
85878 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
85879
85880 config HWPOISON_INJECT
85881 tristate "HWPoison pages injector"
85882 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
85883 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
85884 select PROC_PAGE_MONITOR
85885
85886 config NOMMU_INITIAL_TRIM_EXCESS
85887 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
85888 index e04454c..ca5be3e 100644
85889 --- a/mm/backing-dev.c
85890 +++ b/mm/backing-dev.c
85891 @@ -12,7 +12,7 @@
85892 #include <linux/device.h>
85893 #include <trace/events/writeback.h>
85894
85895 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
85896 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
85897
85898 struct backing_dev_info default_backing_dev_info = {
85899 .name = "default",
85900 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
85901 return err;
85902
85903 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
85904 - atomic_long_inc_return(&bdi_seq));
85905 + atomic_long_inc_return_unchecked(&bdi_seq));
85906 if (err) {
85907 bdi_destroy(bdi);
85908 return err;
85909 diff --git a/mm/filemap.c b/mm/filemap.c
85910 index 4b51ac1..5aa90ff 100644
85911 --- a/mm/filemap.c
85912 +++ b/mm/filemap.c
85913 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
85914 struct address_space *mapping = file->f_mapping;
85915
85916 if (!mapping->a_ops->readpage)
85917 - return -ENOEXEC;
85918 + return -ENODEV;
85919 file_accessed(file);
85920 vma->vm_ops = &generic_file_vm_ops;
85921 return 0;
85922 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
85923
85924 while (bytes) {
85925 char __user *buf = iov->iov_base + base;
85926 - int copy = min(bytes, iov->iov_len - base);
85927 + size_t copy = min(bytes, iov->iov_len - base);
85928
85929 base = 0;
85930 left = __copy_from_user_inatomic(vaddr, buf, copy);
85931 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
85932 BUG_ON(!in_atomic());
85933 kaddr = kmap_atomic(page);
85934 if (likely(i->nr_segs == 1)) {
85935 - int left;
85936 + size_t left;
85937 char __user *buf = i->iov->iov_base + i->iov_offset;
85938 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
85939 copied = bytes - left;
85940 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
85941
85942 kaddr = kmap(page);
85943 if (likely(i->nr_segs == 1)) {
85944 - int left;
85945 + size_t left;
85946 char __user *buf = i->iov->iov_base + i->iov_offset;
85947 left = __copy_from_user(kaddr + offset, buf, bytes);
85948 copied = bytes - left;
85949 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
85950 * zero-length segments (without overruning the iovec).
85951 */
85952 while (bytes || unlikely(i->count && !iov->iov_len)) {
85953 - int copy;
85954 + size_t copy;
85955
85956 copy = min(bytes, iov->iov_len - base);
85957 BUG_ON(!i->count || i->count < copy);
85958 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
85959 *pos = i_size_read(inode);
85960
85961 if (limit != RLIM_INFINITY) {
85962 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
85963 if (*pos >= limit) {
85964 send_sig(SIGXFSZ, current, 0);
85965 return -EFBIG;
85966 diff --git a/mm/fremap.c b/mm/fremap.c
85967 index 5bff081..d8189a9 100644
85968 --- a/mm/fremap.c
85969 +++ b/mm/fremap.c
85970 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
85971 retry:
85972 vma = find_vma(mm, start);
85973
85974 +#ifdef CONFIG_PAX_SEGMEXEC
85975 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
85976 + goto out;
85977 +#endif
85978 +
85979 /*
85980 * Make sure the vma is shared, that it supports prefaulting,
85981 * and that the remapped range is valid and fully within
85982 diff --git a/mm/highmem.c b/mm/highmem.c
85983 index b32b70c..e512eb0 100644
85984 --- a/mm/highmem.c
85985 +++ b/mm/highmem.c
85986 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
85987 * So no dangers, even with speculative execution.
85988 */
85989 page = pte_page(pkmap_page_table[i]);
85990 + pax_open_kernel();
85991 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
85992 -
85993 + pax_close_kernel();
85994 set_page_address(page, NULL);
85995 need_flush = 1;
85996 }
85997 @@ -198,9 +199,11 @@ start:
85998 }
85999 }
86000 vaddr = PKMAP_ADDR(last_pkmap_nr);
86001 +
86002 + pax_open_kernel();
86003 set_pte_at(&init_mm, vaddr,
86004 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
86005 -
86006 + pax_close_kernel();
86007 pkmap_count[last_pkmap_nr] = 1;
86008 set_page_address(page, (void *)vaddr);
86009
86010 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
86011 index b60f330..ee7de7e 100644
86012 --- a/mm/hugetlb.c
86013 +++ b/mm/hugetlb.c
86014 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
86015 struct hstate *h = &default_hstate;
86016 unsigned long tmp;
86017 int ret;
86018 + ctl_table_no_const hugetlb_table;
86019
86020 tmp = h->max_huge_pages;
86021
86022 if (write && h->order >= MAX_ORDER)
86023 return -EINVAL;
86024
86025 - table->data = &tmp;
86026 - table->maxlen = sizeof(unsigned long);
86027 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86028 + hugetlb_table = *table;
86029 + hugetlb_table.data = &tmp;
86030 + hugetlb_table.maxlen = sizeof(unsigned long);
86031 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86032 if (ret)
86033 goto out;
86034
86035 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
86036 struct hstate *h = &default_hstate;
86037 unsigned long tmp;
86038 int ret;
86039 + ctl_table_no_const hugetlb_table;
86040
86041 tmp = h->nr_overcommit_huge_pages;
86042
86043 if (write && h->order >= MAX_ORDER)
86044 return -EINVAL;
86045
86046 - table->data = &tmp;
86047 - table->maxlen = sizeof(unsigned long);
86048 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86049 + hugetlb_table = *table;
86050 + hugetlb_table.data = &tmp;
86051 + hugetlb_table.maxlen = sizeof(unsigned long);
86052 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86053 if (ret)
86054 goto out;
86055
86056 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
86057 return 1;
86058 }
86059
86060 +#ifdef CONFIG_PAX_SEGMEXEC
86061 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
86062 +{
86063 + struct mm_struct *mm = vma->vm_mm;
86064 + struct vm_area_struct *vma_m;
86065 + unsigned long address_m;
86066 + pte_t *ptep_m;
86067 +
86068 + vma_m = pax_find_mirror_vma(vma);
86069 + if (!vma_m)
86070 + return;
86071 +
86072 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86073 + address_m = address + SEGMEXEC_TASK_SIZE;
86074 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
86075 + get_page(page_m);
86076 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
86077 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
86078 +}
86079 +#endif
86080 +
86081 /*
86082 * Hugetlb_cow() should be called with page lock of the original hugepage held.
86083 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
86084 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
86085 make_huge_pte(vma, new_page, 1));
86086 page_remove_rmap(old_page);
86087 hugepage_add_new_anon_rmap(new_page, vma, address);
86088 +
86089 +#ifdef CONFIG_PAX_SEGMEXEC
86090 + pax_mirror_huge_pte(vma, address, new_page);
86091 +#endif
86092 +
86093 /* Make the old page be freed below */
86094 new_page = old_page;
86095 }
86096 @@ -2821,6 +2851,10 @@ retry:
86097 && (vma->vm_flags & VM_SHARED)));
86098 set_huge_pte_at(mm, address, ptep, new_pte);
86099
86100 +#ifdef CONFIG_PAX_SEGMEXEC
86101 + pax_mirror_huge_pte(vma, address, page);
86102 +#endif
86103 +
86104 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
86105 /* Optimization, do the COW without a second fault */
86106 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
86107 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86108 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
86109 struct hstate *h = hstate_vma(vma);
86110
86111 +#ifdef CONFIG_PAX_SEGMEXEC
86112 + struct vm_area_struct *vma_m;
86113 +#endif
86114 +
86115 address &= huge_page_mask(h);
86116
86117 ptep = huge_pte_offset(mm, address);
86118 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86119 VM_FAULT_SET_HINDEX(hstate_index(h));
86120 }
86121
86122 +#ifdef CONFIG_PAX_SEGMEXEC
86123 + vma_m = pax_find_mirror_vma(vma);
86124 + if (vma_m) {
86125 + unsigned long address_m;
86126 +
86127 + if (vma->vm_start > vma_m->vm_start) {
86128 + address_m = address;
86129 + address -= SEGMEXEC_TASK_SIZE;
86130 + vma = vma_m;
86131 + h = hstate_vma(vma);
86132 + } else
86133 + address_m = address + SEGMEXEC_TASK_SIZE;
86134 +
86135 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
86136 + return VM_FAULT_OOM;
86137 + address_m &= HPAGE_MASK;
86138 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
86139 + }
86140 +#endif
86141 +
86142 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
86143 if (!ptep)
86144 return VM_FAULT_OOM;
86145 diff --git a/mm/internal.h b/mm/internal.h
86146 index 4390ac6..fc60373c 100644
86147 --- a/mm/internal.h
86148 +++ b/mm/internal.h
86149 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
86150 * in mm/page_alloc.c
86151 */
86152 extern void __free_pages_bootmem(struct page *page, unsigned int order);
86153 +extern void free_compound_page(struct page *page);
86154 extern void prep_compound_page(struct page *page, unsigned long order);
86155 #ifdef CONFIG_MEMORY_FAILURE
86156 extern bool is_free_buddy_page(struct page *page);
86157 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
86158
86159 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
86160 unsigned long, unsigned long,
86161 - unsigned long, unsigned long);
86162 + unsigned long, unsigned long) __intentional_overflow(-1);
86163
86164 extern void set_pageblock_order(void);
86165 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
86166 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
86167 index c8d7f31..2dbeffd 100644
86168 --- a/mm/kmemleak.c
86169 +++ b/mm/kmemleak.c
86170 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
86171
86172 for (i = 0; i < object->trace_len; i++) {
86173 void *ptr = (void *)object->trace[i];
86174 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
86175 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
86176 }
86177 }
86178
86179 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
86180 return -ENOMEM;
86181 }
86182
86183 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
86184 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
86185 &kmemleak_fops);
86186 if (!dentry)
86187 pr_warning("Failed to create the debugfs kmemleak file\n");
86188 diff --git a/mm/maccess.c b/mm/maccess.c
86189 index d53adf9..03a24bf 100644
86190 --- a/mm/maccess.c
86191 +++ b/mm/maccess.c
86192 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
86193 set_fs(KERNEL_DS);
86194 pagefault_disable();
86195 ret = __copy_from_user_inatomic(dst,
86196 - (__force const void __user *)src, size);
86197 + (const void __force_user *)src, size);
86198 pagefault_enable();
86199 set_fs(old_fs);
86200
86201 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
86202
86203 set_fs(KERNEL_DS);
86204 pagefault_disable();
86205 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
86206 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
86207 pagefault_enable();
86208 set_fs(old_fs);
86209
86210 diff --git a/mm/madvise.c b/mm/madvise.c
86211 index 7055883..aafb1ed 100644
86212 --- a/mm/madvise.c
86213 +++ b/mm/madvise.c
86214 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86215 pgoff_t pgoff;
86216 unsigned long new_flags = vma->vm_flags;
86217
86218 +#ifdef CONFIG_PAX_SEGMEXEC
86219 + struct vm_area_struct *vma_m;
86220 +#endif
86221 +
86222 switch (behavior) {
86223 case MADV_NORMAL:
86224 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86225 @@ -126,6 +130,13 @@ success:
86226 /*
86227 * vm_flags is protected by the mmap_sem held in write mode.
86228 */
86229 +
86230 +#ifdef CONFIG_PAX_SEGMEXEC
86231 + vma_m = pax_find_mirror_vma(vma);
86232 + if (vma_m)
86233 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86234 +#endif
86235 +
86236 vma->vm_flags = new_flags;
86237
86238 out:
86239 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86240 struct vm_area_struct ** prev,
86241 unsigned long start, unsigned long end)
86242 {
86243 +
86244 +#ifdef CONFIG_PAX_SEGMEXEC
86245 + struct vm_area_struct *vma_m;
86246 +#endif
86247 +
86248 *prev = vma;
86249 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86250 return -EINVAL;
86251 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86252 zap_page_range(vma, start, end - start, &details);
86253 } else
86254 zap_page_range(vma, start, end - start, NULL);
86255 +
86256 +#ifdef CONFIG_PAX_SEGMEXEC
86257 + vma_m = pax_find_mirror_vma(vma);
86258 + if (vma_m) {
86259 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86260 + struct zap_details details = {
86261 + .nonlinear_vma = vma_m,
86262 + .last_index = ULONG_MAX,
86263 + };
86264 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86265 + } else
86266 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86267 + }
86268 +#endif
86269 +
86270 return 0;
86271 }
86272
86273 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86274 if (end < start)
86275 return error;
86276
86277 +#ifdef CONFIG_PAX_SEGMEXEC
86278 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86279 + if (end > SEGMEXEC_TASK_SIZE)
86280 + return error;
86281 + } else
86282 +#endif
86283 +
86284 + if (end > TASK_SIZE)
86285 + return error;
86286 +
86287 error = 0;
86288 if (end == start)
86289 return error;
86290 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86291 index 2c13aa7..64cbc3f 100644
86292 --- a/mm/memory-failure.c
86293 +++ b/mm/memory-failure.c
86294 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86295
86296 int sysctl_memory_failure_recovery __read_mostly = 1;
86297
86298 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86299 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86300
86301 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86302
86303 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86304 pfn, t->comm, t->pid);
86305 si.si_signo = SIGBUS;
86306 si.si_errno = 0;
86307 - si.si_addr = (void *)addr;
86308 + si.si_addr = (void __user *)addr;
86309 #ifdef __ARCH_SI_TRAPNO
86310 si.si_trapno = trapno;
86311 #endif
86312 @@ -760,7 +760,7 @@ static struct page_state {
86313 unsigned long res;
86314 char *msg;
86315 int (*action)(struct page *p, unsigned long pfn);
86316 -} error_states[] = {
86317 +} __do_const error_states[] = {
86318 { reserved, reserved, "reserved kernel", me_kernel },
86319 /*
86320 * free pages are specially detected outside this table:
86321 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86322 nr_pages = 1 << compound_order(hpage);
86323 else /* normal page or thp */
86324 nr_pages = 1;
86325 - atomic_long_add(nr_pages, &num_poisoned_pages);
86326 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86327
86328 /*
86329 * We need/can do nothing about count=0 pages.
86330 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86331 if (!PageHWPoison(hpage)
86332 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86333 || (p != hpage && TestSetPageHWPoison(hpage))) {
86334 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86335 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86336 return 0;
86337 }
86338 set_page_hwpoison_huge_page(hpage);
86339 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86340 }
86341 if (hwpoison_filter(p)) {
86342 if (TestClearPageHWPoison(p))
86343 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86344 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86345 unlock_page(hpage);
86346 put_page(hpage);
86347 return 0;
86348 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86349 return 0;
86350 }
86351 if (TestClearPageHWPoison(p))
86352 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86353 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86354 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86355 return 0;
86356 }
86357 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86358 */
86359 if (TestClearPageHWPoison(page)) {
86360 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86361 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86362 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86363 freeit = 1;
86364 if (PageHuge(page))
86365 clear_page_hwpoison_huge_page(page);
86366 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86367 } else {
86368 set_page_hwpoison_huge_page(hpage);
86369 dequeue_hwpoisoned_huge_page(hpage);
86370 - atomic_long_add(1 << compound_trans_order(hpage),
86371 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86372 &num_poisoned_pages);
86373 }
86374 return ret;
86375 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86376 if (PageHuge(page)) {
86377 set_page_hwpoison_huge_page(hpage);
86378 dequeue_hwpoisoned_huge_page(hpage);
86379 - atomic_long_add(1 << compound_trans_order(hpage),
86380 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86381 &num_poisoned_pages);
86382 } else {
86383 SetPageHWPoison(page);
86384 - atomic_long_inc(&num_poisoned_pages);
86385 + atomic_long_inc_unchecked(&num_poisoned_pages);
86386 }
86387 }
86388 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86389 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86390 put_page(page);
86391 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86392 SetPageHWPoison(page);
86393 - atomic_long_inc(&num_poisoned_pages);
86394 + atomic_long_inc_unchecked(&num_poisoned_pages);
86395 return 0;
86396 }
86397
86398 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86399 if (!is_free_buddy_page(page))
86400 pr_info("soft offline: %#lx: page leaked\n",
86401 pfn);
86402 - atomic_long_inc(&num_poisoned_pages);
86403 + atomic_long_inc_unchecked(&num_poisoned_pages);
86404 }
86405 } else {
86406 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86407 diff --git a/mm/memory.c b/mm/memory.c
86408 index af84bc0..2ed0816 100644
86409 --- a/mm/memory.c
86410 +++ b/mm/memory.c
86411 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86412 free_pte_range(tlb, pmd, addr);
86413 } while (pmd++, addr = next, addr != end);
86414
86415 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86416 start &= PUD_MASK;
86417 if (start < floor)
86418 return;
86419 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86420 pmd = pmd_offset(pud, start);
86421 pud_clear(pud);
86422 pmd_free_tlb(tlb, pmd, start);
86423 +#endif
86424 +
86425 }
86426
86427 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86428 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86429 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86430 } while (pud++, addr = next, addr != end);
86431
86432 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86433 start &= PGDIR_MASK;
86434 if (start < floor)
86435 return;
86436 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86437 pud = pud_offset(pgd, start);
86438 pgd_clear(pgd);
86439 pud_free_tlb(tlb, pud, start);
86440 +#endif
86441 +
86442 }
86443
86444 /*
86445 @@ -1645,12 +1651,6 @@ no_page_table:
86446 return page;
86447 }
86448
86449 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86450 -{
86451 - return stack_guard_page_start(vma, addr) ||
86452 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86453 -}
86454 -
86455 /**
86456 * __get_user_pages() - pin user pages in memory
86457 * @tsk: task_struct of target task
86458 @@ -1737,10 +1737,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86459
86460 i = 0;
86461
86462 - do {
86463 + while (nr_pages) {
86464 struct vm_area_struct *vma;
86465
86466 - vma = find_extend_vma(mm, start);
86467 + vma = find_vma(mm, start);
86468 if (!vma && in_gate_area(mm, start)) {
86469 unsigned long pg = start & PAGE_MASK;
86470 pgd_t *pgd;
86471 @@ -1789,7 +1789,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86472 goto next_page;
86473 }
86474
86475 - if (!vma ||
86476 + if (!vma || start < vma->vm_start ||
86477 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86478 !(vm_flags & vma->vm_flags))
86479 return i ? : -EFAULT;
86480 @@ -1818,11 +1818,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86481 int ret;
86482 unsigned int fault_flags = 0;
86483
86484 - /* For mlock, just skip the stack guard page. */
86485 - if (foll_flags & FOLL_MLOCK) {
86486 - if (stack_guard_page(vma, start))
86487 - goto next_page;
86488 - }
86489 if (foll_flags & FOLL_WRITE)
86490 fault_flags |= FAULT_FLAG_WRITE;
86491 if (nonblocking)
86492 @@ -1902,7 +1897,7 @@ next_page:
86493 start += page_increm * PAGE_SIZE;
86494 nr_pages -= page_increm;
86495 } while (nr_pages && start < vma->vm_end);
86496 - } while (nr_pages);
86497 + }
86498 return i;
86499 }
86500 EXPORT_SYMBOL(__get_user_pages);
86501 @@ -2109,6 +2104,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86502 page_add_file_rmap(page);
86503 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86504
86505 +#ifdef CONFIG_PAX_SEGMEXEC
86506 + pax_mirror_file_pte(vma, addr, page, ptl);
86507 +#endif
86508 +
86509 retval = 0;
86510 pte_unmap_unlock(pte, ptl);
86511 return retval;
86512 @@ -2153,9 +2152,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86513 if (!page_count(page))
86514 return -EINVAL;
86515 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86516 +
86517 +#ifdef CONFIG_PAX_SEGMEXEC
86518 + struct vm_area_struct *vma_m;
86519 +#endif
86520 +
86521 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86522 BUG_ON(vma->vm_flags & VM_PFNMAP);
86523 vma->vm_flags |= VM_MIXEDMAP;
86524 +
86525 +#ifdef CONFIG_PAX_SEGMEXEC
86526 + vma_m = pax_find_mirror_vma(vma);
86527 + if (vma_m)
86528 + vma_m->vm_flags |= VM_MIXEDMAP;
86529 +#endif
86530 +
86531 }
86532 return insert_page(vma, addr, page, vma->vm_page_prot);
86533 }
86534 @@ -2238,6 +2249,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86535 unsigned long pfn)
86536 {
86537 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86538 + BUG_ON(vma->vm_mirror);
86539
86540 if (addr < vma->vm_start || addr >= vma->vm_end)
86541 return -EFAULT;
86542 @@ -2485,7 +2497,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86543
86544 BUG_ON(pud_huge(*pud));
86545
86546 - pmd = pmd_alloc(mm, pud, addr);
86547 + pmd = (mm == &init_mm) ?
86548 + pmd_alloc_kernel(mm, pud, addr) :
86549 + pmd_alloc(mm, pud, addr);
86550 if (!pmd)
86551 return -ENOMEM;
86552 do {
86553 @@ -2505,7 +2519,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86554 unsigned long next;
86555 int err;
86556
86557 - pud = pud_alloc(mm, pgd, addr);
86558 + pud = (mm == &init_mm) ?
86559 + pud_alloc_kernel(mm, pgd, addr) :
86560 + pud_alloc(mm, pgd, addr);
86561 if (!pud)
86562 return -ENOMEM;
86563 do {
86564 @@ -2593,6 +2609,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86565 copy_user_highpage(dst, src, va, vma);
86566 }
86567
86568 +#ifdef CONFIG_PAX_SEGMEXEC
86569 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86570 +{
86571 + struct mm_struct *mm = vma->vm_mm;
86572 + spinlock_t *ptl;
86573 + pte_t *pte, entry;
86574 +
86575 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86576 + entry = *pte;
86577 + if (!pte_present(entry)) {
86578 + if (!pte_none(entry)) {
86579 + BUG_ON(pte_file(entry));
86580 + free_swap_and_cache(pte_to_swp_entry(entry));
86581 + pte_clear_not_present_full(mm, address, pte, 0);
86582 + }
86583 + } else {
86584 + struct page *page;
86585 +
86586 + flush_cache_page(vma, address, pte_pfn(entry));
86587 + entry = ptep_clear_flush(vma, address, pte);
86588 + BUG_ON(pte_dirty(entry));
86589 + page = vm_normal_page(vma, address, entry);
86590 + if (page) {
86591 + update_hiwater_rss(mm);
86592 + if (PageAnon(page))
86593 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86594 + else
86595 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86596 + page_remove_rmap(page);
86597 + page_cache_release(page);
86598 + }
86599 + }
86600 + pte_unmap_unlock(pte, ptl);
86601 +}
86602 +
86603 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86604 + *
86605 + * the ptl of the lower mapped page is held on entry and is not released on exit
86606 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86607 + */
86608 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86609 +{
86610 + struct mm_struct *mm = vma->vm_mm;
86611 + unsigned long address_m;
86612 + spinlock_t *ptl_m;
86613 + struct vm_area_struct *vma_m;
86614 + pmd_t *pmd_m;
86615 + pte_t *pte_m, entry_m;
86616 +
86617 + BUG_ON(!page_m || !PageAnon(page_m));
86618 +
86619 + vma_m = pax_find_mirror_vma(vma);
86620 + if (!vma_m)
86621 + return;
86622 +
86623 + BUG_ON(!PageLocked(page_m));
86624 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86625 + address_m = address + SEGMEXEC_TASK_SIZE;
86626 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86627 + pte_m = pte_offset_map(pmd_m, address_m);
86628 + ptl_m = pte_lockptr(mm, pmd_m);
86629 + if (ptl != ptl_m) {
86630 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86631 + if (!pte_none(*pte_m))
86632 + goto out;
86633 + }
86634 +
86635 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86636 + page_cache_get(page_m);
86637 + page_add_anon_rmap(page_m, vma_m, address_m);
86638 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86639 + set_pte_at(mm, address_m, pte_m, entry_m);
86640 + update_mmu_cache(vma_m, address_m, pte_m);
86641 +out:
86642 + if (ptl != ptl_m)
86643 + spin_unlock(ptl_m);
86644 + pte_unmap(pte_m);
86645 + unlock_page(page_m);
86646 +}
86647 +
86648 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86649 +{
86650 + struct mm_struct *mm = vma->vm_mm;
86651 + unsigned long address_m;
86652 + spinlock_t *ptl_m;
86653 + struct vm_area_struct *vma_m;
86654 + pmd_t *pmd_m;
86655 + pte_t *pte_m, entry_m;
86656 +
86657 + BUG_ON(!page_m || PageAnon(page_m));
86658 +
86659 + vma_m = pax_find_mirror_vma(vma);
86660 + if (!vma_m)
86661 + return;
86662 +
86663 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86664 + address_m = address + SEGMEXEC_TASK_SIZE;
86665 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86666 + pte_m = pte_offset_map(pmd_m, address_m);
86667 + ptl_m = pte_lockptr(mm, pmd_m);
86668 + if (ptl != ptl_m) {
86669 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86670 + if (!pte_none(*pte_m))
86671 + goto out;
86672 + }
86673 +
86674 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86675 + page_cache_get(page_m);
86676 + page_add_file_rmap(page_m);
86677 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86678 + set_pte_at(mm, address_m, pte_m, entry_m);
86679 + update_mmu_cache(vma_m, address_m, pte_m);
86680 +out:
86681 + if (ptl != ptl_m)
86682 + spin_unlock(ptl_m);
86683 + pte_unmap(pte_m);
86684 +}
86685 +
86686 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86687 +{
86688 + struct mm_struct *mm = vma->vm_mm;
86689 + unsigned long address_m;
86690 + spinlock_t *ptl_m;
86691 + struct vm_area_struct *vma_m;
86692 + pmd_t *pmd_m;
86693 + pte_t *pte_m, entry_m;
86694 +
86695 + vma_m = pax_find_mirror_vma(vma);
86696 + if (!vma_m)
86697 + return;
86698 +
86699 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86700 + address_m = address + SEGMEXEC_TASK_SIZE;
86701 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86702 + pte_m = pte_offset_map(pmd_m, address_m);
86703 + ptl_m = pte_lockptr(mm, pmd_m);
86704 + if (ptl != ptl_m) {
86705 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86706 + if (!pte_none(*pte_m))
86707 + goto out;
86708 + }
86709 +
86710 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86711 + set_pte_at(mm, address_m, pte_m, entry_m);
86712 +out:
86713 + if (ptl != ptl_m)
86714 + spin_unlock(ptl_m);
86715 + pte_unmap(pte_m);
86716 +}
86717 +
86718 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86719 +{
86720 + struct page *page_m;
86721 + pte_t entry;
86722 +
86723 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86724 + goto out;
86725 +
86726 + entry = *pte;
86727 + page_m = vm_normal_page(vma, address, entry);
86728 + if (!page_m)
86729 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86730 + else if (PageAnon(page_m)) {
86731 + if (pax_find_mirror_vma(vma)) {
86732 + pte_unmap_unlock(pte, ptl);
86733 + lock_page(page_m);
86734 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86735 + if (pte_same(entry, *pte))
86736 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86737 + else
86738 + unlock_page(page_m);
86739 + }
86740 + } else
86741 + pax_mirror_file_pte(vma, address, page_m, ptl);
86742 +
86743 +out:
86744 + pte_unmap_unlock(pte, ptl);
86745 +}
86746 +#endif
86747 +
86748 /*
86749 * This routine handles present pages, when users try to write
86750 * to a shared page. It is done by copying the page to a new address
86751 @@ -2809,6 +3005,12 @@ gotten:
86752 */
86753 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86754 if (likely(pte_same(*page_table, orig_pte))) {
86755 +
86756 +#ifdef CONFIG_PAX_SEGMEXEC
86757 + if (pax_find_mirror_vma(vma))
86758 + BUG_ON(!trylock_page(new_page));
86759 +#endif
86760 +
86761 if (old_page) {
86762 if (!PageAnon(old_page)) {
86763 dec_mm_counter_fast(mm, MM_FILEPAGES);
86764 @@ -2860,6 +3062,10 @@ gotten:
86765 page_remove_rmap(old_page);
86766 }
86767
86768 +#ifdef CONFIG_PAX_SEGMEXEC
86769 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86770 +#endif
86771 +
86772 /* Free the old page.. */
86773 new_page = old_page;
86774 ret |= VM_FAULT_WRITE;
86775 @@ -3137,6 +3343,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86776 swap_free(entry);
86777 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86778 try_to_free_swap(page);
86779 +
86780 +#ifdef CONFIG_PAX_SEGMEXEC
86781 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86782 +#endif
86783 +
86784 unlock_page(page);
86785 if (page != swapcache) {
86786 /*
86787 @@ -3160,6 +3371,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86788
86789 /* No need to invalidate - it was non-present before */
86790 update_mmu_cache(vma, address, page_table);
86791 +
86792 +#ifdef CONFIG_PAX_SEGMEXEC
86793 + pax_mirror_anon_pte(vma, address, page, ptl);
86794 +#endif
86795 +
86796 unlock:
86797 pte_unmap_unlock(page_table, ptl);
86798 out:
86799 @@ -3179,40 +3395,6 @@ out_release:
86800 }
86801
86802 /*
86803 - * This is like a special single-page "expand_{down|up}wards()",
86804 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86805 - * doesn't hit another vma.
86806 - */
86807 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86808 -{
86809 - address &= PAGE_MASK;
86810 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86811 - struct vm_area_struct *prev = vma->vm_prev;
86812 -
86813 - /*
86814 - * Is there a mapping abutting this one below?
86815 - *
86816 - * That's only ok if it's the same stack mapping
86817 - * that has gotten split..
86818 - */
86819 - if (prev && prev->vm_end == address)
86820 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86821 -
86822 - expand_downwards(vma, address - PAGE_SIZE);
86823 - }
86824 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86825 - struct vm_area_struct *next = vma->vm_next;
86826 -
86827 - /* As VM_GROWSDOWN but s/below/above/ */
86828 - if (next && next->vm_start == address + PAGE_SIZE)
86829 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86830 -
86831 - expand_upwards(vma, address + PAGE_SIZE);
86832 - }
86833 - return 0;
86834 -}
86835 -
86836 -/*
86837 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86838 * but allow concurrent faults), and pte mapped but not yet locked.
86839 * We return with mmap_sem still held, but pte unmapped and unlocked.
86840 @@ -3221,27 +3403,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86841 unsigned long address, pte_t *page_table, pmd_t *pmd,
86842 unsigned int flags)
86843 {
86844 - struct page *page;
86845 + struct page *page = NULL;
86846 spinlock_t *ptl;
86847 pte_t entry;
86848
86849 - pte_unmap(page_table);
86850 -
86851 - /* Check if we need to add a guard page to the stack */
86852 - if (check_stack_guard_page(vma, address) < 0)
86853 - return VM_FAULT_SIGBUS;
86854 -
86855 - /* Use the zero-page for reads */
86856 if (!(flags & FAULT_FLAG_WRITE)) {
86857 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
86858 vma->vm_page_prot));
86859 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86860 + ptl = pte_lockptr(mm, pmd);
86861 + spin_lock(ptl);
86862 if (!pte_none(*page_table))
86863 goto unlock;
86864 goto setpte;
86865 }
86866
86867 /* Allocate our own private page. */
86868 + pte_unmap(page_table);
86869 +
86870 if (unlikely(anon_vma_prepare(vma)))
86871 goto oom;
86872 page = alloc_zeroed_user_highpage_movable(vma, address);
86873 @@ -3265,6 +3443,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86874 if (!pte_none(*page_table))
86875 goto release;
86876
86877 +#ifdef CONFIG_PAX_SEGMEXEC
86878 + if (pax_find_mirror_vma(vma))
86879 + BUG_ON(!trylock_page(page));
86880 +#endif
86881 +
86882 inc_mm_counter_fast(mm, MM_ANONPAGES);
86883 page_add_new_anon_rmap(page, vma, address);
86884 setpte:
86885 @@ -3272,6 +3455,12 @@ setpte:
86886
86887 /* No need to invalidate - it was non-present before */
86888 update_mmu_cache(vma, address, page_table);
86889 +
86890 +#ifdef CONFIG_PAX_SEGMEXEC
86891 + if (page)
86892 + pax_mirror_anon_pte(vma, address, page, ptl);
86893 +#endif
86894 +
86895 unlock:
86896 pte_unmap_unlock(page_table, ptl);
86897 return 0;
86898 @@ -3415,6 +3604,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86899 */
86900 /* Only go through if we didn't race with anybody else... */
86901 if (likely(pte_same(*page_table, orig_pte))) {
86902 +
86903 +#ifdef CONFIG_PAX_SEGMEXEC
86904 + if (anon && pax_find_mirror_vma(vma))
86905 + BUG_ON(!trylock_page(page));
86906 +#endif
86907 +
86908 flush_icache_page(vma, page);
86909 entry = mk_pte(page, vma->vm_page_prot);
86910 if (flags & FAULT_FLAG_WRITE)
86911 @@ -3436,6 +3631,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86912
86913 /* no need to invalidate: a not-present page won't be cached */
86914 update_mmu_cache(vma, address, page_table);
86915 +
86916 +#ifdef CONFIG_PAX_SEGMEXEC
86917 + if (anon)
86918 + pax_mirror_anon_pte(vma, address, page, ptl);
86919 + else
86920 + pax_mirror_file_pte(vma, address, page, ptl);
86921 +#endif
86922 +
86923 } else {
86924 if (cow_page)
86925 mem_cgroup_uncharge_page(cow_page);
86926 @@ -3757,6 +3960,12 @@ int handle_pte_fault(struct mm_struct *mm,
86927 if (flags & FAULT_FLAG_WRITE)
86928 flush_tlb_fix_spurious_fault(vma, address);
86929 }
86930 +
86931 +#ifdef CONFIG_PAX_SEGMEXEC
86932 + pax_mirror_pte(vma, address, pte, pmd, ptl);
86933 + return 0;
86934 +#endif
86935 +
86936 unlock:
86937 pte_unmap_unlock(pte, ptl);
86938 return 0;
86939 @@ -3773,6 +3982,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86940 pmd_t *pmd;
86941 pte_t *pte;
86942
86943 +#ifdef CONFIG_PAX_SEGMEXEC
86944 + struct vm_area_struct *vma_m;
86945 +#endif
86946 +
86947 __set_current_state(TASK_RUNNING);
86948
86949 count_vm_event(PGFAULT);
86950 @@ -3784,6 +3997,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86951 if (unlikely(is_vm_hugetlb_page(vma)))
86952 return hugetlb_fault(mm, vma, address, flags);
86953
86954 +#ifdef CONFIG_PAX_SEGMEXEC
86955 + vma_m = pax_find_mirror_vma(vma);
86956 + if (vma_m) {
86957 + unsigned long address_m;
86958 + pgd_t *pgd_m;
86959 + pud_t *pud_m;
86960 + pmd_t *pmd_m;
86961 +
86962 + if (vma->vm_start > vma_m->vm_start) {
86963 + address_m = address;
86964 + address -= SEGMEXEC_TASK_SIZE;
86965 + vma = vma_m;
86966 + } else
86967 + address_m = address + SEGMEXEC_TASK_SIZE;
86968 +
86969 + pgd_m = pgd_offset(mm, address_m);
86970 + pud_m = pud_alloc(mm, pgd_m, address_m);
86971 + if (!pud_m)
86972 + return VM_FAULT_OOM;
86973 + pmd_m = pmd_alloc(mm, pud_m, address_m);
86974 + if (!pmd_m)
86975 + return VM_FAULT_OOM;
86976 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
86977 + return VM_FAULT_OOM;
86978 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
86979 + }
86980 +#endif
86981 +
86982 retry:
86983 pgd = pgd_offset(mm, address);
86984 pud = pud_alloc(mm, pgd, address);
86985 @@ -3882,6 +4123,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
86986 spin_unlock(&mm->page_table_lock);
86987 return 0;
86988 }
86989 +
86990 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
86991 +{
86992 + pud_t *new = pud_alloc_one(mm, address);
86993 + if (!new)
86994 + return -ENOMEM;
86995 +
86996 + smp_wmb(); /* See comment in __pte_alloc */
86997 +
86998 + spin_lock(&mm->page_table_lock);
86999 + if (pgd_present(*pgd)) /* Another has populated it */
87000 + pud_free(mm, new);
87001 + else
87002 + pgd_populate_kernel(mm, pgd, new);
87003 + spin_unlock(&mm->page_table_lock);
87004 + return 0;
87005 +}
87006 #endif /* __PAGETABLE_PUD_FOLDED */
87007
87008 #ifndef __PAGETABLE_PMD_FOLDED
87009 @@ -3912,6 +4170,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
87010 spin_unlock(&mm->page_table_lock);
87011 return 0;
87012 }
87013 +
87014 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
87015 +{
87016 + pmd_t *new = pmd_alloc_one(mm, address);
87017 + if (!new)
87018 + return -ENOMEM;
87019 +
87020 + smp_wmb(); /* See comment in __pte_alloc */
87021 +
87022 + spin_lock(&mm->page_table_lock);
87023 +#ifndef __ARCH_HAS_4LEVEL_HACK
87024 + if (pud_present(*pud)) /* Another has populated it */
87025 + pmd_free(mm, new);
87026 + else
87027 + pud_populate_kernel(mm, pud, new);
87028 +#else
87029 + if (pgd_present(*pud)) /* Another has populated it */
87030 + pmd_free(mm, new);
87031 + else
87032 + pgd_populate_kernel(mm, pud, new);
87033 +#endif /* __ARCH_HAS_4LEVEL_HACK */
87034 + spin_unlock(&mm->page_table_lock);
87035 + return 0;
87036 +}
87037 #endif /* __PAGETABLE_PMD_FOLDED */
87038
87039 #if !defined(__HAVE_ARCH_GATE_AREA)
87040 @@ -3925,7 +4207,7 @@ static int __init gate_vma_init(void)
87041 gate_vma.vm_start = FIXADDR_USER_START;
87042 gate_vma.vm_end = FIXADDR_USER_END;
87043 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
87044 - gate_vma.vm_page_prot = __P101;
87045 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
87046
87047 return 0;
87048 }
87049 @@ -4059,8 +4341,8 @@ out:
87050 return ret;
87051 }
87052
87053 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87054 - void *buf, int len, int write)
87055 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87056 + void *buf, size_t len, int write)
87057 {
87058 resource_size_t phys_addr;
87059 unsigned long prot = 0;
87060 @@ -4085,8 +4367,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87061 * Access another process' address space as given in mm. If non-NULL, use the
87062 * given task for page fault accounting.
87063 */
87064 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87065 - unsigned long addr, void *buf, int len, int write)
87066 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87067 + unsigned long addr, void *buf, size_t len, int write)
87068 {
87069 struct vm_area_struct *vma;
87070 void *old_buf = buf;
87071 @@ -4094,7 +4376,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87072 down_read(&mm->mmap_sem);
87073 /* ignore errors, just check how much was successfully transferred */
87074 while (len) {
87075 - int bytes, ret, offset;
87076 + ssize_t bytes, ret, offset;
87077 void *maddr;
87078 struct page *page = NULL;
87079
87080 @@ -4153,8 +4435,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87081 *
87082 * The caller must hold a reference on @mm.
87083 */
87084 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87085 - void *buf, int len, int write)
87086 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87087 + void *buf, size_t len, int write)
87088 {
87089 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87090 }
87091 @@ -4164,11 +4446,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87092 * Source/target buffer must be kernel space,
87093 * Do not walk the page table directly, use get_user_pages
87094 */
87095 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
87096 - void *buf, int len, int write)
87097 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
87098 + void *buf, size_t len, int write)
87099 {
87100 struct mm_struct *mm;
87101 - int ret;
87102 + ssize_t ret;
87103
87104 mm = get_task_mm(tsk);
87105 if (!mm)
87106 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
87107 index 4baf12e..5497066 100644
87108 --- a/mm/mempolicy.c
87109 +++ b/mm/mempolicy.c
87110 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87111 unsigned long vmstart;
87112 unsigned long vmend;
87113
87114 +#ifdef CONFIG_PAX_SEGMEXEC
87115 + struct vm_area_struct *vma_m;
87116 +#endif
87117 +
87118 vma = find_vma(mm, start);
87119 if (!vma || vma->vm_start > start)
87120 return -EFAULT;
87121 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87122 err = vma_replace_policy(vma, new_pol);
87123 if (err)
87124 goto out;
87125 +
87126 +#ifdef CONFIG_PAX_SEGMEXEC
87127 + vma_m = pax_find_mirror_vma(vma);
87128 + if (vma_m) {
87129 + err = vma_replace_policy(vma_m, new_pol);
87130 + if (err)
87131 + goto out;
87132 + }
87133 +#endif
87134 +
87135 }
87136
87137 out:
87138 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
87139
87140 if (end < start)
87141 return -EINVAL;
87142 +
87143 +#ifdef CONFIG_PAX_SEGMEXEC
87144 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87145 + if (end > SEGMEXEC_TASK_SIZE)
87146 + return -EINVAL;
87147 + } else
87148 +#endif
87149 +
87150 + if (end > TASK_SIZE)
87151 + return -EINVAL;
87152 +
87153 if (end == start)
87154 return 0;
87155
87156 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87157 */
87158 tcred = __task_cred(task);
87159 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87160 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87161 - !capable(CAP_SYS_NICE)) {
87162 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87163 rcu_read_unlock();
87164 err = -EPERM;
87165 goto out_put;
87166 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87167 goto out;
87168 }
87169
87170 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
87171 + if (mm != current->mm &&
87172 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
87173 + mmput(mm);
87174 + err = -EPERM;
87175 + goto out;
87176 + }
87177 +#endif
87178 +
87179 err = do_migrate_pages(mm, old, new,
87180 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
87181
87182 diff --git a/mm/migrate.c b/mm/migrate.c
87183 index 6f0c244..6d1ae32 100644
87184 --- a/mm/migrate.c
87185 +++ b/mm/migrate.c
87186 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
87187 */
87188 tcred = __task_cred(task);
87189 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87190 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87191 - !capable(CAP_SYS_NICE)) {
87192 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87193 rcu_read_unlock();
87194 err = -EPERM;
87195 goto out;
87196 diff --git a/mm/mlock.c b/mm/mlock.c
87197 index 79b7cf7..9944291 100644
87198 --- a/mm/mlock.c
87199 +++ b/mm/mlock.c
87200 @@ -13,6 +13,7 @@
87201 #include <linux/pagemap.h>
87202 #include <linux/mempolicy.h>
87203 #include <linux/syscalls.h>
87204 +#include <linux/security.h>
87205 #include <linux/sched.h>
87206 #include <linux/export.h>
87207 #include <linux/rmap.h>
87208 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
87209 {
87210 unsigned long nstart, end, tmp;
87211 struct vm_area_struct * vma, * prev;
87212 - int error;
87213 + int error = 0;
87214
87215 VM_BUG_ON(start & ~PAGE_MASK);
87216 VM_BUG_ON(len != PAGE_ALIGN(len));
87217 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87218 return -EINVAL;
87219 if (end == start)
87220 return 0;
87221 + if (end > TASK_SIZE)
87222 + return -EINVAL;
87223 +
87224 vma = find_vma(current->mm, start);
87225 if (!vma || vma->vm_start > start)
87226 return -ENOMEM;
87227 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87228 for (nstart = start ; ; ) {
87229 vm_flags_t newflags;
87230
87231 +#ifdef CONFIG_PAX_SEGMEXEC
87232 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87233 + break;
87234 +#endif
87235 +
87236 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87237
87238 newflags = vma->vm_flags & ~VM_LOCKED;
87239 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87240 lock_limit >>= PAGE_SHIFT;
87241
87242 /* check against resource limits */
87243 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87244 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87245 error = do_mlock(start, len, 1);
87246 up_write(&current->mm->mmap_sem);
87247 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
87248 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87249 vm_flags_t newflags;
87250
87251 +#ifdef CONFIG_PAX_SEGMEXEC
87252 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87253 + break;
87254 +#endif
87255 +
87256 newflags = vma->vm_flags & ~VM_LOCKED;
87257 if (flags & MCL_CURRENT)
87258 newflags |= VM_LOCKED;
87259 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87260 lock_limit >>= PAGE_SHIFT;
87261
87262 ret = -ENOMEM;
87263 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87264 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87265 capable(CAP_IPC_LOCK))
87266 ret = do_mlockall(flags);
87267 diff --git a/mm/mmap.c b/mm/mmap.c
87268 index f9c97d1..3468d3b 100644
87269 --- a/mm/mmap.c
87270 +++ b/mm/mmap.c
87271 @@ -36,6 +36,7 @@
87272 #include <linux/sched/sysctl.h>
87273 #include <linux/notifier.h>
87274 #include <linux/memory.h>
87275 +#include <linux/random.h>
87276
87277 #include <asm/uaccess.h>
87278 #include <asm/cacheflush.h>
87279 @@ -52,6 +53,16 @@
87280 #define arch_rebalance_pgtables(addr, len) (addr)
87281 #endif
87282
87283 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87284 +{
87285 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87286 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87287 + up_read(&mm->mmap_sem);
87288 + BUG();
87289 + }
87290 +#endif
87291 +}
87292 +
87293 static void unmap_region(struct mm_struct *mm,
87294 struct vm_area_struct *vma, struct vm_area_struct *prev,
87295 unsigned long start, unsigned long end);
87296 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87297 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87298 *
87299 */
87300 -pgprot_t protection_map[16] = {
87301 +pgprot_t protection_map[16] __read_only = {
87302 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87303 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87304 };
87305
87306 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87307 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87308 {
87309 - return __pgprot(pgprot_val(protection_map[vm_flags &
87310 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87311 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87312 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87313 +
87314 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87315 + if (!(__supported_pte_mask & _PAGE_NX) &&
87316 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87317 + (vm_flags & (VM_READ | VM_WRITE)))
87318 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87319 +#endif
87320 +
87321 + return prot;
87322 }
87323 EXPORT_SYMBOL(vm_get_page_prot);
87324
87325 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87326 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87327 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87328 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87329 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87330 /*
87331 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87332 * other variables. It can be updated by several CPUs frequently.
87333 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87334 struct vm_area_struct *next = vma->vm_next;
87335
87336 might_sleep();
87337 + BUG_ON(vma->vm_mirror);
87338 if (vma->vm_ops && vma->vm_ops->close)
87339 vma->vm_ops->close(vma);
87340 if (vma->vm_file)
87341 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87342 * not page aligned -Ram Gupta
87343 */
87344 rlim = rlimit(RLIMIT_DATA);
87345 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87346 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87347 (mm->end_data - mm->start_data) > rlim)
87348 goto out;
87349 @@ -933,6 +956,12 @@ static int
87350 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
87351 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87352 {
87353 +
87354 +#ifdef CONFIG_PAX_SEGMEXEC
87355 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
87356 + return 0;
87357 +#endif
87358 +
87359 if (is_mergeable_vma(vma, file, vm_flags) &&
87360 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87361 if (vma->vm_pgoff == vm_pgoff)
87362 @@ -952,6 +981,12 @@ static int
87363 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87364 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87365 {
87366 +
87367 +#ifdef CONFIG_PAX_SEGMEXEC
87368 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87369 + return 0;
87370 +#endif
87371 +
87372 if (is_mergeable_vma(vma, file, vm_flags) &&
87373 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87374 pgoff_t vm_pglen;
87375 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87376 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87377 struct vm_area_struct *prev, unsigned long addr,
87378 unsigned long end, unsigned long vm_flags,
87379 - struct anon_vma *anon_vma, struct file *file,
87380 + struct anon_vma *anon_vma, struct file *file,
87381 pgoff_t pgoff, struct mempolicy *policy)
87382 {
87383 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87384 struct vm_area_struct *area, *next;
87385 int err;
87386
87387 +#ifdef CONFIG_PAX_SEGMEXEC
87388 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87389 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87390 +
87391 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87392 +#endif
87393 +
87394 /*
87395 * We later require that vma->vm_flags == vm_flags,
87396 * so this tests vma->vm_flags & VM_SPECIAL, too.
87397 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87398 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87399 next = next->vm_next;
87400
87401 +#ifdef CONFIG_PAX_SEGMEXEC
87402 + if (prev)
87403 + prev_m = pax_find_mirror_vma(prev);
87404 + if (area)
87405 + area_m = pax_find_mirror_vma(area);
87406 + if (next)
87407 + next_m = pax_find_mirror_vma(next);
87408 +#endif
87409 +
87410 /*
87411 * Can it merge with the predecessor?
87412 */
87413 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87414 /* cases 1, 6 */
87415 err = vma_adjust(prev, prev->vm_start,
87416 next->vm_end, prev->vm_pgoff, NULL);
87417 - } else /* cases 2, 5, 7 */
87418 +
87419 +#ifdef CONFIG_PAX_SEGMEXEC
87420 + if (!err && prev_m)
87421 + err = vma_adjust(prev_m, prev_m->vm_start,
87422 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87423 +#endif
87424 +
87425 + } else { /* cases 2, 5, 7 */
87426 err = vma_adjust(prev, prev->vm_start,
87427 end, prev->vm_pgoff, NULL);
87428 +
87429 +#ifdef CONFIG_PAX_SEGMEXEC
87430 + if (!err && prev_m)
87431 + err = vma_adjust(prev_m, prev_m->vm_start,
87432 + end_m, prev_m->vm_pgoff, NULL);
87433 +#endif
87434 +
87435 + }
87436 if (err)
87437 return NULL;
87438 khugepaged_enter_vma_merge(prev);
87439 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87440 mpol_equal(policy, vma_policy(next)) &&
87441 can_vma_merge_before(next, vm_flags,
87442 anon_vma, file, pgoff+pglen)) {
87443 - if (prev && addr < prev->vm_end) /* case 4 */
87444 + if (prev && addr < prev->vm_end) { /* case 4 */
87445 err = vma_adjust(prev, prev->vm_start,
87446 addr, prev->vm_pgoff, NULL);
87447 - else /* cases 3, 8 */
87448 +
87449 +#ifdef CONFIG_PAX_SEGMEXEC
87450 + if (!err && prev_m)
87451 + err = vma_adjust(prev_m, prev_m->vm_start,
87452 + addr_m, prev_m->vm_pgoff, NULL);
87453 +#endif
87454 +
87455 + } else { /* cases 3, 8 */
87456 err = vma_adjust(area, addr, next->vm_end,
87457 next->vm_pgoff - pglen, NULL);
87458 +
87459 +#ifdef CONFIG_PAX_SEGMEXEC
87460 + if (!err && area_m)
87461 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87462 + next_m->vm_pgoff - pglen, NULL);
87463 +#endif
87464 +
87465 + }
87466 if (err)
87467 return NULL;
87468 khugepaged_enter_vma_merge(area);
87469 @@ -1165,8 +1246,10 @@ none:
87470 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87471 struct file *file, long pages)
87472 {
87473 - const unsigned long stack_flags
87474 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87475 +
87476 +#ifdef CONFIG_PAX_RANDMMAP
87477 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87478 +#endif
87479
87480 mm->total_vm += pages;
87481
87482 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87483 mm->shared_vm += pages;
87484 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87485 mm->exec_vm += pages;
87486 - } else if (flags & stack_flags)
87487 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87488 mm->stack_vm += pages;
87489 }
87490 #endif /* CONFIG_PROC_FS */
87491 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87492 * (the exception is when the underlying filesystem is noexec
87493 * mounted, in which case we dont add PROT_EXEC.)
87494 */
87495 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87496 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87497 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87498 prot |= PROT_EXEC;
87499
87500 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87501 /* Obtain the address to map to. we verify (or select) it and ensure
87502 * that it represents a valid section of the address space.
87503 */
87504 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87505 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87506 if (addr & ~PAGE_MASK)
87507 return addr;
87508
87509 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87510 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87511 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87512
87513 +#ifdef CONFIG_PAX_MPROTECT
87514 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87515 +
87516 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87517 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87518 + mm->binfmt->handle_mmap)
87519 + mm->binfmt->handle_mmap(file);
87520 +#endif
87521 +
87522 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87523 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87524 + gr_log_rwxmmap(file);
87525 +
87526 +#ifdef CONFIG_PAX_EMUPLT
87527 + vm_flags &= ~VM_EXEC;
87528 +#else
87529 + return -EPERM;
87530 +#endif
87531 +
87532 + }
87533 +
87534 + if (!(vm_flags & VM_EXEC))
87535 + vm_flags &= ~VM_MAYEXEC;
87536 +#else
87537 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87538 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87539 +#endif
87540 + else
87541 + vm_flags &= ~VM_MAYWRITE;
87542 + }
87543 +#endif
87544 +
87545 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87546 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87547 + vm_flags &= ~VM_PAGEEXEC;
87548 +#endif
87549 +
87550 if (flags & MAP_LOCKED)
87551 if (!can_do_mlock())
87552 return -EPERM;
87553 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87554 locked += mm->locked_vm;
87555 lock_limit = rlimit(RLIMIT_MEMLOCK);
87556 lock_limit >>= PAGE_SHIFT;
87557 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87558 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87559 return -EAGAIN;
87560 }
87561 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87562 vm_flags |= VM_NORESERVE;
87563 }
87564
87565 + if (!gr_acl_handle_mmap(file, prot))
87566 + return -EACCES;
87567 +
87568 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87569 if (!IS_ERR_VALUE(addr) &&
87570 ((vm_flags & VM_LOCKED) ||
87571 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87572 vm_flags_t vm_flags = vma->vm_flags;
87573
87574 /* If it was private or non-writable, the write bit is already clear */
87575 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87576 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87577 return 0;
87578
87579 /* The backer wishes to know when pages are first written to? */
87580 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87581 unsigned long charged = 0;
87582 struct inode *inode = file ? file_inode(file) : NULL;
87583
87584 +#ifdef CONFIG_PAX_SEGMEXEC
87585 + struct vm_area_struct *vma_m = NULL;
87586 +#endif
87587 +
87588 + /*
87589 + * mm->mmap_sem is required to protect against another thread
87590 + * changing the mappings in case we sleep.
87591 + */
87592 + verify_mm_writelocked(mm);
87593 +
87594 /* Check against address space limit. */
87595 +
87596 +#ifdef CONFIG_PAX_RANDMMAP
87597 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87598 +#endif
87599 +
87600 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87601 unsigned long nr_pages;
87602
87603 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87604
87605 /* Clear old maps */
87606 error = -ENOMEM;
87607 -munmap_back:
87608 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87609 if (do_munmap(mm, addr, len))
87610 return -ENOMEM;
87611 - goto munmap_back;
87612 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87613 }
87614
87615 /*
87616 @@ -1536,6 +1674,16 @@ munmap_back:
87617 goto unacct_error;
87618 }
87619
87620 +#ifdef CONFIG_PAX_SEGMEXEC
87621 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87622 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87623 + if (!vma_m) {
87624 + error = -ENOMEM;
87625 + goto free_vma;
87626 + }
87627 + }
87628 +#endif
87629 +
87630 vma->vm_mm = mm;
87631 vma->vm_start = addr;
87632 vma->vm_end = addr + len;
87633 @@ -1560,6 +1708,13 @@ munmap_back:
87634 if (error)
87635 goto unmap_and_free_vma;
87636
87637 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87638 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87639 + vma->vm_flags |= VM_PAGEEXEC;
87640 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87641 + }
87642 +#endif
87643 +
87644 /* Can addr have changed??
87645 *
87646 * Answer: Yes, several device drivers can do it in their
87647 @@ -1598,6 +1753,11 @@ munmap_back:
87648 vma_link(mm, vma, prev, rb_link, rb_parent);
87649 file = vma->vm_file;
87650
87651 +#ifdef CONFIG_PAX_SEGMEXEC
87652 + if (vma_m)
87653 + BUG_ON(pax_mirror_vma(vma_m, vma));
87654 +#endif
87655 +
87656 /* Once vma denies write, undo our temporary denial count */
87657 if (correct_wcount)
87658 atomic_inc(&inode->i_writecount);
87659 @@ -1605,6 +1765,7 @@ out:
87660 perf_event_mmap(vma);
87661
87662 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87663 + track_exec_limit(mm, addr, addr + len, vm_flags);
87664 if (vm_flags & VM_LOCKED) {
87665 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87666 vma == get_gate_vma(current->mm)))
87667 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87668 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87669 charged = 0;
87670 free_vma:
87671 +
87672 +#ifdef CONFIG_PAX_SEGMEXEC
87673 + if (vma_m)
87674 + kmem_cache_free(vm_area_cachep, vma_m);
87675 +#endif
87676 +
87677 kmem_cache_free(vm_area_cachep, vma);
87678 unacct_error:
87679 if (charged)
87680 @@ -1635,7 +1802,63 @@ unacct_error:
87681 return error;
87682 }
87683
87684 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87685 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87686 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87687 +{
87688 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87689 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87690 +
87691 + return 0;
87692 +}
87693 +#endif
87694 +
87695 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87696 +{
87697 + if (!vma) {
87698 +#ifdef CONFIG_STACK_GROWSUP
87699 + if (addr > sysctl_heap_stack_gap)
87700 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87701 + else
87702 + vma = find_vma(current->mm, 0);
87703 + if (vma && (vma->vm_flags & VM_GROWSUP))
87704 + return false;
87705 +#endif
87706 + return true;
87707 + }
87708 +
87709 + if (addr + len > vma->vm_start)
87710 + return false;
87711 +
87712 + if (vma->vm_flags & VM_GROWSDOWN)
87713 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87714 +#ifdef CONFIG_STACK_GROWSUP
87715 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87716 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87717 +#endif
87718 + else if (offset)
87719 + return offset <= vma->vm_start - addr - len;
87720 +
87721 + return true;
87722 +}
87723 +
87724 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87725 +{
87726 + if (vma->vm_start < len)
87727 + return -ENOMEM;
87728 +
87729 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87730 + if (offset <= vma->vm_start - len)
87731 + return vma->vm_start - len - offset;
87732 + else
87733 + return -ENOMEM;
87734 + }
87735 +
87736 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87737 + return vma->vm_start - len - sysctl_heap_stack_gap;
87738 + return -ENOMEM;
87739 +}
87740 +
87741 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87742 {
87743 /*
87744 * We implement the search by looking for an rbtree node that
87745 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87746 }
87747 }
87748
87749 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87750 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87751 check_current:
87752 /* Check if current node has a suitable gap */
87753 if (gap_start > high_limit)
87754 return -ENOMEM;
87755 +
87756 + if (gap_end - gap_start > info->threadstack_offset)
87757 + gap_start += info->threadstack_offset;
87758 + else
87759 + gap_start = gap_end;
87760 +
87761 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87762 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87763 + gap_start += sysctl_heap_stack_gap;
87764 + else
87765 + gap_start = gap_end;
87766 + }
87767 + if (vma->vm_flags & VM_GROWSDOWN) {
87768 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87769 + gap_end -= sysctl_heap_stack_gap;
87770 + else
87771 + gap_end = gap_start;
87772 + }
87773 if (gap_end >= low_limit && gap_end - gap_start >= length)
87774 goto found;
87775
87776 @@ -1737,7 +1978,7 @@ found:
87777 return gap_start;
87778 }
87779
87780 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87781 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87782 {
87783 struct mm_struct *mm = current->mm;
87784 struct vm_area_struct *vma;
87785 @@ -1791,6 +2032,24 @@ check_current:
87786 gap_end = vma->vm_start;
87787 if (gap_end < low_limit)
87788 return -ENOMEM;
87789 +
87790 + if (gap_end - gap_start > info->threadstack_offset)
87791 + gap_end -= info->threadstack_offset;
87792 + else
87793 + gap_end = gap_start;
87794 +
87795 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87796 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87797 + gap_start += sysctl_heap_stack_gap;
87798 + else
87799 + gap_start = gap_end;
87800 + }
87801 + if (vma->vm_flags & VM_GROWSDOWN) {
87802 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87803 + gap_end -= sysctl_heap_stack_gap;
87804 + else
87805 + gap_end = gap_start;
87806 + }
87807 if (gap_start <= high_limit && gap_end - gap_start >= length)
87808 goto found;
87809
87810 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87811 struct mm_struct *mm = current->mm;
87812 struct vm_area_struct *vma;
87813 struct vm_unmapped_area_info info;
87814 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87815
87816 if (len > TASK_SIZE)
87817 return -ENOMEM;
87818 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87819 if (flags & MAP_FIXED)
87820 return addr;
87821
87822 +#ifdef CONFIG_PAX_RANDMMAP
87823 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87824 +#endif
87825 +
87826 if (addr) {
87827 addr = PAGE_ALIGN(addr);
87828 vma = find_vma(mm, addr);
87829 - if (TASK_SIZE - len >= addr &&
87830 - (!vma || addr + len <= vma->vm_start))
87831 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87832 return addr;
87833 }
87834
87835 info.flags = 0;
87836 info.length = len;
87837 info.low_limit = TASK_UNMAPPED_BASE;
87838 +
87839 +#ifdef CONFIG_PAX_RANDMMAP
87840 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87841 + info.low_limit += mm->delta_mmap;
87842 +#endif
87843 +
87844 info.high_limit = TASK_SIZE;
87845 info.align_mask = 0;
87846 + info.threadstack_offset = offset;
87847 return vm_unmapped_area(&info);
87848 }
87849 #endif
87850 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87851 struct mm_struct *mm = current->mm;
87852 unsigned long addr = addr0;
87853 struct vm_unmapped_area_info info;
87854 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87855
87856 /* requested length too big for entire address space */
87857 if (len > TASK_SIZE)
87858 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87859 if (flags & MAP_FIXED)
87860 return addr;
87861
87862 +#ifdef CONFIG_PAX_RANDMMAP
87863 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87864 +#endif
87865 +
87866 /* requesting a specific address */
87867 if (addr) {
87868 addr = PAGE_ALIGN(addr);
87869 vma = find_vma(mm, addr);
87870 - if (TASK_SIZE - len >= addr &&
87871 - (!vma || addr + len <= vma->vm_start))
87872 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87873 return addr;
87874 }
87875
87876 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87877 info.low_limit = PAGE_SIZE;
87878 info.high_limit = mm->mmap_base;
87879 info.align_mask = 0;
87880 + info.threadstack_offset = offset;
87881 addr = vm_unmapped_area(&info);
87882
87883 /*
87884 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87885 VM_BUG_ON(addr != -ENOMEM);
87886 info.flags = 0;
87887 info.low_limit = TASK_UNMAPPED_BASE;
87888 +
87889 +#ifdef CONFIG_PAX_RANDMMAP
87890 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87891 + info.low_limit += mm->delta_mmap;
87892 +#endif
87893 +
87894 info.high_limit = TASK_SIZE;
87895 addr = vm_unmapped_area(&info);
87896 }
87897 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
87898 return vma;
87899 }
87900
87901 +#ifdef CONFIG_PAX_SEGMEXEC
87902 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
87903 +{
87904 + struct vm_area_struct *vma_m;
87905 +
87906 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
87907 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
87908 + BUG_ON(vma->vm_mirror);
87909 + return NULL;
87910 + }
87911 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
87912 + vma_m = vma->vm_mirror;
87913 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
87914 + BUG_ON(vma->vm_file != vma_m->vm_file);
87915 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
87916 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
87917 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
87918 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
87919 + return vma_m;
87920 +}
87921 +#endif
87922 +
87923 /*
87924 * Verify that the stack growth is acceptable and
87925 * update accounting. This is shared with both the
87926 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87927 return -ENOMEM;
87928
87929 /* Stack limit test */
87930 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
87931 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
87932 return -ENOMEM;
87933
87934 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87935 locked = mm->locked_vm + grow;
87936 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
87937 limit >>= PAGE_SHIFT;
87938 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87939 if (locked > limit && !capable(CAP_IPC_LOCK))
87940 return -ENOMEM;
87941 }
87942 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87943 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
87944 * vma is the last one with address > vma->vm_end. Have to extend vma.
87945 */
87946 +#ifndef CONFIG_IA64
87947 +static
87948 +#endif
87949 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
87950 {
87951 int error;
87952 + bool locknext;
87953
87954 if (!(vma->vm_flags & VM_GROWSUP))
87955 return -EFAULT;
87956
87957 + /* Also guard against wrapping around to address 0. */
87958 + if (address < PAGE_ALIGN(address+1))
87959 + address = PAGE_ALIGN(address+1);
87960 + else
87961 + return -ENOMEM;
87962 +
87963 /*
87964 * We must make sure the anon_vma is allocated
87965 * so that the anon_vma locking is not a noop.
87966 */
87967 if (unlikely(anon_vma_prepare(vma)))
87968 return -ENOMEM;
87969 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
87970 + if (locknext && anon_vma_prepare(vma->vm_next))
87971 + return -ENOMEM;
87972 vma_lock_anon_vma(vma);
87973 + if (locknext)
87974 + vma_lock_anon_vma(vma->vm_next);
87975
87976 /*
87977 * vma->vm_start/vm_end cannot change under us because the caller
87978 * is required to hold the mmap_sem in read mode. We need the
87979 - * anon_vma lock to serialize against concurrent expand_stacks.
87980 - * Also guard against wrapping around to address 0.
87981 + * anon_vma locks to serialize against concurrent expand_stacks
87982 + * and expand_upwards.
87983 */
87984 - if (address < PAGE_ALIGN(address+4))
87985 - address = PAGE_ALIGN(address+4);
87986 - else {
87987 - vma_unlock_anon_vma(vma);
87988 - return -ENOMEM;
87989 - }
87990 error = 0;
87991
87992 /* Somebody else might have raced and expanded it already */
87993 - if (address > vma->vm_end) {
87994 + 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)
87995 + error = -ENOMEM;
87996 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
87997 unsigned long size, grow;
87998
87999 size = address - vma->vm_start;
88000 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88001 }
88002 }
88003 }
88004 + if (locknext)
88005 + vma_unlock_anon_vma(vma->vm_next);
88006 vma_unlock_anon_vma(vma);
88007 khugepaged_enter_vma_merge(vma);
88008 validate_mm(vma->vm_mm);
88009 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
88010 unsigned long address)
88011 {
88012 int error;
88013 + bool lockprev = false;
88014 + struct vm_area_struct *prev;
88015
88016 /*
88017 * We must make sure the anon_vma is allocated
88018 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
88019 if (error)
88020 return error;
88021
88022 + prev = vma->vm_prev;
88023 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
88024 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
88025 +#endif
88026 + if (lockprev && anon_vma_prepare(prev))
88027 + return -ENOMEM;
88028 + if (lockprev)
88029 + vma_lock_anon_vma(prev);
88030 +
88031 vma_lock_anon_vma(vma);
88032
88033 /*
88034 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
88035 */
88036
88037 /* Somebody else might have raced and expanded it already */
88038 - if (address < vma->vm_start) {
88039 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
88040 + error = -ENOMEM;
88041 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
88042 unsigned long size, grow;
88043
88044 +#ifdef CONFIG_PAX_SEGMEXEC
88045 + struct vm_area_struct *vma_m;
88046 +
88047 + vma_m = pax_find_mirror_vma(vma);
88048 +#endif
88049 +
88050 size = vma->vm_end - address;
88051 grow = (vma->vm_start - address) >> PAGE_SHIFT;
88052
88053 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
88054 vma->vm_pgoff -= grow;
88055 anon_vma_interval_tree_post_update_vma(vma);
88056 vma_gap_update(vma);
88057 +
88058 +#ifdef CONFIG_PAX_SEGMEXEC
88059 + if (vma_m) {
88060 + anon_vma_interval_tree_pre_update_vma(vma_m);
88061 + vma_m->vm_start -= grow << PAGE_SHIFT;
88062 + vma_m->vm_pgoff -= grow;
88063 + anon_vma_interval_tree_post_update_vma(vma_m);
88064 + vma_gap_update(vma_m);
88065 + }
88066 +#endif
88067 +
88068 spin_unlock(&vma->vm_mm->page_table_lock);
88069
88070 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
88071 perf_event_mmap(vma);
88072 }
88073 }
88074 }
88075 vma_unlock_anon_vma(vma);
88076 + if (lockprev)
88077 + vma_unlock_anon_vma(prev);
88078 khugepaged_enter_vma_merge(vma);
88079 validate_mm(vma->vm_mm);
88080 return error;
88081 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
88082 do {
88083 long nrpages = vma_pages(vma);
88084
88085 +#ifdef CONFIG_PAX_SEGMEXEC
88086 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
88087 + vma = remove_vma(vma);
88088 + continue;
88089 + }
88090 +#endif
88091 +
88092 if (vma->vm_flags & VM_ACCOUNT)
88093 nr_accounted += nrpages;
88094 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
88095 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
88096 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
88097 vma->vm_prev = NULL;
88098 do {
88099 +
88100 +#ifdef CONFIG_PAX_SEGMEXEC
88101 + if (vma->vm_mirror) {
88102 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
88103 + vma->vm_mirror->vm_mirror = NULL;
88104 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
88105 + vma->vm_mirror = NULL;
88106 + }
88107 +#endif
88108 +
88109 vma_rb_erase(vma, &mm->mm_rb);
88110 mm->map_count--;
88111 tail_vma = vma;
88112 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88113 struct vm_area_struct *new;
88114 int err = -ENOMEM;
88115
88116 +#ifdef CONFIG_PAX_SEGMEXEC
88117 + struct vm_area_struct *vma_m, *new_m = NULL;
88118 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
88119 +#endif
88120 +
88121 if (is_vm_hugetlb_page(vma) && (addr &
88122 ~(huge_page_mask(hstate_vma(vma)))))
88123 return -EINVAL;
88124
88125 +#ifdef CONFIG_PAX_SEGMEXEC
88126 + vma_m = pax_find_mirror_vma(vma);
88127 +#endif
88128 +
88129 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88130 if (!new)
88131 goto out_err;
88132
88133 +#ifdef CONFIG_PAX_SEGMEXEC
88134 + if (vma_m) {
88135 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88136 + if (!new_m) {
88137 + kmem_cache_free(vm_area_cachep, new);
88138 + goto out_err;
88139 + }
88140 + }
88141 +#endif
88142 +
88143 /* most fields are the same, copy all, and then fixup */
88144 *new = *vma;
88145
88146 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88147 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
88148 }
88149
88150 +#ifdef CONFIG_PAX_SEGMEXEC
88151 + if (vma_m) {
88152 + *new_m = *vma_m;
88153 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
88154 + new_m->vm_mirror = new;
88155 + new->vm_mirror = new_m;
88156 +
88157 + if (new_below)
88158 + new_m->vm_end = addr_m;
88159 + else {
88160 + new_m->vm_start = addr_m;
88161 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
88162 + }
88163 + }
88164 +#endif
88165 +
88166 pol = mpol_dup(vma_policy(vma));
88167 if (IS_ERR(pol)) {
88168 err = PTR_ERR(pol);
88169 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88170 else
88171 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
88172
88173 +#ifdef CONFIG_PAX_SEGMEXEC
88174 + if (!err && vma_m) {
88175 + if (anon_vma_clone(new_m, vma_m))
88176 + goto out_free_mpol;
88177 +
88178 + mpol_get(pol);
88179 + vma_set_policy(new_m, pol);
88180 +
88181 + if (new_m->vm_file)
88182 + get_file(new_m->vm_file);
88183 +
88184 + if (new_m->vm_ops && new_m->vm_ops->open)
88185 + new_m->vm_ops->open(new_m);
88186 +
88187 + if (new_below)
88188 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
88189 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
88190 + else
88191 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
88192 +
88193 + if (err) {
88194 + if (new_m->vm_ops && new_m->vm_ops->close)
88195 + new_m->vm_ops->close(new_m);
88196 + if (new_m->vm_file)
88197 + fput(new_m->vm_file);
88198 + mpol_put(pol);
88199 + }
88200 + }
88201 +#endif
88202 +
88203 /* Success. */
88204 if (!err)
88205 return 0;
88206 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88207 new->vm_ops->close(new);
88208 if (new->vm_file)
88209 fput(new->vm_file);
88210 - unlink_anon_vmas(new);
88211 out_free_mpol:
88212 mpol_put(pol);
88213 out_free_vma:
88214 +
88215 +#ifdef CONFIG_PAX_SEGMEXEC
88216 + if (new_m) {
88217 + unlink_anon_vmas(new_m);
88218 + kmem_cache_free(vm_area_cachep, new_m);
88219 + }
88220 +#endif
88221 +
88222 + unlink_anon_vmas(new);
88223 kmem_cache_free(vm_area_cachep, new);
88224 out_err:
88225 return err;
88226 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88227 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88228 unsigned long addr, int new_below)
88229 {
88230 +
88231 +#ifdef CONFIG_PAX_SEGMEXEC
88232 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88233 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88234 + if (mm->map_count >= sysctl_max_map_count-1)
88235 + return -ENOMEM;
88236 + } else
88237 +#endif
88238 +
88239 if (mm->map_count >= sysctl_max_map_count)
88240 return -ENOMEM;
88241
88242 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88243 * work. This now handles partial unmappings.
88244 * Jeremy Fitzhardinge <jeremy@goop.org>
88245 */
88246 +#ifdef CONFIG_PAX_SEGMEXEC
88247 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88248 {
88249 + int ret = __do_munmap(mm, start, len);
88250 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88251 + return ret;
88252 +
88253 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88254 +}
88255 +
88256 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88257 +#else
88258 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88259 +#endif
88260 +{
88261 unsigned long end;
88262 struct vm_area_struct *vma, *prev, *last;
88263
88264 + /*
88265 + * mm->mmap_sem is required to protect against another thread
88266 + * changing the mappings in case we sleep.
88267 + */
88268 + verify_mm_writelocked(mm);
88269 +
88270 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88271 return -EINVAL;
88272
88273 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88274 /* Fix up all other VM information */
88275 remove_vma_list(mm, vma);
88276
88277 + track_exec_limit(mm, start, end, 0UL);
88278 +
88279 return 0;
88280 }
88281
88282 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88283 int ret;
88284 struct mm_struct *mm = current->mm;
88285
88286 +
88287 +#ifdef CONFIG_PAX_SEGMEXEC
88288 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88289 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88290 + return -EINVAL;
88291 +#endif
88292 +
88293 down_write(&mm->mmap_sem);
88294 ret = do_munmap(mm, start, len);
88295 up_write(&mm->mmap_sem);
88296 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88297 return vm_munmap(addr, len);
88298 }
88299
88300 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88301 -{
88302 -#ifdef CONFIG_DEBUG_VM
88303 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88304 - WARN_ON(1);
88305 - up_read(&mm->mmap_sem);
88306 - }
88307 -#endif
88308 -}
88309 -
88310 /*
88311 * this is really a simplified "do_mmap". it only handles
88312 * anonymous maps. eventually we may be able to do some
88313 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88314 struct rb_node ** rb_link, * rb_parent;
88315 pgoff_t pgoff = addr >> PAGE_SHIFT;
88316 int error;
88317 + unsigned long charged;
88318
88319 len = PAGE_ALIGN(len);
88320 if (!len)
88321 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88322
88323 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88324
88325 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88326 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88327 + flags &= ~VM_EXEC;
88328 +
88329 +#ifdef CONFIG_PAX_MPROTECT
88330 + if (mm->pax_flags & MF_PAX_MPROTECT)
88331 + flags &= ~VM_MAYEXEC;
88332 +#endif
88333 +
88334 + }
88335 +#endif
88336 +
88337 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88338 if (error & ~PAGE_MASK)
88339 return error;
88340
88341 + charged = len >> PAGE_SHIFT;
88342 +
88343 /*
88344 * mlock MCL_FUTURE?
88345 */
88346 if (mm->def_flags & VM_LOCKED) {
88347 unsigned long locked, lock_limit;
88348 - locked = len >> PAGE_SHIFT;
88349 + locked = charged;
88350 locked += mm->locked_vm;
88351 lock_limit = rlimit(RLIMIT_MEMLOCK);
88352 lock_limit >>= PAGE_SHIFT;
88353 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88354 /*
88355 * Clear old maps. this also does some error checking for us
88356 */
88357 - munmap_back:
88358 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88359 if (do_munmap(mm, addr, len))
88360 return -ENOMEM;
88361 - goto munmap_back;
88362 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88363 }
88364
88365 /* Check against address space limits *after* clearing old maps... */
88366 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88367 + if (!may_expand_vm(mm, charged))
88368 return -ENOMEM;
88369
88370 if (mm->map_count > sysctl_max_map_count)
88371 return -ENOMEM;
88372
88373 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88374 + if (security_vm_enough_memory_mm(mm, charged))
88375 return -ENOMEM;
88376
88377 /* Can we just expand an old private anonymous mapping? */
88378 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88379 */
88380 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88381 if (!vma) {
88382 - vm_unacct_memory(len >> PAGE_SHIFT);
88383 + vm_unacct_memory(charged);
88384 return -ENOMEM;
88385 }
88386
88387 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88388 vma_link(mm, vma, prev, rb_link, rb_parent);
88389 out:
88390 perf_event_mmap(vma);
88391 - mm->total_vm += len >> PAGE_SHIFT;
88392 + mm->total_vm += charged;
88393 if (flags & VM_LOCKED)
88394 - mm->locked_vm += (len >> PAGE_SHIFT);
88395 + mm->locked_vm += charged;
88396 + track_exec_limit(mm, addr, addr + len, flags);
88397 return addr;
88398 }
88399
88400 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88401 while (vma) {
88402 if (vma->vm_flags & VM_ACCOUNT)
88403 nr_accounted += vma_pages(vma);
88404 + vma->vm_mirror = NULL;
88405 vma = remove_vma(vma);
88406 }
88407 vm_unacct_memory(nr_accounted);
88408 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88409 struct vm_area_struct *prev;
88410 struct rb_node **rb_link, *rb_parent;
88411
88412 +#ifdef CONFIG_PAX_SEGMEXEC
88413 + struct vm_area_struct *vma_m = NULL;
88414 +#endif
88415 +
88416 + if (security_mmap_addr(vma->vm_start))
88417 + return -EPERM;
88418 +
88419 /*
88420 * The vm_pgoff of a purely anonymous vma should be irrelevant
88421 * until its first write fault, when page's anon_vma and index
88422 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88423 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88424 return -ENOMEM;
88425
88426 +#ifdef CONFIG_PAX_SEGMEXEC
88427 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88428 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88429 + if (!vma_m)
88430 + return -ENOMEM;
88431 + }
88432 +#endif
88433 +
88434 vma_link(mm, vma, prev, rb_link, rb_parent);
88435 +
88436 +#ifdef CONFIG_PAX_SEGMEXEC
88437 + if (vma_m)
88438 + BUG_ON(pax_mirror_vma(vma_m, vma));
88439 +#endif
88440 +
88441 return 0;
88442 }
88443
88444 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88445 struct mempolicy *pol;
88446 bool faulted_in_anon_vma = true;
88447
88448 + BUG_ON(vma->vm_mirror);
88449 +
88450 /*
88451 * If anonymous vma has not yet been faulted, update new pgoff
88452 * to match new location, to increase its chance of merging.
88453 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88454 return NULL;
88455 }
88456
88457 +#ifdef CONFIG_PAX_SEGMEXEC
88458 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88459 +{
88460 + struct vm_area_struct *prev_m;
88461 + struct rb_node **rb_link_m, *rb_parent_m;
88462 + struct mempolicy *pol_m;
88463 +
88464 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88465 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88466 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88467 + *vma_m = *vma;
88468 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88469 + if (anon_vma_clone(vma_m, vma))
88470 + return -ENOMEM;
88471 + pol_m = vma_policy(vma_m);
88472 + mpol_get(pol_m);
88473 + vma_set_policy(vma_m, pol_m);
88474 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88475 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88476 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88477 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88478 + if (vma_m->vm_file)
88479 + get_file(vma_m->vm_file);
88480 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88481 + vma_m->vm_ops->open(vma_m);
88482 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88483 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88484 + vma_m->vm_mirror = vma;
88485 + vma->vm_mirror = vma_m;
88486 + return 0;
88487 +}
88488 +#endif
88489 +
88490 /*
88491 * Return true if the calling process may expand its vm space by the passed
88492 * number of pages
88493 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88494
88495 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88496
88497 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88498 if (cur + npages > lim)
88499 return 0;
88500 return 1;
88501 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88502 vma->vm_start = addr;
88503 vma->vm_end = addr + len;
88504
88505 +#ifdef CONFIG_PAX_MPROTECT
88506 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88507 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88508 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88509 + return -EPERM;
88510 + if (!(vm_flags & VM_EXEC))
88511 + vm_flags &= ~VM_MAYEXEC;
88512 +#else
88513 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88514 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88515 +#endif
88516 + else
88517 + vm_flags &= ~VM_MAYWRITE;
88518 + }
88519 +#endif
88520 +
88521 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88522 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88523
88524 diff --git a/mm/mprotect.c b/mm/mprotect.c
88525 index 94722a4..e661e29 100644
88526 --- a/mm/mprotect.c
88527 +++ b/mm/mprotect.c
88528 @@ -23,10 +23,18 @@
88529 #include <linux/mmu_notifier.h>
88530 #include <linux/migrate.h>
88531 #include <linux/perf_event.h>
88532 +#include <linux/sched/sysctl.h>
88533 +
88534 +#ifdef CONFIG_PAX_MPROTECT
88535 +#include <linux/elf.h>
88536 +#include <linux/binfmts.h>
88537 +#endif
88538 +
88539 #include <asm/uaccess.h>
88540 #include <asm/pgtable.h>
88541 #include <asm/cacheflush.h>
88542 #include <asm/tlbflush.h>
88543 +#include <asm/mmu_context.h>
88544
88545 #ifndef pgprot_modify
88546 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88547 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88548 return pages;
88549 }
88550
88551 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88552 +/* called while holding the mmap semaphor for writing except stack expansion */
88553 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88554 +{
88555 + unsigned long oldlimit, newlimit = 0UL;
88556 +
88557 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88558 + return;
88559 +
88560 + spin_lock(&mm->page_table_lock);
88561 + oldlimit = mm->context.user_cs_limit;
88562 + if ((prot & VM_EXEC) && oldlimit < end)
88563 + /* USER_CS limit moved up */
88564 + newlimit = end;
88565 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88566 + /* USER_CS limit moved down */
88567 + newlimit = start;
88568 +
88569 + if (newlimit) {
88570 + mm->context.user_cs_limit = newlimit;
88571 +
88572 +#ifdef CONFIG_SMP
88573 + wmb();
88574 + cpus_clear(mm->context.cpu_user_cs_mask);
88575 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88576 +#endif
88577 +
88578 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88579 + }
88580 + spin_unlock(&mm->page_table_lock);
88581 + if (newlimit == end) {
88582 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88583 +
88584 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88585 + if (is_vm_hugetlb_page(vma))
88586 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88587 + else
88588 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88589 + }
88590 +}
88591 +#endif
88592 +
88593 int
88594 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88595 unsigned long start, unsigned long end, unsigned long newflags)
88596 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88597 int error;
88598 int dirty_accountable = 0;
88599
88600 +#ifdef CONFIG_PAX_SEGMEXEC
88601 + struct vm_area_struct *vma_m = NULL;
88602 + unsigned long start_m, end_m;
88603 +
88604 + start_m = start + SEGMEXEC_TASK_SIZE;
88605 + end_m = end + SEGMEXEC_TASK_SIZE;
88606 +#endif
88607 +
88608 if (newflags == oldflags) {
88609 *pprev = vma;
88610 return 0;
88611 }
88612
88613 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88614 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88615 +
88616 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88617 + return -ENOMEM;
88618 +
88619 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88620 + return -ENOMEM;
88621 + }
88622 +
88623 /*
88624 * If we make a private mapping writable we increase our commit;
88625 * but (without finer accounting) cannot reduce our commit if we
88626 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88627 }
88628 }
88629
88630 +#ifdef CONFIG_PAX_SEGMEXEC
88631 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88632 + if (start != vma->vm_start) {
88633 + error = split_vma(mm, vma, start, 1);
88634 + if (error)
88635 + goto fail;
88636 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88637 + *pprev = (*pprev)->vm_next;
88638 + }
88639 +
88640 + if (end != vma->vm_end) {
88641 + error = split_vma(mm, vma, end, 0);
88642 + if (error)
88643 + goto fail;
88644 + }
88645 +
88646 + if (pax_find_mirror_vma(vma)) {
88647 + error = __do_munmap(mm, start_m, end_m - start_m);
88648 + if (error)
88649 + goto fail;
88650 + } else {
88651 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88652 + if (!vma_m) {
88653 + error = -ENOMEM;
88654 + goto fail;
88655 + }
88656 + vma->vm_flags = newflags;
88657 + error = pax_mirror_vma(vma_m, vma);
88658 + if (error) {
88659 + vma->vm_flags = oldflags;
88660 + goto fail;
88661 + }
88662 + }
88663 + }
88664 +#endif
88665 +
88666 /*
88667 * First try to merge with previous and/or next vma.
88668 */
88669 @@ -296,9 +400,21 @@ success:
88670 * vm_flags and vm_page_prot are protected by the mmap_sem
88671 * held in write mode.
88672 */
88673 +
88674 +#ifdef CONFIG_PAX_SEGMEXEC
88675 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88676 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88677 +#endif
88678 +
88679 vma->vm_flags = newflags;
88680 +
88681 +#ifdef CONFIG_PAX_MPROTECT
88682 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88683 + mm->binfmt->handle_mprotect(vma, newflags);
88684 +#endif
88685 +
88686 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88687 - vm_get_page_prot(newflags));
88688 + vm_get_page_prot(vma->vm_flags));
88689
88690 if (vma_wants_writenotify(vma)) {
88691 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88692 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88693 end = start + len;
88694 if (end <= start)
88695 return -ENOMEM;
88696 +
88697 +#ifdef CONFIG_PAX_SEGMEXEC
88698 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88699 + if (end > SEGMEXEC_TASK_SIZE)
88700 + return -EINVAL;
88701 + } else
88702 +#endif
88703 +
88704 + if (end > TASK_SIZE)
88705 + return -EINVAL;
88706 +
88707 if (!arch_validate_prot(prot))
88708 return -EINVAL;
88709
88710 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88711 /*
88712 * Does the application expect PROT_READ to imply PROT_EXEC:
88713 */
88714 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88715 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88716 prot |= PROT_EXEC;
88717
88718 vm_flags = calc_vm_prot_bits(prot);
88719 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88720 if (start > vma->vm_start)
88721 prev = vma;
88722
88723 +#ifdef CONFIG_PAX_MPROTECT
88724 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88725 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88726 +#endif
88727 +
88728 for (nstart = start ; ; ) {
88729 unsigned long newflags;
88730
88731 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88732
88733 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88734 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88735 + if (prot & (PROT_WRITE | PROT_EXEC))
88736 + gr_log_rwxmprotect(vma);
88737 +
88738 + error = -EACCES;
88739 + goto out;
88740 + }
88741 +
88742 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88743 error = -EACCES;
88744 goto out;
88745 }
88746 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88747 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88748 if (error)
88749 goto out;
88750 +
88751 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88752 +
88753 nstart = tmp;
88754
88755 if (nstart < prev->vm_end)
88756 diff --git a/mm/mremap.c b/mm/mremap.c
88757 index 0843feb..5607f47 100644
88758 --- a/mm/mremap.c
88759 +++ b/mm/mremap.c
88760 @@ -25,6 +25,7 @@
88761 #include <asm/uaccess.h>
88762 #include <asm/cacheflush.h>
88763 #include <asm/tlbflush.h>
88764 +#include <asm/pgalloc.h>
88765
88766 #include "internal.h"
88767
88768 @@ -62,8 +63,10 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma,
88769 return NULL;
88770
88771 pmd = pmd_alloc(mm, pud, addr);
88772 - if (!pmd)
88773 + if (!pmd) {
88774 + pud_free(mm, pud);
88775 return NULL;
88776 + }
88777
88778 VM_BUG_ON(pmd_trans_huge(*pmd));
88779
88780 @@ -144,6 +147,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88781 continue;
88782 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88783 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88784 +
88785 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88786 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88787 + pte = pte_exprotect(pte);
88788 +#endif
88789 +
88790 pte = move_soft_dirty_pte(pte);
88791 set_pte_at(mm, new_addr, new_pte, pte);
88792 }
88793 @@ -337,6 +346,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88794 if (is_vm_hugetlb_page(vma))
88795 goto Einval;
88796
88797 +#ifdef CONFIG_PAX_SEGMEXEC
88798 + if (pax_find_mirror_vma(vma))
88799 + goto Einval;
88800 +#endif
88801 +
88802 /* We can't remap across vm area boundaries */
88803 if (old_len > vma->vm_end - addr)
88804 goto Efault;
88805 @@ -392,20 +406,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88806 unsigned long ret = -EINVAL;
88807 unsigned long charged = 0;
88808 unsigned long map_flags;
88809 + unsigned long pax_task_size = TASK_SIZE;
88810
88811 if (new_addr & ~PAGE_MASK)
88812 goto out;
88813
88814 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88815 +#ifdef CONFIG_PAX_SEGMEXEC
88816 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88817 + pax_task_size = SEGMEXEC_TASK_SIZE;
88818 +#endif
88819 +
88820 + pax_task_size -= PAGE_SIZE;
88821 +
88822 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88823 goto out;
88824
88825 /* Check if the location we're moving into overlaps the
88826 * old location at all, and fail if it does.
88827 */
88828 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88829 - goto out;
88830 -
88831 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88832 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88833 goto out;
88834
88835 ret = do_munmap(mm, new_addr, new_len);
88836 @@ -474,6 +493,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88837 unsigned long ret = -EINVAL;
88838 unsigned long charged = 0;
88839 bool locked = false;
88840 + unsigned long pax_task_size = TASK_SIZE;
88841
88842 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88843 return ret;
88844 @@ -495,6 +515,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88845 if (!new_len)
88846 return ret;
88847
88848 +#ifdef CONFIG_PAX_SEGMEXEC
88849 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88850 + pax_task_size = SEGMEXEC_TASK_SIZE;
88851 +#endif
88852 +
88853 + pax_task_size -= PAGE_SIZE;
88854 +
88855 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
88856 + old_len > pax_task_size || addr > pax_task_size-old_len)
88857 + return ret;
88858 +
88859 down_write(&current->mm->mmap_sem);
88860
88861 if (flags & MREMAP_FIXED) {
88862 @@ -545,6 +576,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88863 new_addr = addr;
88864 }
88865 ret = addr;
88866 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
88867 goto out;
88868 }
88869 }
88870 @@ -568,7 +600,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88871 goto out;
88872 }
88873
88874 + map_flags = vma->vm_flags;
88875 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
88876 + if (!(ret & ~PAGE_MASK)) {
88877 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
88878 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
88879 + }
88880 }
88881 out:
88882 if (ret & ~PAGE_MASK)
88883 diff --git a/mm/nommu.c b/mm/nommu.c
88884 index ecd1f15..77039bd 100644
88885 --- a/mm/nommu.c
88886 +++ b/mm/nommu.c
88887 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
88888 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
88889 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88890 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88891 -int heap_stack_gap = 0;
88892
88893 atomic_long_t mmap_pages_allocated;
88894
88895 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
88896 EXPORT_SYMBOL(find_vma);
88897
88898 /*
88899 - * find a VMA
88900 - * - we don't extend stack VMAs under NOMMU conditions
88901 - */
88902 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
88903 -{
88904 - return find_vma(mm, addr);
88905 -}
88906 -
88907 -/*
88908 * expand a stack to a given address
88909 * - not supported under NOMMU conditions
88910 */
88911 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88912
88913 /* most fields are the same, copy all, and then fixup */
88914 *new = *vma;
88915 + INIT_LIST_HEAD(&new->anon_vma_chain);
88916 *region = *vma->vm_region;
88917 new->vm_region = region;
88918
88919 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
88920 }
88921 EXPORT_SYMBOL(generic_file_remap_pages);
88922
88923 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88924 - unsigned long addr, void *buf, int len, int write)
88925 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88926 + unsigned long addr, void *buf, size_t len, int write)
88927 {
88928 struct vm_area_struct *vma;
88929
88930 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88931 *
88932 * The caller must hold a reference on @mm.
88933 */
88934 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88935 - void *buf, int len, int write)
88936 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88937 + void *buf, size_t len, int write)
88938 {
88939 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88940 }
88941 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88942 * Access another process' address space.
88943 * - source/target buffer must be kernel space
88944 */
88945 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
88946 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
88947 {
88948 struct mm_struct *mm;
88949
88950 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
88951 index 3f0c895..60cd104 100644
88952 --- a/mm/page-writeback.c
88953 +++ b/mm/page-writeback.c
88954 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
88955 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
88956 * - the bdi dirty thresh drops quickly due to change of JBOD workload
88957 */
88958 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
88959 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
88960 unsigned long thresh,
88961 unsigned long bg_thresh,
88962 unsigned long dirty,
88963 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
88964 index b100255..fba1254 100644
88965 --- a/mm/page_alloc.c
88966 +++ b/mm/page_alloc.c
88967 @@ -60,6 +60,7 @@
88968 #include <linux/page-debug-flags.h>
88969 #include <linux/hugetlb.h>
88970 #include <linux/sched/rt.h>
88971 +#include <linux/random.h>
88972
88973 #include <asm/sections.h>
88974 #include <asm/tlbflush.h>
88975 @@ -353,7 +354,7 @@ out:
88976 * This usage means that zero-order pages may not be compound.
88977 */
88978
88979 -static void free_compound_page(struct page *page)
88980 +void free_compound_page(struct page *page)
88981 {
88982 __free_pages_ok(page, compound_order(page));
88983 }
88984 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
88985 int i;
88986 int bad = 0;
88987
88988 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88989 + unsigned long index = 1UL << order;
88990 +#endif
88991 +
88992 trace_mm_page_free(page, order);
88993 kmemcheck_free_shadow(page, order);
88994
88995 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
88996 debug_check_no_obj_freed(page_address(page),
88997 PAGE_SIZE << order);
88998 }
88999 +
89000 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89001 + for (; index; --index)
89002 + sanitize_highpage(page + index - 1);
89003 +#endif
89004 +
89005 arch_free_page(page, order);
89006 kernel_map_pages(page, 1 << order, 0);
89007
89008 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
89009 local_irq_restore(flags);
89010 }
89011
89012 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89013 +bool __meminitdata extra_latent_entropy;
89014 +
89015 +static int __init setup_pax_extra_latent_entropy(char *str)
89016 +{
89017 + extra_latent_entropy = true;
89018 + return 0;
89019 +}
89020 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
89021 +
89022 +volatile u64 latent_entropy;
89023 +EXPORT_SYMBOL(latent_entropy);
89024 +#endif
89025 +
89026 void __init __free_pages_bootmem(struct page *page, unsigned int order)
89027 {
89028 unsigned int nr_pages = 1 << order;
89029 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
89030 set_page_count(p, 0);
89031 }
89032
89033 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89034 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
89035 + u64 hash = 0;
89036 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
89037 + const u64 *data = lowmem_page_address(page);
89038 +
89039 + for (index = 0; index < end; index++)
89040 + hash ^= hash + data[index];
89041 + latent_entropy ^= hash;
89042 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
89043 + }
89044 +#endif
89045 +
89046 page_zone(page)->managed_pages += 1 << order;
89047 set_page_refcounted(page);
89048 __free_pages(page, order);
89049 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
89050 arch_alloc_page(page, order);
89051 kernel_map_pages(page, 1 << order, 1);
89052
89053 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
89054 if (gfp_flags & __GFP_ZERO)
89055 prep_zero_page(page, order, gfp_flags);
89056 +#endif
89057
89058 if (order && (gfp_flags & __GFP_COMP))
89059 prep_compound_page(page, order);
89060 diff --git a/mm/page_io.c b/mm/page_io.c
89061 index ba05b64..ef2f314 100644
89062 --- a/mm/page_io.c
89063 +++ b/mm/page_io.c
89064 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
89065 struct file *swap_file = sis->swap_file;
89066 struct address_space *mapping = swap_file->f_mapping;
89067 struct iovec iov = {
89068 - .iov_base = kmap(page),
89069 + .iov_base = (void __force_user *)kmap(page),
89070 .iov_len = PAGE_SIZE,
89071 };
89072
89073 diff --git a/mm/percpu.c b/mm/percpu.c
89074 index 8c8e08f..73a5cda 100644
89075 --- a/mm/percpu.c
89076 +++ b/mm/percpu.c
89077 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
89078 static unsigned int pcpu_high_unit_cpu __read_mostly;
89079
89080 /* the address of the first chunk which starts with the kernel static area */
89081 -void *pcpu_base_addr __read_mostly;
89082 +void *pcpu_base_addr __read_only;
89083 EXPORT_SYMBOL_GPL(pcpu_base_addr);
89084
89085 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
89086 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
89087 index fd26d04..0cea1b0 100644
89088 --- a/mm/process_vm_access.c
89089 +++ b/mm/process_vm_access.c
89090 @@ -13,6 +13,7 @@
89091 #include <linux/uio.h>
89092 #include <linux/sched.h>
89093 #include <linux/highmem.h>
89094 +#include <linux/security.h>
89095 #include <linux/ptrace.h>
89096 #include <linux/slab.h>
89097 #include <linux/syscalls.h>
89098 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89099 size_t iov_l_curr_offset = 0;
89100 ssize_t iov_len;
89101
89102 + return -ENOSYS; // PaX: until properly audited
89103 +
89104 /*
89105 * Work out how many pages of struct pages we're going to need
89106 * when eventually calling get_user_pages
89107 */
89108 for (i = 0; i < riovcnt; i++) {
89109 iov_len = rvec[i].iov_len;
89110 - if (iov_len > 0) {
89111 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
89112 - + iov_len)
89113 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
89114 - / PAGE_SIZE + 1;
89115 - nr_pages = max(nr_pages, nr_pages_iov);
89116 - }
89117 + if (iov_len <= 0)
89118 + continue;
89119 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
89120 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
89121 + nr_pages = max(nr_pages, nr_pages_iov);
89122 }
89123
89124 if (nr_pages == 0)
89125 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89126 goto free_proc_pages;
89127 }
89128
89129 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
89130 + rc = -EPERM;
89131 + goto put_task_struct;
89132 + }
89133 +
89134 mm = mm_access(task, PTRACE_MODE_ATTACH);
89135 if (!mm || IS_ERR(mm)) {
89136 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
89137 diff --git a/mm/rmap.c b/mm/rmap.c
89138 index b2e29ac..4168491 100644
89139 --- a/mm/rmap.c
89140 +++ b/mm/rmap.c
89141 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89142 struct anon_vma *anon_vma = vma->anon_vma;
89143 struct anon_vma_chain *avc;
89144
89145 +#ifdef CONFIG_PAX_SEGMEXEC
89146 + struct anon_vma_chain *avc_m = NULL;
89147 +#endif
89148 +
89149 might_sleep();
89150 if (unlikely(!anon_vma)) {
89151 struct mm_struct *mm = vma->vm_mm;
89152 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89153 if (!avc)
89154 goto out_enomem;
89155
89156 +#ifdef CONFIG_PAX_SEGMEXEC
89157 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
89158 + if (!avc_m)
89159 + goto out_enomem_free_avc;
89160 +#endif
89161 +
89162 anon_vma = find_mergeable_anon_vma(vma);
89163 allocated = NULL;
89164 if (!anon_vma) {
89165 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89166 /* page_table_lock to protect against threads */
89167 spin_lock(&mm->page_table_lock);
89168 if (likely(!vma->anon_vma)) {
89169 +
89170 +#ifdef CONFIG_PAX_SEGMEXEC
89171 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
89172 +
89173 + if (vma_m) {
89174 + BUG_ON(vma_m->anon_vma);
89175 + vma_m->anon_vma = anon_vma;
89176 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
89177 + avc_m = NULL;
89178 + }
89179 +#endif
89180 +
89181 vma->anon_vma = anon_vma;
89182 anon_vma_chain_link(vma, avc, anon_vma);
89183 allocated = NULL;
89184 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89185
89186 if (unlikely(allocated))
89187 put_anon_vma(allocated);
89188 +
89189 +#ifdef CONFIG_PAX_SEGMEXEC
89190 + if (unlikely(avc_m))
89191 + anon_vma_chain_free(avc_m);
89192 +#endif
89193 +
89194 if (unlikely(avc))
89195 anon_vma_chain_free(avc);
89196 }
89197 return 0;
89198
89199 out_enomem_free_avc:
89200 +
89201 +#ifdef CONFIG_PAX_SEGMEXEC
89202 + if (avc_m)
89203 + anon_vma_chain_free(avc_m);
89204 +#endif
89205 +
89206 anon_vma_chain_free(avc);
89207 out_enomem:
89208 return -ENOMEM;
89209 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89210 * Attach the anon_vmas from src to dst.
89211 * Returns 0 on success, -ENOMEM on failure.
89212 */
89213 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89214 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89215 {
89216 struct anon_vma_chain *avc, *pavc;
89217 struct anon_vma *root = NULL;
89218 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89219 * the corresponding VMA in the parent process is attached to.
89220 * Returns 0 on success, non-zero on failure.
89221 */
89222 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89223 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89224 {
89225 struct anon_vma_chain *avc;
89226 struct anon_vma *anon_vma;
89227 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89228 void __init anon_vma_init(void)
89229 {
89230 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89231 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89232 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89233 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89234 + anon_vma_ctor);
89235 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89236 + SLAB_PANIC|SLAB_NO_SANITIZE);
89237 }
89238
89239 /*
89240 diff --git a/mm/shmem.c b/mm/shmem.c
89241 index e43dc55..930e3a2 100644
89242 --- a/mm/shmem.c
89243 +++ b/mm/shmem.c
89244 @@ -33,7 +33,7 @@
89245 #include <linux/swap.h>
89246 #include <linux/aio.h>
89247
89248 -static struct vfsmount *shm_mnt;
89249 +struct vfsmount *shm_mnt;
89250
89251 #ifdef CONFIG_SHMEM
89252 /*
89253 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89254 #define BOGO_DIRENT_SIZE 20
89255
89256 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89257 -#define SHORT_SYMLINK_LEN 128
89258 +#define SHORT_SYMLINK_LEN 64
89259
89260 /*
89261 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89262 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89263 static int shmem_xattr_validate(const char *name)
89264 {
89265 struct { const char *prefix; size_t len; } arr[] = {
89266 +
89267 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89268 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89269 +#endif
89270 +
89271 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89272 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89273 };
89274 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89275 if (err)
89276 return err;
89277
89278 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89279 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89280 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89281 + return -EOPNOTSUPP;
89282 + if (size > 8)
89283 + return -EINVAL;
89284 + }
89285 +#endif
89286 +
89287 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89288 }
89289
89290 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89291 int err = -ENOMEM;
89292
89293 /* Round up to L1_CACHE_BYTES to resist false sharing */
89294 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89295 - L1_CACHE_BYTES), GFP_KERNEL);
89296 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89297 if (!sbinfo)
89298 return -ENOMEM;
89299
89300 diff --git a/mm/slab.c b/mm/slab.c
89301 index 2580db0..0523956 100644
89302 --- a/mm/slab.c
89303 +++ b/mm/slab.c
89304 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89305 if ((x)->max_freeable < i) \
89306 (x)->max_freeable = i; \
89307 } while (0)
89308 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89309 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89310 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89311 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89312 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89313 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89314 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89315 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89316 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89317 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89318 #else
89319 #define STATS_INC_ACTIVE(x) do { } while (0)
89320 #define STATS_DEC_ACTIVE(x) do { } while (0)
89321 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89322 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89323 #define STATS_INC_FREEHIT(x) do { } while (0)
89324 #define STATS_INC_FREEMISS(x) do { } while (0)
89325 +#define STATS_INC_SANITIZED(x) do { } while (0)
89326 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89327 #endif
89328
89329 #if DEBUG
89330 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89331 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89332 */
89333 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89334 - const struct slab *slab, void *obj)
89335 + const struct slab *slab, const void *obj)
89336 {
89337 u32 offset = (obj - slab->s_mem);
89338 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89339 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89340 */
89341
89342 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89343 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89344 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89345
89346 if (INDEX_AC != INDEX_NODE)
89347 kmalloc_caches[INDEX_NODE] =
89348 create_kmalloc_cache("kmalloc-node",
89349 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89350 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89351
89352 slab_early_init = 0;
89353
89354 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89355 struct array_cache *ac = cpu_cache_get(cachep);
89356
89357 check_irq_off();
89358 +
89359 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89360 + if (pax_sanitize_slab) {
89361 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89362 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89363 +
89364 + if (cachep->ctor)
89365 + cachep->ctor(objp);
89366 +
89367 + STATS_INC_SANITIZED(cachep);
89368 + } else
89369 + STATS_INC_NOT_SANITIZED(cachep);
89370 + }
89371 +#endif
89372 +
89373 kmemleak_free_recursive(objp, cachep->flags);
89374 objp = cache_free_debugcheck(cachep, objp, caller);
89375
89376 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89377
89378 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89379 return;
89380 + VM_BUG_ON(!virt_addr_valid(objp));
89381 local_irq_save(flags);
89382 kfree_debugcheck(objp);
89383 c = virt_to_cache(objp);
89384 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89385 }
89386 /* cpu stats */
89387 {
89388 - unsigned long allochit = atomic_read(&cachep->allochit);
89389 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89390 - unsigned long freehit = atomic_read(&cachep->freehit);
89391 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89392 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89393 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89394 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89395 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89396
89397 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89398 allochit, allocmiss, freehit, freemiss);
89399 }
89400 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89401 + {
89402 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89403 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89404 +
89405 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89406 + }
89407 +#endif
89408 #endif
89409 }
89410
89411 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89412 static int __init slab_proc_init(void)
89413 {
89414 #ifdef CONFIG_DEBUG_SLAB_LEAK
89415 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89416 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89417 #endif
89418 return 0;
89419 }
89420 module_init(slab_proc_init);
89421 #endif
89422
89423 +bool is_usercopy_object(const void *ptr)
89424 +{
89425 + struct page *page;
89426 + struct kmem_cache *cachep;
89427 +
89428 + if (ZERO_OR_NULL_PTR(ptr))
89429 + return false;
89430 +
89431 + if (!slab_is_available())
89432 + return false;
89433 +
89434 + if (!virt_addr_valid(ptr))
89435 + return false;
89436 +
89437 + page = virt_to_head_page(ptr);
89438 +
89439 + if (!PageSlab(page))
89440 + return false;
89441 +
89442 + cachep = page->slab_cache;
89443 + return cachep->flags & SLAB_USERCOPY;
89444 +}
89445 +
89446 +#ifdef CONFIG_PAX_USERCOPY
89447 +const char *check_heap_object(const void *ptr, unsigned long n)
89448 +{
89449 + struct page *page;
89450 + struct kmem_cache *cachep;
89451 + struct slab *slabp;
89452 + unsigned int objnr;
89453 + unsigned long offset;
89454 +
89455 + if (ZERO_OR_NULL_PTR(ptr))
89456 + return "<null>";
89457 +
89458 + if (!virt_addr_valid(ptr))
89459 + return NULL;
89460 +
89461 + page = virt_to_head_page(ptr);
89462 +
89463 + if (!PageSlab(page))
89464 + return NULL;
89465 +
89466 + cachep = page->slab_cache;
89467 + if (!(cachep->flags & SLAB_USERCOPY))
89468 + return cachep->name;
89469 +
89470 + slabp = page->slab_page;
89471 + objnr = obj_to_index(cachep, slabp, ptr);
89472 + BUG_ON(objnr >= cachep->num);
89473 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89474 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89475 + return NULL;
89476 +
89477 + return cachep->name;
89478 +}
89479 +#endif
89480 +
89481 /**
89482 * ksize - get the actual amount of memory allocated for a given object
89483 * @objp: Pointer to the object
89484 diff --git a/mm/slab.h b/mm/slab.h
89485 index a535033..2f98fe5 100644
89486 --- a/mm/slab.h
89487 +++ b/mm/slab.h
89488 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89489 /* The slab cache that manages slab cache information */
89490 extern struct kmem_cache *kmem_cache;
89491
89492 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89493 +#ifdef CONFIG_X86_64
89494 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89495 +#else
89496 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89497 +#endif
89498 +extern bool pax_sanitize_slab;
89499 +#endif
89500 +
89501 unsigned long calculate_alignment(unsigned long flags,
89502 unsigned long align, unsigned long size);
89503
89504 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89505
89506 /* Legal flag mask for kmem_cache_create(), for various configurations */
89507 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89508 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89509 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89510 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89511
89512 #if defined(CONFIG_DEBUG_SLAB)
89513 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89514 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89515 return s;
89516
89517 page = virt_to_head_page(x);
89518 +
89519 + BUG_ON(!PageSlab(page));
89520 +
89521 cachep = page->slab_cache;
89522 if (slab_equal_or_root(cachep, s))
89523 return cachep;
89524 diff --git a/mm/slab_common.c b/mm/slab_common.c
89525 index 538bade..36fed99 100644
89526 --- a/mm/slab_common.c
89527 +++ b/mm/slab_common.c
89528 @@ -22,11 +22,22 @@
89529
89530 #include "slab.h"
89531
89532 -enum slab_state slab_state;
89533 +enum slab_state slab_state __read_only;
89534 LIST_HEAD(slab_caches);
89535 DEFINE_MUTEX(slab_mutex);
89536 struct kmem_cache *kmem_cache;
89537
89538 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89539 +bool pax_sanitize_slab __read_only = true;
89540 +static int __init pax_sanitize_slab_setup(char *str)
89541 +{
89542 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89543 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89544 + return 1;
89545 +}
89546 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89547 +#endif
89548 +
89549 #ifdef CONFIG_DEBUG_VM
89550 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89551 size_t size)
89552 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89553
89554 err = __kmem_cache_create(s, flags);
89555 if (!err) {
89556 - s->refcount = 1;
89557 + atomic_set(&s->refcount, 1);
89558 list_add(&s->list, &slab_caches);
89559 memcg_cache_list_add(memcg, s);
89560 } else {
89561 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89562
89563 get_online_cpus();
89564 mutex_lock(&slab_mutex);
89565 - s->refcount--;
89566 - if (!s->refcount) {
89567 + if (atomic_dec_and_test(&s->refcount)) {
89568 list_del(&s->list);
89569
89570 if (!__kmem_cache_shutdown(s)) {
89571 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89572 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89573 name, size, err);
89574
89575 - s->refcount = -1; /* Exempt from merging for now */
89576 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89577 }
89578
89579 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89580 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89581
89582 create_boot_cache(s, name, size, flags);
89583 list_add(&s->list, &slab_caches);
89584 - s->refcount = 1;
89585 + atomic_set(&s->refcount, 1);
89586 return s;
89587 }
89588
89589 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89590 EXPORT_SYMBOL(kmalloc_dma_caches);
89591 #endif
89592
89593 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89594 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89595 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89596 +#endif
89597 +
89598 /*
89599 * Conversion table for small slabs sizes / 8 to the index in the
89600 * kmalloc array. This is necessary for slabs < 192 since we have non power
89601 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89602 return kmalloc_dma_caches[index];
89603
89604 #endif
89605 +
89606 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89607 + if (unlikely((flags & GFP_USERCOPY)))
89608 + return kmalloc_usercopy_caches[index];
89609 +
89610 +#endif
89611 +
89612 return kmalloc_caches[index];
89613 }
89614
89615 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89616 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89617 if (!kmalloc_caches[i]) {
89618 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89619 - 1 << i, flags);
89620 + 1 << i, SLAB_USERCOPY | flags);
89621 }
89622
89623 /*
89624 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89625 * earlier power of two caches
89626 */
89627 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89628 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89629 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89630
89631 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89632 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89633 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89634 }
89635
89636 /* Kmalloc array is now usable */
89637 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89638 }
89639 }
89640 #endif
89641 +
89642 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89643 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89644 + struct kmem_cache *s = kmalloc_caches[i];
89645 +
89646 + if (s) {
89647 + int size = kmalloc_size(i);
89648 + char *n = kasprintf(GFP_NOWAIT,
89649 + "usercopy-kmalloc-%d", size);
89650 +
89651 + BUG_ON(!n);
89652 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89653 + size, SLAB_USERCOPY | flags);
89654 + }
89655 + }
89656 +#endif
89657 +
89658 }
89659 #endif /* !CONFIG_SLOB */
89660
89661 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89662 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89663 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89664 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89665 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89666 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89667 +#endif
89668 #endif
89669 seq_putc(m, '\n');
89670 }
89671 diff --git a/mm/slob.c b/mm/slob.c
89672 index 91bd3f2..e2f549e 100644
89673 --- a/mm/slob.c
89674 +++ b/mm/slob.c
89675 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89676 /*
89677 * Return the size of a slob block.
89678 */
89679 -static slobidx_t slob_units(slob_t *s)
89680 +static slobidx_t slob_units(const slob_t *s)
89681 {
89682 if (s->units > 0)
89683 return s->units;
89684 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89685 /*
89686 * Return the next free slob block pointer after this one.
89687 */
89688 -static slob_t *slob_next(slob_t *s)
89689 +static slob_t *slob_next(const slob_t *s)
89690 {
89691 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89692 slobidx_t next;
89693 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89694 /*
89695 * Returns true if s is the last free block in its page.
89696 */
89697 -static int slob_last(slob_t *s)
89698 +static int slob_last(const slob_t *s)
89699 {
89700 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89701 }
89702
89703 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89704 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89705 {
89706 - void *page;
89707 + struct page *page;
89708
89709 #ifdef CONFIG_NUMA
89710 if (node != NUMA_NO_NODE)
89711 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89712 if (!page)
89713 return NULL;
89714
89715 - return page_address(page);
89716 + __SetPageSlab(page);
89717 + return page;
89718 }
89719
89720 -static void slob_free_pages(void *b, int order)
89721 +static void slob_free_pages(struct page *sp, int order)
89722 {
89723 if (current->reclaim_state)
89724 current->reclaim_state->reclaimed_slab += 1 << order;
89725 - free_pages((unsigned long)b, order);
89726 + __ClearPageSlab(sp);
89727 + page_mapcount_reset(sp);
89728 + sp->private = 0;
89729 + __free_pages(sp, order);
89730 }
89731
89732 /*
89733 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89734
89735 /* Not enough space: must allocate a new page */
89736 if (!b) {
89737 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89738 - if (!b)
89739 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89740 + if (!sp)
89741 return NULL;
89742 - sp = virt_to_page(b);
89743 - __SetPageSlab(sp);
89744 + b = page_address(sp);
89745
89746 spin_lock_irqsave(&slob_lock, flags);
89747 sp->units = SLOB_UNITS(PAGE_SIZE);
89748 sp->freelist = b;
89749 + sp->private = 0;
89750 INIT_LIST_HEAD(&sp->list);
89751 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89752 set_slob_page_free(sp, slob_list);
89753 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89754 if (slob_page_free(sp))
89755 clear_slob_page_free(sp);
89756 spin_unlock_irqrestore(&slob_lock, flags);
89757 - __ClearPageSlab(sp);
89758 - page_mapcount_reset(sp);
89759 - slob_free_pages(b, 0);
89760 + slob_free_pages(sp, 0);
89761 return;
89762 }
89763
89764 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89765 + if (pax_sanitize_slab)
89766 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89767 +#endif
89768 +
89769 if (!slob_page_free(sp)) {
89770 /* This slob page is about to become partially free. Easy! */
89771 sp->units = units;
89772 @@ -424,11 +431,10 @@ out:
89773 */
89774
89775 static __always_inline void *
89776 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89777 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89778 {
89779 - unsigned int *m;
89780 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89781 - void *ret;
89782 + slob_t *m;
89783 + void *ret = NULL;
89784
89785 gfp &= gfp_allowed_mask;
89786
89787 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89788
89789 if (!m)
89790 return NULL;
89791 - *m = size;
89792 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89793 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89794 + m[0].units = size;
89795 + m[1].units = align;
89796 ret = (void *)m + align;
89797
89798 trace_kmalloc_node(caller, ret,
89799 size, size + align, gfp, node);
89800 } else {
89801 unsigned int order = get_order(size);
89802 + struct page *page;
89803
89804 if (likely(order))
89805 gfp |= __GFP_COMP;
89806 - ret = slob_new_pages(gfp, order, node);
89807 + page = slob_new_pages(gfp, order, node);
89808 + if (page) {
89809 + ret = page_address(page);
89810 + page->private = size;
89811 + }
89812
89813 trace_kmalloc_node(caller, ret,
89814 size, PAGE_SIZE << order, gfp, node);
89815 }
89816
89817 - kmemleak_alloc(ret, size, 1, gfp);
89818 + return ret;
89819 +}
89820 +
89821 +static __always_inline void *
89822 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89823 +{
89824 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89825 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89826 +
89827 + if (!ZERO_OR_NULL_PTR(ret))
89828 + kmemleak_alloc(ret, size, 1, gfp);
89829 return ret;
89830 }
89831
89832 @@ -493,34 +517,112 @@ void kfree(const void *block)
89833 return;
89834 kmemleak_free(block);
89835
89836 + VM_BUG_ON(!virt_addr_valid(block));
89837 sp = virt_to_page(block);
89838 - if (PageSlab(sp)) {
89839 + VM_BUG_ON(!PageSlab(sp));
89840 + if (!sp->private) {
89841 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89842 - unsigned int *m = (unsigned int *)(block - align);
89843 - slob_free(m, *m + align);
89844 - } else
89845 + slob_t *m = (slob_t *)(block - align);
89846 + slob_free(m, m[0].units + align);
89847 + } else {
89848 + __ClearPageSlab(sp);
89849 + page_mapcount_reset(sp);
89850 + sp->private = 0;
89851 __free_pages(sp, compound_order(sp));
89852 + }
89853 }
89854 EXPORT_SYMBOL(kfree);
89855
89856 +bool is_usercopy_object(const void *ptr)
89857 +{
89858 + if (!slab_is_available())
89859 + return false;
89860 +
89861 + // PAX: TODO
89862 +
89863 + return false;
89864 +}
89865 +
89866 +#ifdef CONFIG_PAX_USERCOPY
89867 +const char *check_heap_object(const void *ptr, unsigned long n)
89868 +{
89869 + struct page *page;
89870 + const slob_t *free;
89871 + const void *base;
89872 + unsigned long flags;
89873 +
89874 + if (ZERO_OR_NULL_PTR(ptr))
89875 + return "<null>";
89876 +
89877 + if (!virt_addr_valid(ptr))
89878 + return NULL;
89879 +
89880 + page = virt_to_head_page(ptr);
89881 + if (!PageSlab(page))
89882 + return NULL;
89883 +
89884 + if (page->private) {
89885 + base = page;
89886 + if (base <= ptr && n <= page->private - (ptr - base))
89887 + return NULL;
89888 + return "<slob>";
89889 + }
89890 +
89891 + /* some tricky double walking to find the chunk */
89892 + spin_lock_irqsave(&slob_lock, flags);
89893 + base = (void *)((unsigned long)ptr & PAGE_MASK);
89894 + free = page->freelist;
89895 +
89896 + while (!slob_last(free) && (void *)free <= ptr) {
89897 + base = free + slob_units(free);
89898 + free = slob_next(free);
89899 + }
89900 +
89901 + while (base < (void *)free) {
89902 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
89903 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
89904 + int offset;
89905 +
89906 + if (ptr < base + align)
89907 + break;
89908 +
89909 + offset = ptr - base - align;
89910 + if (offset >= m) {
89911 + base += size;
89912 + continue;
89913 + }
89914 +
89915 + if (n > m - offset)
89916 + break;
89917 +
89918 + spin_unlock_irqrestore(&slob_lock, flags);
89919 + return NULL;
89920 + }
89921 +
89922 + spin_unlock_irqrestore(&slob_lock, flags);
89923 + return "<slob>";
89924 +}
89925 +#endif
89926 +
89927 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
89928 size_t ksize(const void *block)
89929 {
89930 struct page *sp;
89931 int align;
89932 - unsigned int *m;
89933 + slob_t *m;
89934
89935 BUG_ON(!block);
89936 if (unlikely(block == ZERO_SIZE_PTR))
89937 return 0;
89938
89939 sp = virt_to_page(block);
89940 - if (unlikely(!PageSlab(sp)))
89941 - return PAGE_SIZE << compound_order(sp);
89942 + VM_BUG_ON(!PageSlab(sp));
89943 + if (sp->private)
89944 + return sp->private;
89945
89946 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89947 - m = (unsigned int *)(block - align);
89948 - return SLOB_UNITS(*m) * SLOB_UNIT;
89949 + m = (slob_t *)(block - align);
89950 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
89951 }
89952 EXPORT_SYMBOL(ksize);
89953
89954 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
89955
89956 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
89957 {
89958 - void *b;
89959 + void *b = NULL;
89960
89961 flags &= gfp_allowed_mask;
89962
89963 lockdep_trace_alloc(flags);
89964
89965 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89966 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
89967 +#else
89968 if (c->size < PAGE_SIZE) {
89969 b = slob_alloc(c->size, flags, c->align, node);
89970 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
89971 SLOB_UNITS(c->size) * SLOB_UNIT,
89972 flags, node);
89973 } else {
89974 - b = slob_new_pages(flags, get_order(c->size), node);
89975 + struct page *sp;
89976 +
89977 + sp = slob_new_pages(flags, get_order(c->size), node);
89978 + if (sp) {
89979 + b = page_address(sp);
89980 + sp->private = c->size;
89981 + }
89982 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
89983 PAGE_SIZE << get_order(c->size),
89984 flags, node);
89985 }
89986 +#endif
89987
89988 if (b && c->ctor)
89989 c->ctor(b);
89990 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
89991
89992 static void __kmem_cache_free(void *b, int size)
89993 {
89994 - if (size < PAGE_SIZE)
89995 + struct page *sp;
89996 +
89997 + sp = virt_to_page(b);
89998 + BUG_ON(!PageSlab(sp));
89999 + if (!sp->private)
90000 slob_free(b, size);
90001 else
90002 - slob_free_pages(b, get_order(size));
90003 + slob_free_pages(sp, get_order(size));
90004 }
90005
90006 static void kmem_rcu_free(struct rcu_head *head)
90007 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
90008
90009 void kmem_cache_free(struct kmem_cache *c, void *b)
90010 {
90011 + int size = c->size;
90012 +
90013 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90014 + if (size + c->align < PAGE_SIZE) {
90015 + size += c->align;
90016 + b -= c->align;
90017 + }
90018 +#endif
90019 +
90020 kmemleak_free_recursive(b, c->flags);
90021 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
90022 struct slob_rcu *slob_rcu;
90023 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
90024 - slob_rcu->size = c->size;
90025 + slob_rcu = b + (size - sizeof(struct slob_rcu));
90026 + slob_rcu->size = size;
90027 call_rcu(&slob_rcu->head, kmem_rcu_free);
90028 } else {
90029 - __kmem_cache_free(b, c->size);
90030 + __kmem_cache_free(b, size);
90031 }
90032
90033 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90034 + trace_kfree(_RET_IP_, b);
90035 +#else
90036 trace_kmem_cache_free(_RET_IP_, b);
90037 +#endif
90038 +
90039 }
90040 EXPORT_SYMBOL(kmem_cache_free);
90041
90042 diff --git a/mm/slub.c b/mm/slub.c
90043 index e3ba1f2..bd45dac 100644
90044 --- a/mm/slub.c
90045 +++ b/mm/slub.c
90046 @@ -207,7 +207,7 @@ struct track {
90047
90048 enum track_item { TRACK_ALLOC, TRACK_FREE };
90049
90050 -#ifdef CONFIG_SYSFS
90051 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90052 static int sysfs_slab_add(struct kmem_cache *);
90053 static int sysfs_slab_alias(struct kmem_cache *, const char *);
90054 static void sysfs_slab_remove(struct kmem_cache *);
90055 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
90056 if (!t->addr)
90057 return;
90058
90059 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
90060 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
90061 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
90062 #ifdef CONFIG_STACKTRACE
90063 {
90064 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
90065
90066 slab_free_hook(s, x);
90067
90068 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90069 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
90070 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
90071 + if (s->ctor)
90072 + s->ctor(x);
90073 + }
90074 +#endif
90075 +
90076 redo:
90077 /*
90078 * Determine the currently cpus per cpu slab.
90079 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
90080 * Merge control. If this is set then no merging of slab caches will occur.
90081 * (Could be removed. This was introduced to pacify the merge skeptics.)
90082 */
90083 -static int slub_nomerge;
90084 +static int slub_nomerge = 1;
90085
90086 /*
90087 * Calculate the order of allocation given an slab object size.
90088 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
90089 s->inuse = size;
90090
90091 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
90092 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90093 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
90094 +#endif
90095 s->ctor)) {
90096 /*
90097 * Relocate free pointer after the object if it is not
90098 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
90099 EXPORT_SYMBOL(__kmalloc_node);
90100 #endif
90101
90102 +bool is_usercopy_object(const void *ptr)
90103 +{
90104 + struct page *page;
90105 + struct kmem_cache *s;
90106 +
90107 + if (ZERO_OR_NULL_PTR(ptr))
90108 + return false;
90109 +
90110 + if (!slab_is_available())
90111 + return false;
90112 +
90113 + if (!virt_addr_valid(ptr))
90114 + return false;
90115 +
90116 + page = virt_to_head_page(ptr);
90117 +
90118 + if (!PageSlab(page))
90119 + return false;
90120 +
90121 + s = page->slab_cache;
90122 + return s->flags & SLAB_USERCOPY;
90123 +}
90124 +
90125 +#ifdef CONFIG_PAX_USERCOPY
90126 +const char *check_heap_object(const void *ptr, unsigned long n)
90127 +{
90128 + struct page *page;
90129 + struct kmem_cache *s;
90130 + unsigned long offset;
90131 +
90132 + if (ZERO_OR_NULL_PTR(ptr))
90133 + return "<null>";
90134 +
90135 + if (!virt_addr_valid(ptr))
90136 + return NULL;
90137 +
90138 + page = virt_to_head_page(ptr);
90139 +
90140 + if (!PageSlab(page))
90141 + return NULL;
90142 +
90143 + s = page->slab_cache;
90144 + if (!(s->flags & SLAB_USERCOPY))
90145 + return s->name;
90146 +
90147 + offset = (ptr - page_address(page)) % s->size;
90148 + if (offset <= s->object_size && n <= s->object_size - offset)
90149 + return NULL;
90150 +
90151 + return s->name;
90152 +}
90153 +#endif
90154 +
90155 size_t ksize(const void *object)
90156 {
90157 struct page *page;
90158 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
90159 if (unlikely(ZERO_OR_NULL_PTR(x)))
90160 return;
90161
90162 + VM_BUG_ON(!virt_addr_valid(x));
90163 page = virt_to_head_page(x);
90164 if (unlikely(!PageSlab(page))) {
90165 BUG_ON(!PageCompound(page));
90166 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
90167 /*
90168 * We may have set a slab to be unmergeable during bootstrap.
90169 */
90170 - if (s->refcount < 0)
90171 + if (atomic_read(&s->refcount) < 0)
90172 return 1;
90173
90174 return 0;
90175 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90176
90177 s = find_mergeable(memcg, size, align, flags, name, ctor);
90178 if (s) {
90179 - s->refcount++;
90180 + atomic_inc(&s->refcount);
90181 /*
90182 * Adjust the object sizes so that we clear
90183 * the complete object on kzalloc.
90184 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90185 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
90186
90187 if (sysfs_slab_alias(s, name)) {
90188 - s->refcount--;
90189 + atomic_dec(&s->refcount);
90190 s = NULL;
90191 }
90192 }
90193 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
90194 }
90195 #endif
90196
90197 -#ifdef CONFIG_SYSFS
90198 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90199 static int count_inuse(struct page *page)
90200 {
90201 return page->inuse;
90202 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
90203 validate_slab_cache(kmalloc_caches[9]);
90204 }
90205 #else
90206 -#ifdef CONFIG_SYSFS
90207 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90208 static void resiliency_test(void) {};
90209 #endif
90210 #endif
90211
90212 -#ifdef CONFIG_SYSFS
90213 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90214 enum slab_stat_type {
90215 SL_ALL, /* All slabs */
90216 SL_PARTIAL, /* Only partially allocated slabs */
90217 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90218
90219 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90220 {
90221 - return sprintf(buf, "%d\n", s->refcount - 1);
90222 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90223 }
90224 SLAB_ATTR_RO(aliases);
90225
90226 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90227 SLAB_ATTR_RO(cache_dma);
90228 #endif
90229
90230 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90231 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90232 +{
90233 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90234 +}
90235 +SLAB_ATTR_RO(usercopy);
90236 +#endif
90237 +
90238 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90239 {
90240 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90241 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90242 #ifdef CONFIG_ZONE_DMA
90243 &cache_dma_attr.attr,
90244 #endif
90245 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90246 + &usercopy_attr.attr,
90247 +#endif
90248 #ifdef CONFIG_NUMA
90249 &remote_node_defrag_ratio_attr.attr,
90250 #endif
90251 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90252 return name;
90253 }
90254
90255 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90256 static int sysfs_slab_add(struct kmem_cache *s)
90257 {
90258 int err;
90259 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90260 }
90261
90262 s->kobj.kset = slab_kset;
90263 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90264 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90265 if (err) {
90266 kobject_put(&s->kobj);
90267 return err;
90268 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90269 kobject_del(&s->kobj);
90270 kobject_put(&s->kobj);
90271 }
90272 +#endif
90273
90274 /*
90275 * Need to buffer aliases during bootup until sysfs becomes
90276 @@ -5213,6 +5291,7 @@ struct saved_alias {
90277
90278 static struct saved_alias *alias_list;
90279
90280 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90281 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90282 {
90283 struct saved_alias *al;
90284 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90285 alias_list = al;
90286 return 0;
90287 }
90288 +#endif
90289
90290 static int __init slab_sysfs_init(void)
90291 {
90292 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90293 index 27eeab3..7c3f7f2 100644
90294 --- a/mm/sparse-vmemmap.c
90295 +++ b/mm/sparse-vmemmap.c
90296 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90297 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90298 if (!p)
90299 return NULL;
90300 - pud_populate(&init_mm, pud, p);
90301 + pud_populate_kernel(&init_mm, pud, p);
90302 }
90303 return pud;
90304 }
90305 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90306 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90307 if (!p)
90308 return NULL;
90309 - pgd_populate(&init_mm, pgd, p);
90310 + pgd_populate_kernel(&init_mm, pgd, p);
90311 }
90312 return pgd;
90313 }
90314 diff --git a/mm/sparse.c b/mm/sparse.c
90315 index 308d503..3dbbd04 100644
90316 --- a/mm/sparse.c
90317 +++ b/mm/sparse.c
90318 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90319
90320 for (i = 0; i < PAGES_PER_SECTION; i++) {
90321 if (PageHWPoison(&memmap[i])) {
90322 - atomic_long_sub(1, &num_poisoned_pages);
90323 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90324 ClearPageHWPoison(&memmap[i]);
90325 }
90326 }
90327 diff --git a/mm/swap.c b/mm/swap.c
90328 index 62b78a6..0bcf28f 100644
90329 --- a/mm/swap.c
90330 +++ b/mm/swap.c
90331 @@ -31,6 +31,7 @@
90332 #include <linux/memcontrol.h>
90333 #include <linux/gfp.h>
90334 #include <linux/uio.h>
90335 +#include <linux/hugetlb.h>
90336
90337 #include "internal.h"
90338
90339 @@ -76,6 +77,8 @@ static void __put_compound_page(struct page *page)
90340
90341 __page_cache_release(page);
90342 dtor = get_compound_page_dtor(page);
90343 + if (!PageHuge(page))
90344 + BUG_ON(dtor != free_compound_page);
90345 (*dtor)(page);
90346 }
90347
90348 diff --git a/mm/swapfile.c b/mm/swapfile.c
90349 index 6cf2e60..d204b3e 100644
90350 --- a/mm/swapfile.c
90351 +++ b/mm/swapfile.c
90352 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90353
90354 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90355 /* Activity counter to indicate that a swapon or swapoff has occurred */
90356 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90357 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90358
90359 static inline unsigned char swap_count(unsigned char ent)
90360 {
90361 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90362 }
90363 filp_close(swap_file, NULL);
90364 err = 0;
90365 - atomic_inc(&proc_poll_event);
90366 + atomic_inc_unchecked(&proc_poll_event);
90367 wake_up_interruptible(&proc_poll_wait);
90368
90369 out_dput:
90370 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90371
90372 poll_wait(file, &proc_poll_wait, wait);
90373
90374 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90375 - seq->poll_event = atomic_read(&proc_poll_event);
90376 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90377 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90378 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90379 }
90380
90381 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90382 return ret;
90383
90384 seq = file->private_data;
90385 - seq->poll_event = atomic_read(&proc_poll_event);
90386 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90387 return 0;
90388 }
90389
90390 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90391 (frontswap_map) ? "FS" : "");
90392
90393 mutex_unlock(&swapon_mutex);
90394 - atomic_inc(&proc_poll_event);
90395 + atomic_inc_unchecked(&proc_poll_event);
90396 wake_up_interruptible(&proc_poll_wait);
90397
90398 if (S_ISREG(inode->i_mode))
90399 diff --git a/mm/util.c b/mm/util.c
90400 index 7441c41..c3de793 100644
90401 --- a/mm/util.c
90402 +++ b/mm/util.c
90403 @@ -294,6 +294,12 @@ done:
90404 void arch_pick_mmap_layout(struct mm_struct *mm)
90405 {
90406 mm->mmap_base = TASK_UNMAPPED_BASE;
90407 +
90408 +#ifdef CONFIG_PAX_RANDMMAP
90409 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90410 + mm->mmap_base += mm->delta_mmap;
90411 +#endif
90412 +
90413 mm->get_unmapped_area = arch_get_unmapped_area;
90414 }
90415 #endif
90416 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90417 index 13a5495..6707d97 100644
90418 --- a/mm/vmalloc.c
90419 +++ b/mm/vmalloc.c
90420 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90421
90422 pte = pte_offset_kernel(pmd, addr);
90423 do {
90424 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90425 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90426 +
90427 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90428 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90429 + BUG_ON(!pte_exec(*pte));
90430 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90431 + continue;
90432 + }
90433 +#endif
90434 +
90435 + {
90436 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90437 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90438 + }
90439 } while (pte++, addr += PAGE_SIZE, addr != end);
90440 }
90441
90442 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90443 pte = pte_alloc_kernel(pmd, addr);
90444 if (!pte)
90445 return -ENOMEM;
90446 +
90447 + pax_open_kernel();
90448 do {
90449 struct page *page = pages[*nr];
90450
90451 - if (WARN_ON(!pte_none(*pte)))
90452 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90453 + if (pgprot_val(prot) & _PAGE_NX)
90454 +#endif
90455 +
90456 + if (!pte_none(*pte)) {
90457 + pax_close_kernel();
90458 + WARN_ON(1);
90459 return -EBUSY;
90460 - if (WARN_ON(!page))
90461 + }
90462 + if (!page) {
90463 + pax_close_kernel();
90464 + WARN_ON(1);
90465 return -ENOMEM;
90466 + }
90467 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90468 (*nr)++;
90469 } while (pte++, addr += PAGE_SIZE, addr != end);
90470 + pax_close_kernel();
90471 return 0;
90472 }
90473
90474 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90475 pmd_t *pmd;
90476 unsigned long next;
90477
90478 - pmd = pmd_alloc(&init_mm, pud, addr);
90479 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90480 if (!pmd)
90481 return -ENOMEM;
90482 do {
90483 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90484 pud_t *pud;
90485 unsigned long next;
90486
90487 - pud = pud_alloc(&init_mm, pgd, addr);
90488 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90489 if (!pud)
90490 return -ENOMEM;
90491 do {
90492 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90493 if (addr >= MODULES_VADDR && addr < MODULES_END)
90494 return 1;
90495 #endif
90496 +
90497 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90498 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90499 + return 1;
90500 +#endif
90501 +
90502 return is_vmalloc_addr(x);
90503 }
90504
90505 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90506
90507 if (!pgd_none(*pgd)) {
90508 pud_t *pud = pud_offset(pgd, addr);
90509 +#ifdef CONFIG_X86
90510 + if (!pud_large(*pud))
90511 +#endif
90512 if (!pud_none(*pud)) {
90513 pmd_t *pmd = pmd_offset(pud, addr);
90514 +#ifdef CONFIG_X86
90515 + if (!pmd_large(*pmd))
90516 +#endif
90517 if (!pmd_none(*pmd)) {
90518 pte_t *ptep, pte;
90519
90520 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90521 * Allocate a region of KVA of the specified size and alignment, within the
90522 * vstart and vend.
90523 */
90524 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90525 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90526 unsigned long align,
90527 unsigned long vstart, unsigned long vend,
90528 int node, gfp_t gfp_mask)
90529 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90530 struct vm_struct *area;
90531
90532 BUG_ON(in_interrupt());
90533 +
90534 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90535 + if (flags & VM_KERNEXEC) {
90536 + if (start != VMALLOC_START || end != VMALLOC_END)
90537 + return NULL;
90538 + start = (unsigned long)MODULES_EXEC_VADDR;
90539 + end = (unsigned long)MODULES_EXEC_END;
90540 + }
90541 +#endif
90542 +
90543 if (flags & VM_IOREMAP)
90544 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90545
90546 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90547 if (count > totalram_pages)
90548 return NULL;
90549
90550 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90551 + if (!(pgprot_val(prot) & _PAGE_NX))
90552 + flags |= VM_KERNEXEC;
90553 +#endif
90554 +
90555 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90556 __builtin_return_address(0));
90557 if (!area)
90558 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90559 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90560 goto fail;
90561
90562 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90563 + if (!(pgprot_val(prot) & _PAGE_NX))
90564 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90565 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90566 + else
90567 +#endif
90568 +
90569 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90570 start, end, node, gfp_mask, caller);
90571 if (!area)
90572 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90573 * For tight control over page level allocator and protection flags
90574 * use __vmalloc() instead.
90575 */
90576 -
90577 void *vmalloc_exec(unsigned long size)
90578 {
90579 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90580 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90581 NUMA_NO_NODE, __builtin_return_address(0));
90582 }
90583
90584 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90585 {
90586 struct vm_struct *area;
90587
90588 + BUG_ON(vma->vm_mirror);
90589 +
90590 size = PAGE_ALIGN(size);
90591
90592 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90593 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90594 v->addr, v->addr + v->size, v->size);
90595
90596 if (v->caller)
90597 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90598 + seq_printf(m, " %pK", v->caller);
90599 +#else
90600 seq_printf(m, " %pS", v->caller);
90601 +#endif
90602
90603 if (v->nr_pages)
90604 seq_printf(m, " pages=%d", v->nr_pages);
90605 diff --git a/mm/vmstat.c b/mm/vmstat.c
90606 index 20c2ef4..15e7ab7 100644
90607 --- a/mm/vmstat.c
90608 +++ b/mm/vmstat.c
90609 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90610 *
90611 * vm_stat contains the global counters
90612 */
90613 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90614 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90615 EXPORT_SYMBOL(vm_stat);
90616
90617 #ifdef CONFIG_SMP
90618 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90619 v = p->vm_stat_diff[i];
90620 p->vm_stat_diff[i] = 0;
90621 local_irq_restore(flags);
90622 - atomic_long_add(v, &zone->vm_stat[i]);
90623 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90624 global_diff[i] += v;
90625 #ifdef CONFIG_NUMA
90626 /* 3 seconds idle till flush */
90627 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90628
90629 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90630 if (global_diff[i])
90631 - atomic_long_add(global_diff[i], &vm_stat[i]);
90632 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90633 }
90634
90635 /*
90636 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90637 if (pset->vm_stat_diff[i]) {
90638 int v = pset->vm_stat_diff[i];
90639 pset->vm_stat_diff[i] = 0;
90640 - atomic_long_add(v, &zone->vm_stat[i]);
90641 - atomic_long_add(v, &vm_stat[i]);
90642 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90643 + atomic_long_add_unchecked(v, &vm_stat[i]);
90644 }
90645 }
90646 #endif
90647 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90648 start_cpu_timer(cpu);
90649 #endif
90650 #ifdef CONFIG_PROC_FS
90651 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90652 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90653 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90654 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90655 + {
90656 + mode_t gr_mode = S_IRUGO;
90657 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90658 + gr_mode = S_IRUSR;
90659 +#endif
90660 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90661 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90662 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90663 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90664 +#else
90665 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90666 +#endif
90667 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90668 + }
90669 #endif
90670 return 0;
90671 }
90672 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90673 index 2fb2d88..8c06e40 100644
90674 --- a/net/8021q/vlan.c
90675 +++ b/net/8021q/vlan.c
90676 @@ -469,7 +469,7 @@ out:
90677 return NOTIFY_DONE;
90678 }
90679
90680 -static struct notifier_block vlan_notifier_block __read_mostly = {
90681 +static struct notifier_block vlan_notifier_block = {
90682 .notifier_call = vlan_device_event,
90683 };
90684
90685 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90686 err = -EPERM;
90687 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90688 break;
90689 - if ((args.u.name_type >= 0) &&
90690 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90691 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90692 struct vlan_net *vn;
90693
90694 vn = net_generic(net, vlan_net_id);
90695 diff --git a/net/9p/mod.c b/net/9p/mod.c
90696 index 6ab36ae..6f1841b 100644
90697 --- a/net/9p/mod.c
90698 +++ b/net/9p/mod.c
90699 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90700 void v9fs_register_trans(struct p9_trans_module *m)
90701 {
90702 spin_lock(&v9fs_trans_lock);
90703 - list_add_tail(&m->list, &v9fs_trans_list);
90704 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90705 spin_unlock(&v9fs_trans_lock);
90706 }
90707 EXPORT_SYMBOL(v9fs_register_trans);
90708 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90709 void v9fs_unregister_trans(struct p9_trans_module *m)
90710 {
90711 spin_lock(&v9fs_trans_lock);
90712 - list_del_init(&m->list);
90713 + pax_list_del_init((struct list_head *)&m->list);
90714 spin_unlock(&v9fs_trans_lock);
90715 }
90716 EXPORT_SYMBOL(v9fs_unregister_trans);
90717 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90718 index 3ffda1b..fceac96 100644
90719 --- a/net/9p/trans_fd.c
90720 +++ b/net/9p/trans_fd.c
90721 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90722 oldfs = get_fs();
90723 set_fs(get_ds());
90724 /* The cast to a user pointer is valid due to the set_fs() */
90725 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90726 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90727 set_fs(oldfs);
90728
90729 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90730 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90731 index 876fbe8..8bbea9f 100644
90732 --- a/net/atm/atm_misc.c
90733 +++ b/net/atm/atm_misc.c
90734 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90735 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90736 return 1;
90737 atm_return(vcc, truesize);
90738 - atomic_inc(&vcc->stats->rx_drop);
90739 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90740 return 0;
90741 }
90742 EXPORT_SYMBOL(atm_charge);
90743 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90744 }
90745 }
90746 atm_return(vcc, guess);
90747 - atomic_inc(&vcc->stats->rx_drop);
90748 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90749 return NULL;
90750 }
90751 EXPORT_SYMBOL(atm_alloc_charge);
90752 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90753
90754 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90755 {
90756 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90757 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90758 __SONET_ITEMS
90759 #undef __HANDLE_ITEM
90760 }
90761 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90762
90763 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90764 {
90765 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90766 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90767 __SONET_ITEMS
90768 #undef __HANDLE_ITEM
90769 }
90770 diff --git a/net/atm/lec.h b/net/atm/lec.h
90771 index 4149db1..f2ab682 100644
90772 --- a/net/atm/lec.h
90773 +++ b/net/atm/lec.h
90774 @@ -48,7 +48,7 @@ struct lane2_ops {
90775 const u8 *tlvs, u32 sizeoftlvs);
90776 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90777 const u8 *tlvs, u32 sizeoftlvs);
90778 -};
90779 +} __no_const;
90780
90781 /*
90782 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90783 diff --git a/net/atm/proc.c b/net/atm/proc.c
90784 index bbb6461..cf04016 100644
90785 --- a/net/atm/proc.c
90786 +++ b/net/atm/proc.c
90787 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90788 const struct k_atm_aal_stats *stats)
90789 {
90790 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90791 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90792 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90793 - atomic_read(&stats->rx_drop));
90794 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90795 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90796 + atomic_read_unchecked(&stats->rx_drop));
90797 }
90798
90799 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90800 diff --git a/net/atm/resources.c b/net/atm/resources.c
90801 index 0447d5d..3cf4728 100644
90802 --- a/net/atm/resources.c
90803 +++ b/net/atm/resources.c
90804 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90805 static void copy_aal_stats(struct k_atm_aal_stats *from,
90806 struct atm_aal_stats *to)
90807 {
90808 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90809 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90810 __AAL_STAT_ITEMS
90811 #undef __HANDLE_ITEM
90812 }
90813 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90814 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90815 struct atm_aal_stats *to)
90816 {
90817 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90818 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90819 __AAL_STAT_ITEMS
90820 #undef __HANDLE_ITEM
90821 }
90822 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90823 index 919a5ce..cc6b444 100644
90824 --- a/net/ax25/sysctl_net_ax25.c
90825 +++ b/net/ax25/sysctl_net_ax25.c
90826 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90827 {
90828 char path[sizeof("net/ax25/") + IFNAMSIZ];
90829 int k;
90830 - struct ctl_table *table;
90831 + ctl_table_no_const *table;
90832
90833 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90834 if (!table)
90835 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90836 index 62da527..aa27535 100644
90837 --- a/net/batman-adv/bat_iv_ogm.c
90838 +++ b/net/batman-adv/bat_iv_ogm.c
90839 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90840
90841 /* randomize initial seqno to avoid collision */
90842 get_random_bytes(&random_seqno, sizeof(random_seqno));
90843 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90844 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90845
90846 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90847 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
90848 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
90849 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
90850
90851 /* change sequence number to network order */
90852 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
90853 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
90854 batadv_ogm_packet->seqno = htonl(seqno);
90855 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
90856 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
90857
90858 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
90859 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
90860 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
90861 return;
90862
90863 /* could be changed by schedule_own_packet() */
90864 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
90865 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
90866
90867 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
90868 has_directlink_flag = 1;
90869 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
90870 index c478e6b..469fd2f 100644
90871 --- a/net/batman-adv/hard-interface.c
90872 +++ b/net/batman-adv/hard-interface.c
90873 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
90874 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
90875 dev_add_pack(&hard_iface->batman_adv_ptype);
90876
90877 - atomic_set(&hard_iface->frag_seqno, 1);
90878 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
90879 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
90880 hard_iface->net_dev->name);
90881
90882 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
90883 index 0f04e1c..9c0ac11 100644
90884 --- a/net/batman-adv/soft-interface.c
90885 +++ b/net/batman-adv/soft-interface.c
90886 @@ -260,7 +260,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
90887 primary_if->net_dev->dev_addr, ETH_ALEN);
90888
90889 /* set broadcast sequence number */
90890 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
90891 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
90892 bcast_packet->seqno = htonl(seqno);
90893
90894 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
90895 @@ -479,7 +479,7 @@ static int batadv_softif_init_late(struct net_device *dev)
90896 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
90897
90898 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
90899 - atomic_set(&bat_priv->bcast_seqno, 1);
90900 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
90901 atomic_set(&bat_priv->tt.vn, 0);
90902 atomic_set(&bat_priv->tt.local_changes, 0);
90903 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
90904 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
90905 index b2c94e1..3d47e07 100644
90906 --- a/net/batman-adv/types.h
90907 +++ b/net/batman-adv/types.h
90908 @@ -51,7 +51,7 @@
90909 struct batadv_hard_iface_bat_iv {
90910 unsigned char *ogm_buff;
90911 int ogm_buff_len;
90912 - atomic_t ogm_seqno;
90913 + atomic_unchecked_t ogm_seqno;
90914 };
90915
90916 /**
90917 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
90918 int16_t if_num;
90919 char if_status;
90920 struct net_device *net_dev;
90921 - atomic_t frag_seqno;
90922 + atomic_unchecked_t frag_seqno;
90923 uint8_t num_bcasts;
90924 struct kobject *hardif_obj;
90925 atomic_t refcount;
90926 @@ -560,7 +560,7 @@ struct batadv_priv {
90927 #ifdef CONFIG_BATMAN_ADV_DEBUG
90928 atomic_t log_level;
90929 #endif
90930 - atomic_t bcast_seqno;
90931 + atomic_unchecked_t bcast_seqno;
90932 atomic_t bcast_queue_left;
90933 atomic_t batman_queue_left;
90934 char num_ifaces;
90935 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
90936 index 857e1b8..5ad07b2 100644
90937 --- a/net/batman-adv/unicast.c
90938 +++ b/net/batman-adv/unicast.c
90939 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
90940 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
90941 frag2->flags = large_tail;
90942
90943 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
90944 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
90945 frag1->seqno = htons(seqno - 1);
90946 frag2->seqno = htons(seqno);
90947
90948 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
90949 index 9bd7d95..6c4884f 100644
90950 --- a/net/bluetooth/hci_sock.c
90951 +++ b/net/bluetooth/hci_sock.c
90952 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
90953 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
90954 }
90955
90956 - len = min_t(unsigned int, len, sizeof(uf));
90957 + len = min((size_t)len, sizeof(uf));
90958 if (copy_from_user(&uf, optval, len)) {
90959 err = -EFAULT;
90960 break;
90961 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
90962 index 8c3499b..2661c6a 100644
90963 --- a/net/bluetooth/l2cap_core.c
90964 +++ b/net/bluetooth/l2cap_core.c
90965 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
90966 break;
90967
90968 case L2CAP_CONF_RFC:
90969 - if (olen == sizeof(rfc))
90970 - memcpy(&rfc, (void *)val, olen);
90971 + if (olen != sizeof(rfc))
90972 + break;
90973 +
90974 + memcpy(&rfc, (void *)val, olen);
90975
90976 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
90977 rfc.mode != chan->mode)
90978 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
90979 index 0098af8..fb5a31f 100644
90980 --- a/net/bluetooth/l2cap_sock.c
90981 +++ b/net/bluetooth/l2cap_sock.c
90982 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
90983 struct sock *sk = sock->sk;
90984 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
90985 struct l2cap_options opts;
90986 - int len, err = 0;
90987 + int err = 0;
90988 + size_t len = optlen;
90989 u32 opt;
90990
90991 BT_DBG("sk %p", sk);
90992 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
90993 opts.max_tx = chan->max_tx;
90994 opts.txwin_size = chan->tx_win;
90995
90996 - len = min_t(unsigned int, sizeof(opts), optlen);
90997 + len = min(sizeof(opts), len);
90998 if (copy_from_user((char *) &opts, optval, len)) {
90999 err = -EFAULT;
91000 break;
91001 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91002 struct bt_security sec;
91003 struct bt_power pwr;
91004 struct l2cap_conn *conn;
91005 - int len, err = 0;
91006 + int err = 0;
91007 + size_t len = optlen;
91008 u32 opt;
91009
91010 BT_DBG("sk %p", sk);
91011 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91012
91013 sec.level = BT_SECURITY_LOW;
91014
91015 - len = min_t(unsigned int, sizeof(sec), optlen);
91016 + len = min(sizeof(sec), len);
91017 if (copy_from_user((char *) &sec, optval, len)) {
91018 err = -EFAULT;
91019 break;
91020 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91021
91022 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
91023
91024 - len = min_t(unsigned int, sizeof(pwr), optlen);
91025 + len = min(sizeof(pwr), len);
91026 if (copy_from_user((char *) &pwr, optval, len)) {
91027 err = -EFAULT;
91028 break;
91029 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
91030 index 30b3721..c1bd0a0 100644
91031 --- a/net/bluetooth/rfcomm/sock.c
91032 +++ b/net/bluetooth/rfcomm/sock.c
91033 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91034 struct sock *sk = sock->sk;
91035 struct bt_security sec;
91036 int err = 0;
91037 - size_t len;
91038 + size_t len = optlen;
91039 u32 opt;
91040
91041 BT_DBG("sk %p", sk);
91042 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91043
91044 sec.level = BT_SECURITY_LOW;
91045
91046 - len = min_t(unsigned int, sizeof(sec), optlen);
91047 + len = min(sizeof(sec), len);
91048 if (copy_from_user((char *) &sec, optval, len)) {
91049 err = -EFAULT;
91050 break;
91051 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
91052 index b6e44ad..5b0d514 100644
91053 --- a/net/bluetooth/rfcomm/tty.c
91054 +++ b/net/bluetooth/rfcomm/tty.c
91055 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
91056 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
91057
91058 spin_lock_irqsave(&dev->port.lock, flags);
91059 - if (dev->port.count > 0) {
91060 + if (atomic_read(&dev->port.count) > 0) {
91061 spin_unlock_irqrestore(&dev->port.lock, flags);
91062 return;
91063 }
91064 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
91065 return -ENODEV;
91066
91067 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
91068 - dev->channel, dev->port.count);
91069 + dev->channel, atomic_read(&dev->port.count));
91070
91071 spin_lock_irqsave(&dev->port.lock, flags);
91072 - if (++dev->port.count > 1) {
91073 + if (atomic_inc_return(&dev->port.count) > 1) {
91074 spin_unlock_irqrestore(&dev->port.lock, flags);
91075 return 0;
91076 }
91077 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
91078 return;
91079
91080 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
91081 - dev->port.count);
91082 + atomic_read(&dev->port.count));
91083
91084 spin_lock_irqsave(&dev->port.lock, flags);
91085 - if (!--dev->port.count) {
91086 + if (!atomic_dec_return(&dev->port.count)) {
91087 spin_unlock_irqrestore(&dev->port.lock, flags);
91088 if (dev->tty_dev->parent)
91089 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
91090 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
91091 index ac78024..161a80c 100644
91092 --- a/net/bridge/netfilter/ebtables.c
91093 +++ b/net/bridge/netfilter/ebtables.c
91094 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91095 tmp.valid_hooks = t->table->valid_hooks;
91096 }
91097 mutex_unlock(&ebt_mutex);
91098 - if (copy_to_user(user, &tmp, *len) != 0){
91099 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
91100 BUGPRINT("c2u Didn't work\n");
91101 ret = -EFAULT;
91102 break;
91103 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91104 goto out;
91105 tmp.valid_hooks = t->valid_hooks;
91106
91107 - if (copy_to_user(user, &tmp, *len) != 0) {
91108 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91109 ret = -EFAULT;
91110 break;
91111 }
91112 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91113 tmp.entries_size = t->table->entries_size;
91114 tmp.valid_hooks = t->table->valid_hooks;
91115
91116 - if (copy_to_user(user, &tmp, *len) != 0) {
91117 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91118 ret = -EFAULT;
91119 break;
91120 }
91121 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
91122 index 2bd4b58..0dc30a1 100644
91123 --- a/net/caif/cfctrl.c
91124 +++ b/net/caif/cfctrl.c
91125 @@ -10,6 +10,7 @@
91126 #include <linux/spinlock.h>
91127 #include <linux/slab.h>
91128 #include <linux/pkt_sched.h>
91129 +#include <linux/sched.h>
91130 #include <net/caif/caif_layer.h>
91131 #include <net/caif/cfpkt.h>
91132 #include <net/caif/cfctrl.h>
91133 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
91134 memset(&dev_info, 0, sizeof(dev_info));
91135 dev_info.id = 0xff;
91136 cfsrvl_init(&this->serv, 0, &dev_info, false);
91137 - atomic_set(&this->req_seq_no, 1);
91138 - atomic_set(&this->rsp_seq_no, 1);
91139 + atomic_set_unchecked(&this->req_seq_no, 1);
91140 + atomic_set_unchecked(&this->rsp_seq_no, 1);
91141 this->serv.layer.receive = cfctrl_recv;
91142 sprintf(this->serv.layer.name, "ctrl");
91143 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
91144 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
91145 struct cfctrl_request_info *req)
91146 {
91147 spin_lock_bh(&ctrl->info_list_lock);
91148 - atomic_inc(&ctrl->req_seq_no);
91149 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
91150 + atomic_inc_unchecked(&ctrl->req_seq_no);
91151 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
91152 list_add_tail(&req->list, &ctrl->list);
91153 spin_unlock_bh(&ctrl->info_list_lock);
91154 }
91155 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
91156 if (p != first)
91157 pr_warn("Requests are not received in order\n");
91158
91159 - atomic_set(&ctrl->rsp_seq_no,
91160 + atomic_set_unchecked(&ctrl->rsp_seq_no,
91161 p->sequence_no);
91162 list_del(&p->list);
91163 goto out;
91164 diff --git a/net/can/af_can.c b/net/can/af_can.c
91165 index 3ab8dd2..b9aef13 100644
91166 --- a/net/can/af_can.c
91167 +++ b/net/can/af_can.c
91168 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91169 };
91170
91171 /* notifier block for netdevice event */
91172 -static struct notifier_block can_netdev_notifier __read_mostly = {
91173 +static struct notifier_block can_netdev_notifier = {
91174 .notifier_call = can_notifier,
91175 };
91176
91177 diff --git a/net/can/gw.c b/net/can/gw.c
91178 index 2f291f9..98c986a 100644
91179 --- a/net/can/gw.c
91180 +++ b/net/can/gw.c
91181 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91182 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91183
91184 static HLIST_HEAD(cgw_list);
91185 -static struct notifier_block notifier;
91186
91187 static struct kmem_cache *cgw_cache __read_mostly;
91188
91189 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91190 return err;
91191 }
91192
91193 +static struct notifier_block notifier = {
91194 + .notifier_call = cgw_notifier
91195 +};
91196 +
91197 static __init int cgw_module_init(void)
91198 {
91199 /* sanitize given module parameter */
91200 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91201 return -ENOMEM;
91202
91203 /* set notifier */
91204 - notifier.notifier_call = cgw_notifier;
91205 register_netdevice_notifier(&notifier);
91206
91207 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91208 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91209 index eb0a46a..5f3bae8 100644
91210 --- a/net/ceph/messenger.c
91211 +++ b/net/ceph/messenger.c
91212 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91213 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91214
91215 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91216 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91217 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91218
91219 static struct page *zero_page; /* used in certain error cases */
91220
91221 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91222 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91223 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91224
91225 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91226 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91227 s = addr_str[i];
91228
91229 switch (ss->ss_family) {
91230 diff --git a/net/compat.c b/net/compat.c
91231 index f0a1ba6..0541331 100644
91232 --- a/net/compat.c
91233 +++ b/net/compat.c
91234 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91235 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
91236 __get_user(kmsg->msg_flags, &umsg->msg_flags))
91237 return -EFAULT;
91238 - kmsg->msg_name = compat_ptr(tmp1);
91239 - kmsg->msg_iov = compat_ptr(tmp2);
91240 - kmsg->msg_control = compat_ptr(tmp3);
91241 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91242 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91243 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91244 return 0;
91245 }
91246
91247 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91248
91249 if (kern_msg->msg_namelen) {
91250 if (mode == VERIFY_READ) {
91251 - int err = move_addr_to_kernel(kern_msg->msg_name,
91252 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91253 kern_msg->msg_namelen,
91254 kern_address);
91255 if (err < 0)
91256 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91257 kern_msg->msg_name = NULL;
91258
91259 tot_len = iov_from_user_compat_to_kern(kern_iov,
91260 - (struct compat_iovec __user *)kern_msg->msg_iov,
91261 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91262 kern_msg->msg_iovlen);
91263 if (tot_len >= 0)
91264 kern_msg->msg_iov = kern_iov;
91265 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91266
91267 #define CMSG_COMPAT_FIRSTHDR(msg) \
91268 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91269 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91270 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91271 (struct compat_cmsghdr __user *)NULL)
91272
91273 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91274 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91275 (ucmlen) <= (unsigned long) \
91276 ((mhdr)->msg_controllen - \
91277 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91278 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91279
91280 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91281 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91282 {
91283 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91284 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91285 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91286 msg->msg_controllen)
91287 return NULL;
91288 return (struct compat_cmsghdr __user *)ptr;
91289 @@ -219,7 +219,7 @@ Efault:
91290
91291 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91292 {
91293 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91294 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91295 struct compat_cmsghdr cmhdr;
91296 struct compat_timeval ctv;
91297 struct compat_timespec cts[3];
91298 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91299
91300 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91301 {
91302 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91303 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91304 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91305 int fdnum = scm->fp->count;
91306 struct file **fp = scm->fp->fp;
91307 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91308 return -EFAULT;
91309 old_fs = get_fs();
91310 set_fs(KERNEL_DS);
91311 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91312 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91313 set_fs(old_fs);
91314
91315 return err;
91316 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91317 len = sizeof(ktime);
91318 old_fs = get_fs();
91319 set_fs(KERNEL_DS);
91320 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91321 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91322 set_fs(old_fs);
91323
91324 if (!err) {
91325 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91326 case MCAST_JOIN_GROUP:
91327 case MCAST_LEAVE_GROUP:
91328 {
91329 - struct compat_group_req __user *gr32 = (void *)optval;
91330 + struct compat_group_req __user *gr32 = (void __user *)optval;
91331 struct group_req __user *kgr =
91332 compat_alloc_user_space(sizeof(struct group_req));
91333 u32 interface;
91334 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91335 case MCAST_BLOCK_SOURCE:
91336 case MCAST_UNBLOCK_SOURCE:
91337 {
91338 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91339 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91340 struct group_source_req __user *kgsr = compat_alloc_user_space(
91341 sizeof(struct group_source_req));
91342 u32 interface;
91343 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91344 }
91345 case MCAST_MSFILTER:
91346 {
91347 - struct compat_group_filter __user *gf32 = (void *)optval;
91348 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91349 struct group_filter __user *kgf;
91350 u32 interface, fmode, numsrc;
91351
91352 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91353 char __user *optval, int __user *optlen,
91354 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91355 {
91356 - struct compat_group_filter __user *gf32 = (void *)optval;
91357 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91358 struct group_filter __user *kgf;
91359 int __user *koptlen;
91360 u32 interface, fmode, numsrc;
91361 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91362
91363 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91364 return -EINVAL;
91365 - if (copy_from_user(a, args, nas[call]))
91366 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91367 return -EFAULT;
91368 a0 = a[0];
91369 a1 = a[1];
91370 diff --git a/net/core/datagram.c b/net/core/datagram.c
91371 index 8ab48cd..57b1a80 100644
91372 --- a/net/core/datagram.c
91373 +++ b/net/core/datagram.c
91374 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91375 }
91376
91377 kfree_skb(skb);
91378 - atomic_inc(&sk->sk_drops);
91379 + atomic_inc_unchecked(&sk->sk_drops);
91380 sk_mem_reclaim_partial(sk);
91381
91382 return err;
91383 diff --git a/net/core/dev.c b/net/core/dev.c
91384 index 26755dd..5020ced 100644
91385 --- a/net/core/dev.c
91386 +++ b/net/core/dev.c
91387 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91388 {
91389 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91390 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91391 - atomic_long_inc(&dev->rx_dropped);
91392 + atomic_long_inc_unchecked(&dev->rx_dropped);
91393 kfree_skb(skb);
91394 return NET_RX_DROP;
91395 }
91396 }
91397
91398 if (unlikely(!is_skb_forwardable(dev, skb))) {
91399 - atomic_long_inc(&dev->rx_dropped);
91400 + atomic_long_inc_unchecked(&dev->rx_dropped);
91401 kfree_skb(skb);
91402 return NET_RX_DROP;
91403 }
91404 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91405
91406 struct dev_gso_cb {
91407 void (*destructor)(struct sk_buff *skb);
91408 -};
91409 +} __no_const;
91410
91411 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91412
91413 @@ -3206,7 +3206,7 @@ enqueue:
91414
91415 local_irq_restore(flags);
91416
91417 - atomic_long_inc(&skb->dev->rx_dropped);
91418 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91419 kfree_skb(skb);
91420 return NET_RX_DROP;
91421 }
91422 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91423 }
91424 EXPORT_SYMBOL(netif_rx_ni);
91425
91426 -static void net_tx_action(struct softirq_action *h)
91427 +static void net_tx_action(void)
91428 {
91429 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91430
91431 @@ -3612,7 +3612,7 @@ ncls:
91432 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91433 } else {
91434 drop:
91435 - atomic_long_inc(&skb->dev->rx_dropped);
91436 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91437 kfree_skb(skb);
91438 /* Jamal, now you will not able to escape explaining
91439 * me how you were going to use this. :-)
91440 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91441 }
91442 EXPORT_SYMBOL(netif_napi_del);
91443
91444 -static void net_rx_action(struct softirq_action *h)
91445 +static void net_rx_action(void)
91446 {
91447 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91448 unsigned long time_limit = jiffies + 2;
91449 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91450 } else {
91451 netdev_stats_to_stats64(storage, &dev->stats);
91452 }
91453 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91454 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91455 return storage;
91456 }
91457 EXPORT_SYMBOL(dev_get_stats);
91458 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91459 index 5b7d0e1..cb960fc 100644
91460 --- a/net/core/dev_ioctl.c
91461 +++ b/net/core/dev_ioctl.c
91462 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91463 if (no_module && capable(CAP_NET_ADMIN))
91464 no_module = request_module("netdev-%s", name);
91465 if (no_module && capable(CAP_SYS_MODULE)) {
91466 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91467 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91468 +#else
91469 if (!request_module("%s", name))
91470 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91471 name);
91472 +#endif
91473 }
91474 }
91475 EXPORT_SYMBOL(dev_load);
91476 diff --git a/net/core/flow.c b/net/core/flow.c
91477 index dfa602c..3103d88 100644
91478 --- a/net/core/flow.c
91479 +++ b/net/core/flow.c
91480 @@ -61,7 +61,7 @@ struct flow_cache {
91481 struct timer_list rnd_timer;
91482 };
91483
91484 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91485 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91486 EXPORT_SYMBOL(flow_cache_genid);
91487 static struct flow_cache flow_cache_global;
91488 static struct kmem_cache *flow_cachep __read_mostly;
91489 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91490
91491 static int flow_entry_valid(struct flow_cache_entry *fle)
91492 {
91493 - if (atomic_read(&flow_cache_genid) != fle->genid)
91494 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91495 return 0;
91496 if (fle->object && !fle->object->ops->check(fle->object))
91497 return 0;
91498 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91499 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91500 fcp->hash_count++;
91501 }
91502 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91503 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91504 flo = fle->object;
91505 if (!flo)
91506 goto ret_object;
91507 @@ -279,7 +279,7 @@ nocache:
91508 }
91509 flo = resolver(net, key, family, dir, flo, ctx);
91510 if (fle) {
91511 - fle->genid = atomic_read(&flow_cache_genid);
91512 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91513 if (!IS_ERR(flo))
91514 fle->object = flo;
91515 else
91516 diff --git a/net/core/iovec.c b/net/core/iovec.c
91517 index de178e4..1dabd8b 100644
91518 --- a/net/core/iovec.c
91519 +++ b/net/core/iovec.c
91520 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91521 if (m->msg_namelen) {
91522 if (mode == VERIFY_READ) {
91523 void __user *namep;
91524 - namep = (void __user __force *) m->msg_name;
91525 + namep = (void __force_user *) m->msg_name;
91526 err = move_addr_to_kernel(namep, m->msg_namelen,
91527 address);
91528 if (err < 0)
91529 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91530 }
91531
91532 size = m->msg_iovlen * sizeof(struct iovec);
91533 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91534 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91535 return -EFAULT;
91536
91537 m->msg_iov = iov;
91538 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91539 index 60533db..14842cc 100644
91540 --- a/net/core/neighbour.c
91541 +++ b/net/core/neighbour.c
91542 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91543 void __user *buffer, size_t *lenp, loff_t *ppos)
91544 {
91545 int size, ret;
91546 - struct ctl_table tmp = *ctl;
91547 + ctl_table_no_const tmp = *ctl;
91548
91549 tmp.extra1 = &zero;
91550 tmp.extra2 = &unres_qlen_max;
91551 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91552 index 2bf8329..7960607 100644
91553 --- a/net/core/net-procfs.c
91554 +++ b/net/core/net-procfs.c
91555 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91556 else
91557 seq_printf(seq, "%04x", ntohs(pt->type));
91558
91559 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91560 + seq_printf(seq, " %-8s %pf\n",
91561 + pt->dev ? pt->dev->name : "", NULL);
91562 +#else
91563 seq_printf(seq, " %-8s %pf\n",
91564 pt->dev ? pt->dev->name : "", pt->func);
91565 +#endif
91566 }
91567
91568 return 0;
91569 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91570 index 981fed3..536af34 100644
91571 --- a/net/core/net-sysfs.c
91572 +++ b/net/core/net-sysfs.c
91573 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91574 }
91575 EXPORT_SYMBOL(netdev_class_remove_file);
91576
91577 -int netdev_kobject_init(void)
91578 +int __init netdev_kobject_init(void)
91579 {
91580 kobj_ns_type_register(&net_ns_type_operations);
91581 return class_register(&net_class);
91582 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91583 index f9765203..9feaef8 100644
91584 --- a/net/core/net_namespace.c
91585 +++ b/net/core/net_namespace.c
91586 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91587 int error;
91588 LIST_HEAD(net_exit_list);
91589
91590 - list_add_tail(&ops->list, list);
91591 + pax_list_add_tail((struct list_head *)&ops->list, list);
91592 if (ops->init || (ops->id && ops->size)) {
91593 for_each_net(net) {
91594 error = ops_init(ops, net);
91595 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91596
91597 out_undo:
91598 /* If I have an error cleanup all namespaces I initialized */
91599 - list_del(&ops->list);
91600 + pax_list_del((struct list_head *)&ops->list);
91601 ops_exit_list(ops, &net_exit_list);
91602 ops_free_list(ops, &net_exit_list);
91603 return error;
91604 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91605 struct net *net;
91606 LIST_HEAD(net_exit_list);
91607
91608 - list_del(&ops->list);
91609 + pax_list_del((struct list_head *)&ops->list);
91610 for_each_net(net)
91611 list_add_tail(&net->exit_list, &net_exit_list);
91612 ops_exit_list(ops, &net_exit_list);
91613 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91614 mutex_lock(&net_mutex);
91615 error = register_pernet_operations(&pernet_list, ops);
91616 if (!error && (first_device == &pernet_list))
91617 - first_device = &ops->list;
91618 + first_device = (struct list_head *)&ops->list;
91619 mutex_unlock(&net_mutex);
91620 return error;
91621 }
91622 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91623 index 2c637e9..68c9087 100644
91624 --- a/net/core/netpoll.c
91625 +++ b/net/core/netpoll.c
91626 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91627 struct udphdr *udph;
91628 struct iphdr *iph;
91629 struct ethhdr *eth;
91630 - static atomic_t ip_ident;
91631 + static atomic_unchecked_t ip_ident;
91632 struct ipv6hdr *ip6h;
91633
91634 udp_len = len + sizeof(*udph);
91635 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91636 put_unaligned(0x45, (unsigned char *)iph);
91637 iph->tos = 0;
91638 put_unaligned(htons(ip_len), &(iph->tot_len));
91639 - iph->id = htons(atomic_inc_return(&ip_ident));
91640 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91641 iph->frag_off = 0;
91642 iph->ttl = 64;
91643 iph->protocol = IPPROTO_UDP;
91644 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91645 index ca198c1d1..125372f 100644
91646 --- a/net/core/rtnetlink.c
91647 +++ b/net/core/rtnetlink.c
91648 @@ -58,7 +58,7 @@ struct rtnl_link {
91649 rtnl_doit_func doit;
91650 rtnl_dumpit_func dumpit;
91651 rtnl_calcit_func calcit;
91652 -};
91653 +} __no_const;
91654
91655 static DEFINE_MUTEX(rtnl_mutex);
91656
91657 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91658 if (rtnl_link_ops_get(ops->kind))
91659 return -EEXIST;
91660
91661 - if (!ops->dellink)
91662 - ops->dellink = unregister_netdevice_queue;
91663 + if (!ops->dellink) {
91664 + pax_open_kernel();
91665 + *(void **)&ops->dellink = unregister_netdevice_queue;
91666 + pax_close_kernel();
91667 + }
91668
91669 - list_add_tail(&ops->list, &link_ops);
91670 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91671 return 0;
91672 }
91673 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91674 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91675 for_each_net(net) {
91676 __rtnl_kill_links(net, ops);
91677 }
91678 - list_del(&ops->list);
91679 + pax_list_del((struct list_head *)&ops->list);
91680 }
91681 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91682
91683 diff --git a/net/core/scm.c b/net/core/scm.c
91684 index b4da80b..98d6bdb 100644
91685 --- a/net/core/scm.c
91686 +++ b/net/core/scm.c
91687 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91688 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91689 {
91690 struct cmsghdr __user *cm
91691 - = (__force struct cmsghdr __user *)msg->msg_control;
91692 + = (struct cmsghdr __force_user *)msg->msg_control;
91693 struct cmsghdr cmhdr;
91694 int cmlen = CMSG_LEN(len);
91695 int err;
91696 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91697 err = -EFAULT;
91698 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91699 goto out;
91700 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91701 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91702 goto out;
91703 cmlen = CMSG_SPACE(len);
91704 if (msg->msg_controllen < cmlen)
91705 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91706 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91707 {
91708 struct cmsghdr __user *cm
91709 - = (__force struct cmsghdr __user*)msg->msg_control;
91710 + = (struct cmsghdr __force_user *)msg->msg_control;
91711
91712 int fdmax = 0;
91713 int fdnum = scm->fp->count;
91714 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91715 if (fdnum < fdmax)
91716 fdmax = fdnum;
91717
91718 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91719 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91720 i++, cmfptr++)
91721 {
91722 struct socket *sock;
91723 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91724 index 2c3d0f5..f5a326f 100644
91725 --- a/net/core/skbuff.c
91726 +++ b/net/core/skbuff.c
91727 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91728 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91729 sizeof(struct sk_buff),
91730 0,
91731 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91732 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91733 + SLAB_NO_SANITIZE,
91734 NULL);
91735 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91736 (2*sizeof(struct sk_buff)) +
91737 sizeof(atomic_t),
91738 0,
91739 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91740 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91741 + SLAB_NO_SANITIZE,
91742 NULL);
91743 }
91744
91745 diff --git a/net/core/sock.c b/net/core/sock.c
91746 index 2c097c5..bf72858 100644
91747 --- a/net/core/sock.c
91748 +++ b/net/core/sock.c
91749 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91750 struct sk_buff_head *list = &sk->sk_receive_queue;
91751
91752 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91753 - atomic_inc(&sk->sk_drops);
91754 + atomic_inc_unchecked(&sk->sk_drops);
91755 trace_sock_rcvqueue_full(sk, skb);
91756 return -ENOMEM;
91757 }
91758 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91759 return err;
91760
91761 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91762 - atomic_inc(&sk->sk_drops);
91763 + atomic_inc_unchecked(&sk->sk_drops);
91764 return -ENOBUFS;
91765 }
91766
91767 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91768 skb_dst_force(skb);
91769
91770 spin_lock_irqsave(&list->lock, flags);
91771 - skb->dropcount = atomic_read(&sk->sk_drops);
91772 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91773 __skb_queue_tail(list, skb);
91774 spin_unlock_irqrestore(&list->lock, flags);
91775
91776 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91777 skb->dev = NULL;
91778
91779 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91780 - atomic_inc(&sk->sk_drops);
91781 + atomic_inc_unchecked(&sk->sk_drops);
91782 goto discard_and_relse;
91783 }
91784 if (nested)
91785 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91786 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91787 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91788 bh_unlock_sock(sk);
91789 - atomic_inc(&sk->sk_drops);
91790 + atomic_inc_unchecked(&sk->sk_drops);
91791 goto discard_and_relse;
91792 }
91793
91794 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91795 struct timeval tm;
91796 } v;
91797
91798 - int lv = sizeof(int);
91799 - int len;
91800 + unsigned int lv = sizeof(int);
91801 + unsigned int len;
91802
91803 if (get_user(len, optlen))
91804 return -EFAULT;
91805 - if (len < 0)
91806 + if (len > INT_MAX)
91807 return -EINVAL;
91808
91809 memset(&v, 0, sizeof(v));
91810 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91811
91812 case SO_PEERNAME:
91813 {
91814 - char address[128];
91815 + char address[_K_SS_MAXSIZE];
91816
91817 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
91818 return -ENOTCONN;
91819 - if (lv < len)
91820 + if (lv < len || sizeof address < len)
91821 return -EINVAL;
91822 if (copy_to_user(optval, address, len))
91823 return -EFAULT;
91824 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91825
91826 if (len > lv)
91827 len = lv;
91828 - if (copy_to_user(optval, &v, len))
91829 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
91830 return -EFAULT;
91831 lenout:
91832 if (put_user(len, optlen))
91833 @@ -2303,7 +2303,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
91834 */
91835 smp_wmb();
91836 atomic_set(&sk->sk_refcnt, 1);
91837 - atomic_set(&sk->sk_drops, 0);
91838 + atomic_set_unchecked(&sk->sk_drops, 0);
91839 }
91840 EXPORT_SYMBOL(sock_init_data);
91841
91842 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
91843 index a0e9cf6..ef7f9ed 100644
91844 --- a/net/core/sock_diag.c
91845 +++ b/net/core/sock_diag.c
91846 @@ -9,26 +9,33 @@
91847 #include <linux/inet_diag.h>
91848 #include <linux/sock_diag.h>
91849
91850 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
91851 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
91852 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
91853 static DEFINE_MUTEX(sock_diag_table_mutex);
91854
91855 int sock_diag_check_cookie(void *sk, __u32 *cookie)
91856 {
91857 +#ifndef CONFIG_GRKERNSEC_HIDESYM
91858 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
91859 cookie[1] != INET_DIAG_NOCOOKIE) &&
91860 ((u32)(unsigned long)sk != cookie[0] ||
91861 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
91862 return -ESTALE;
91863 else
91864 +#endif
91865 return 0;
91866 }
91867 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
91868
91869 void sock_diag_save_cookie(void *sk, __u32 *cookie)
91870 {
91871 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91872 + cookie[0] = 0;
91873 + cookie[1] = 0;
91874 +#else
91875 cookie[0] = (u32)(unsigned long)sk;
91876 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
91877 +#endif
91878 }
91879 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
91880
91881 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
91882 mutex_lock(&sock_diag_table_mutex);
91883 if (sock_diag_handlers[hndl->family])
91884 err = -EBUSY;
91885 - else
91886 + else {
91887 + pax_open_kernel();
91888 sock_diag_handlers[hndl->family] = hndl;
91889 + pax_close_kernel();
91890 + }
91891 mutex_unlock(&sock_diag_table_mutex);
91892
91893 return err;
91894 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
91895
91896 mutex_lock(&sock_diag_table_mutex);
91897 BUG_ON(sock_diag_handlers[family] != hnld);
91898 + pax_open_kernel();
91899 sock_diag_handlers[family] = NULL;
91900 + pax_close_kernel();
91901 mutex_unlock(&sock_diag_table_mutex);
91902 }
91903 EXPORT_SYMBOL_GPL(sock_diag_unregister);
91904 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
91905 index 31107ab..ae03d5a 100644
91906 --- a/net/core/sysctl_net_core.c
91907 +++ b/net/core/sysctl_net_core.c
91908 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
91909 {
91910 unsigned int orig_size, size;
91911 int ret, i;
91912 - struct ctl_table tmp = {
91913 + ctl_table_no_const tmp = {
91914 .data = &size,
91915 .maxlen = sizeof(size),
91916 .mode = table->mode
91917 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
91918
91919 static __net_init int sysctl_core_net_init(struct net *net)
91920 {
91921 - struct ctl_table *tbl;
91922 + ctl_table_no_const *tbl = NULL;
91923
91924 net->core.sysctl_somaxconn = SOMAXCONN;
91925
91926 - tbl = netns_core_table;
91927 if (!net_eq(net, &init_net)) {
91928 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
91929 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
91930 if (tbl == NULL)
91931 goto err_dup;
91932
91933 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
91934 if (net->user_ns != &init_user_ns) {
91935 tbl[0].procname = NULL;
91936 }
91937 - }
91938 -
91939 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
91940 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
91941 + } else
91942 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
91943 if (net->core.sysctl_hdr == NULL)
91944 goto err_reg;
91945
91946 return 0;
91947
91948 err_reg:
91949 - if (tbl != netns_core_table)
91950 - kfree(tbl);
91951 + kfree(tbl);
91952 err_dup:
91953 return -ENOMEM;
91954 }
91955 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
91956 kfree(tbl);
91957 }
91958
91959 -static __net_initdata struct pernet_operations sysctl_core_ops = {
91960 +static __net_initconst struct pernet_operations sysctl_core_ops = {
91961 .init = sysctl_core_net_init,
91962 .exit = sysctl_core_net_exit,
91963 };
91964 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
91965 index dd4d506..fb2fb87 100644
91966 --- a/net/decnet/af_decnet.c
91967 +++ b/net/decnet/af_decnet.c
91968 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
91969 .sysctl_rmem = sysctl_decnet_rmem,
91970 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
91971 .obj_size = sizeof(struct dn_sock),
91972 + .slab_flags = SLAB_USERCOPY,
91973 };
91974
91975 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
91976 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
91977 index 5325b54..a0d4d69 100644
91978 --- a/net/decnet/sysctl_net_decnet.c
91979 +++ b/net/decnet/sysctl_net_decnet.c
91980 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
91981
91982 if (len > *lenp) len = *lenp;
91983
91984 - if (copy_to_user(buffer, addr, len))
91985 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
91986 return -EFAULT;
91987
91988 *lenp = len;
91989 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
91990
91991 if (len > *lenp) len = *lenp;
91992
91993 - if (copy_to_user(buffer, devname, len))
91994 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
91995 return -EFAULT;
91996
91997 *lenp = len;
91998 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
91999 index 3b9d5f2..d7015c6 100644
92000 --- a/net/ieee802154/6lowpan.c
92001 +++ b/net/ieee802154/6lowpan.c
92002 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
92003 hc06_ptr += 3;
92004 } else {
92005 /* compress nothing */
92006 - memcpy(hc06_ptr, &hdr, 4);
92007 + memcpy(hc06_ptr, hdr, 4);
92008 /* replace the top byte with new ECN | DSCP format */
92009 *hc06_ptr = tmp;
92010 hc06_ptr += 4;
92011 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
92012 index b4d0be2..443d0f0 100644
92013 --- a/net/ipv4/af_inet.c
92014 +++ b/net/ipv4/af_inet.c
92015 @@ -1689,13 +1689,9 @@ static int __init inet_init(void)
92016
92017 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
92018
92019 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
92020 - if (!sysctl_local_reserved_ports)
92021 - goto out;
92022 -
92023 rc = proto_register(&tcp_prot, 1);
92024 if (rc)
92025 - goto out_free_reserved_ports;
92026 + goto out;
92027
92028 rc = proto_register(&udp_prot, 1);
92029 if (rc)
92030 @@ -1804,8 +1800,6 @@ out_unregister_udp_proto:
92031 proto_unregister(&udp_prot);
92032 out_unregister_tcp_proto:
92033 proto_unregister(&tcp_prot);
92034 -out_free_reserved_ports:
92035 - kfree(sysctl_local_reserved_ports);
92036 goto out;
92037 }
92038
92039 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
92040 index 34ca6d5..b6421e8 100644
92041 --- a/net/ipv4/devinet.c
92042 +++ b/net/ipv4/devinet.c
92043 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
92044 idx = 0;
92045 head = &net->dev_index_head[h];
92046 rcu_read_lock();
92047 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92048 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92049 net->dev_base_seq;
92050 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92051 if (idx < s_idx)
92052 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
92053 idx = 0;
92054 head = &net->dev_index_head[h];
92055 rcu_read_lock();
92056 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92057 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92058 net->dev_base_seq;
92059 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92060 if (idx < s_idx)
92061 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
92062 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
92063 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
92064
92065 -static struct devinet_sysctl_table {
92066 +static const struct devinet_sysctl_table {
92067 struct ctl_table_header *sysctl_header;
92068 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
92069 } devinet_sysctl = {
92070 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
92071 int err;
92072 struct ipv4_devconf *all, *dflt;
92073 #ifdef CONFIG_SYSCTL
92074 - struct ctl_table *tbl = ctl_forward_entry;
92075 + ctl_table_no_const *tbl = NULL;
92076 struct ctl_table_header *forw_hdr;
92077 #endif
92078
92079 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
92080 goto err_alloc_dflt;
92081
92082 #ifdef CONFIG_SYSCTL
92083 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
92084 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
92085 if (tbl == NULL)
92086 goto err_alloc_ctl;
92087
92088 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
92089 goto err_reg_dflt;
92090
92091 err = -ENOMEM;
92092 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92093 + if (!net_eq(net, &init_net))
92094 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92095 + else
92096 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
92097 if (forw_hdr == NULL)
92098 goto err_reg_ctl;
92099 net->ipv4.forw_hdr = forw_hdr;
92100 @@ -2240,8 +2243,7 @@ err_reg_ctl:
92101 err_reg_dflt:
92102 __devinet_sysctl_unregister(all);
92103 err_reg_all:
92104 - if (tbl != ctl_forward_entry)
92105 - kfree(tbl);
92106 + kfree(tbl);
92107 err_alloc_ctl:
92108 #endif
92109 if (dflt != &ipv4_devconf_dflt)
92110 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
92111 index b3f627a..b0f3e99 100644
92112 --- a/net/ipv4/fib_frontend.c
92113 +++ b/net/ipv4/fib_frontend.c
92114 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
92115 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92116 fib_sync_up(dev);
92117 #endif
92118 - atomic_inc(&net->ipv4.dev_addr_genid);
92119 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92120 rt_cache_flush(dev_net(dev));
92121 break;
92122 case NETDEV_DOWN:
92123 fib_del_ifaddr(ifa, NULL);
92124 - atomic_inc(&net->ipv4.dev_addr_genid);
92125 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92126 if (ifa->ifa_dev->ifa_list == NULL) {
92127 /* Last address was deleted from this interface.
92128 * Disable IP.
92129 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
92130 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92131 fib_sync_up(dev);
92132 #endif
92133 - atomic_inc(&net->ipv4.dev_addr_genid);
92134 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92135 rt_cache_flush(net);
92136 break;
92137 case NETDEV_DOWN:
92138 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
92139 index d5dbca5..6251d5f 100644
92140 --- a/net/ipv4/fib_semantics.c
92141 +++ b/net/ipv4/fib_semantics.c
92142 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
92143 nh->nh_saddr = inet_select_addr(nh->nh_dev,
92144 nh->nh_gw,
92145 nh->nh_parent->fib_scope);
92146 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
92147 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
92148
92149 return nh->nh_saddr;
92150 }
92151 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
92152 index 6acb541..9ea617d 100644
92153 --- a/net/ipv4/inet_connection_sock.c
92154 +++ b/net/ipv4/inet_connection_sock.c
92155 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
92156 .range = { 32768, 61000 },
92157 };
92158
92159 -unsigned long *sysctl_local_reserved_ports;
92160 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
92161 EXPORT_SYMBOL(sysctl_local_reserved_ports);
92162
92163 void inet_get_local_port_range(int *low, int *high)
92164 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92165 index 7bd8983..3abdcf6 100644
92166 --- a/net/ipv4/inet_hashtables.c
92167 +++ b/net/ipv4/inet_hashtables.c
92168 @@ -18,12 +18,15 @@
92169 #include <linux/sched.h>
92170 #include <linux/slab.h>
92171 #include <linux/wait.h>
92172 +#include <linux/security.h>
92173
92174 #include <net/inet_connection_sock.h>
92175 #include <net/inet_hashtables.h>
92176 #include <net/secure_seq.h>
92177 #include <net/ip.h>
92178
92179 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92180 +
92181 /*
92182 * Allocate and initialize a new local port bind bucket.
92183 * The bindhash mutex for snum's hash chain must be held here.
92184 @@ -554,6 +557,8 @@ ok:
92185 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92186 spin_unlock(&head->lock);
92187
92188 + gr_update_task_in_ip_table(current, inet_sk(sk));
92189 +
92190 if (tw) {
92191 inet_twsk_deschedule(tw, death_row);
92192 while (twrefcnt) {
92193 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92194 index 000e3d2..5472da3 100644
92195 --- a/net/ipv4/inetpeer.c
92196 +++ b/net/ipv4/inetpeer.c
92197 @@ -503,8 +503,8 @@ relookup:
92198 if (p) {
92199 p->daddr = *daddr;
92200 atomic_set(&p->refcnt, 1);
92201 - atomic_set(&p->rid, 0);
92202 - atomic_set(&p->ip_id_count,
92203 + atomic_set_unchecked(&p->rid, 0);
92204 + atomic_set_unchecked(&p->ip_id_count,
92205 (daddr->family == AF_INET) ?
92206 secure_ip_id(daddr->addr.a4) :
92207 secure_ipv6_id(daddr->addr.a6));
92208 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92209 index b66910a..cfe416e 100644
92210 --- a/net/ipv4/ip_fragment.c
92211 +++ b/net/ipv4/ip_fragment.c
92212 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92213 return 0;
92214
92215 start = qp->rid;
92216 - end = atomic_inc_return(&peer->rid);
92217 + end = atomic_inc_return_unchecked(&peer->rid);
92218 qp->rid = end;
92219
92220 rc = qp->q.fragments && (end - start) > max;
92221 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92222
92223 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92224 {
92225 - struct ctl_table *table;
92226 + ctl_table_no_const *table = NULL;
92227 struct ctl_table_header *hdr;
92228
92229 - table = ip4_frags_ns_ctl_table;
92230 if (!net_eq(net, &init_net)) {
92231 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92232 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92233 if (table == NULL)
92234 goto err_alloc;
92235
92236 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92237 /* Don't export sysctls to unprivileged users */
92238 if (net->user_ns != &init_user_ns)
92239 table[0].procname = NULL;
92240 - }
92241 + hdr = register_net_sysctl(net, "net/ipv4", table);
92242 + } else
92243 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92244
92245 - hdr = register_net_sysctl(net, "net/ipv4", table);
92246 if (hdr == NULL)
92247 goto err_reg;
92248
92249 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92250 return 0;
92251
92252 err_reg:
92253 - if (!net_eq(net, &init_net))
92254 - kfree(table);
92255 + kfree(table);
92256 err_alloc:
92257 return -ENOMEM;
92258 }
92259 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92260 index 8d6939e..19d0a95 100644
92261 --- a/net/ipv4/ip_gre.c
92262 +++ b/net/ipv4/ip_gre.c
92263 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92264 module_param(log_ecn_error, bool, 0644);
92265 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92266
92267 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92268 +static struct rtnl_link_ops ipgre_link_ops;
92269 static int ipgre_tunnel_init(struct net_device *dev);
92270
92271 static int ipgre_net_id __read_mostly;
92272 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92273 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92274 };
92275
92276 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92277 +static struct rtnl_link_ops ipgre_link_ops = {
92278 .kind = "gre",
92279 .maxtype = IFLA_GRE_MAX,
92280 .policy = ipgre_policy,
92281 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92282 .fill_info = ipgre_fill_info,
92283 };
92284
92285 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92286 +static struct rtnl_link_ops ipgre_tap_ops = {
92287 .kind = "gretap",
92288 .maxtype = IFLA_GRE_MAX,
92289 .policy = ipgre_policy,
92290 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92291 index d9c4f11..02b82dbc 100644
92292 --- a/net/ipv4/ip_sockglue.c
92293 +++ b/net/ipv4/ip_sockglue.c
92294 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92295 len = min_t(unsigned int, len, opt->optlen);
92296 if (put_user(len, optlen))
92297 return -EFAULT;
92298 - if (copy_to_user(optval, opt->__data, len))
92299 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92300 + copy_to_user(optval, opt->__data, len))
92301 return -EFAULT;
92302 return 0;
92303 }
92304 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92305 if (sk->sk_type != SOCK_STREAM)
92306 return -ENOPROTOOPT;
92307
92308 - msg.msg_control = optval;
92309 + msg.msg_control = (void __force_kernel *)optval;
92310 msg.msg_controllen = len;
92311 msg.msg_flags = flags;
92312
92313 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92314 index 17cc0ff..63856c4 100644
92315 --- a/net/ipv4/ip_vti.c
92316 +++ b/net/ipv4/ip_vti.c
92317 @@ -47,7 +47,7 @@
92318 #define HASH_SIZE 16
92319 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92320
92321 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92322 +static struct rtnl_link_ops vti_link_ops;
92323
92324 static int vti_net_id __read_mostly;
92325 struct vti_net {
92326 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92327 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92328 };
92329
92330 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92331 +static struct rtnl_link_ops vti_link_ops = {
92332 .kind = "vti",
92333 .maxtype = IFLA_VTI_MAX,
92334 .policy = vti_policy,
92335 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92336 index efa1138..20dbba0 100644
92337 --- a/net/ipv4/ipconfig.c
92338 +++ b/net/ipv4/ipconfig.c
92339 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92340
92341 mm_segment_t oldfs = get_fs();
92342 set_fs(get_ds());
92343 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92344 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92345 set_fs(oldfs);
92346 return res;
92347 }
92348 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92349
92350 mm_segment_t oldfs = get_fs();
92351 set_fs(get_ds());
92352 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92353 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92354 set_fs(oldfs);
92355 return res;
92356 }
92357 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92358
92359 mm_segment_t oldfs = get_fs();
92360 set_fs(get_ds());
92361 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92362 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92363 set_fs(oldfs);
92364 return res;
92365 }
92366 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92367 index b3ac3c3..ec6bd95 100644
92368 --- a/net/ipv4/ipip.c
92369 +++ b/net/ipv4/ipip.c
92370 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92371 static int ipip_net_id __read_mostly;
92372
92373 static int ipip_tunnel_init(struct net_device *dev);
92374 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92375 +static struct rtnl_link_ops ipip_link_ops;
92376
92377 static int ipip_err(struct sk_buff *skb, u32 info)
92378 {
92379 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92380 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92381 };
92382
92383 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92384 +static struct rtnl_link_ops ipip_link_ops = {
92385 .kind = "ipip",
92386 .maxtype = IFLA_IPTUN_MAX,
92387 .policy = ipip_policy,
92388 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92389 index 85a4f21..1beb1f5 100644
92390 --- a/net/ipv4/netfilter/arp_tables.c
92391 +++ b/net/ipv4/netfilter/arp_tables.c
92392 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92393 #endif
92394
92395 static int get_info(struct net *net, void __user *user,
92396 - const int *len, int compat)
92397 + int len, int compat)
92398 {
92399 char name[XT_TABLE_MAXNAMELEN];
92400 struct xt_table *t;
92401 int ret;
92402
92403 - if (*len != sizeof(struct arpt_getinfo)) {
92404 - duprintf("length %u != %Zu\n", *len,
92405 + if (len != sizeof(struct arpt_getinfo)) {
92406 + duprintf("length %u != %Zu\n", len,
92407 sizeof(struct arpt_getinfo));
92408 return -EINVAL;
92409 }
92410 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92411 info.size = private->size;
92412 strcpy(info.name, name);
92413
92414 - if (copy_to_user(user, &info, *len) != 0)
92415 + if (copy_to_user(user, &info, len) != 0)
92416 ret = -EFAULT;
92417 else
92418 ret = 0;
92419 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92420
92421 switch (cmd) {
92422 case ARPT_SO_GET_INFO:
92423 - ret = get_info(sock_net(sk), user, len, 1);
92424 + ret = get_info(sock_net(sk), user, *len, 1);
92425 break;
92426 case ARPT_SO_GET_ENTRIES:
92427 ret = compat_get_entries(sock_net(sk), user, len);
92428 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92429
92430 switch (cmd) {
92431 case ARPT_SO_GET_INFO:
92432 - ret = get_info(sock_net(sk), user, len, 0);
92433 + ret = get_info(sock_net(sk), user, *len, 0);
92434 break;
92435
92436 case ARPT_SO_GET_ENTRIES:
92437 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92438 index d23118d..6ad7277 100644
92439 --- a/net/ipv4/netfilter/ip_tables.c
92440 +++ b/net/ipv4/netfilter/ip_tables.c
92441 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92442 #endif
92443
92444 static int get_info(struct net *net, void __user *user,
92445 - const int *len, int compat)
92446 + int len, int compat)
92447 {
92448 char name[XT_TABLE_MAXNAMELEN];
92449 struct xt_table *t;
92450 int ret;
92451
92452 - if (*len != sizeof(struct ipt_getinfo)) {
92453 - duprintf("length %u != %zu\n", *len,
92454 + if (len != sizeof(struct ipt_getinfo)) {
92455 + duprintf("length %u != %zu\n", len,
92456 sizeof(struct ipt_getinfo));
92457 return -EINVAL;
92458 }
92459 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92460 info.size = private->size;
92461 strcpy(info.name, name);
92462
92463 - if (copy_to_user(user, &info, *len) != 0)
92464 + if (copy_to_user(user, &info, len) != 0)
92465 ret = -EFAULT;
92466 else
92467 ret = 0;
92468 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92469
92470 switch (cmd) {
92471 case IPT_SO_GET_INFO:
92472 - ret = get_info(sock_net(sk), user, len, 1);
92473 + ret = get_info(sock_net(sk), user, *len, 1);
92474 break;
92475 case IPT_SO_GET_ENTRIES:
92476 ret = compat_get_entries(sock_net(sk), user, len);
92477 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92478
92479 switch (cmd) {
92480 case IPT_SO_GET_INFO:
92481 - ret = get_info(sock_net(sk), user, len, 0);
92482 + ret = get_info(sock_net(sk), user, *len, 0);
92483 break;
92484
92485 case IPT_SO_GET_ENTRIES:
92486 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92487 index 746427c..80eab72 100644
92488 --- a/net/ipv4/ping.c
92489 +++ b/net/ipv4/ping.c
92490 @@ -55,7 +55,7 @@
92491
92492
92493 struct ping_table ping_table;
92494 -struct pingv6_ops pingv6_ops;
92495 +struct pingv6_ops *pingv6_ops;
92496 EXPORT_SYMBOL_GPL(pingv6_ops);
92497
92498 static u16 ping_port_rover;
92499 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92500 return -ENODEV;
92501 }
92502 }
92503 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92504 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92505 scoped);
92506 rcu_read_unlock();
92507
92508 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92509 }
92510 #if IS_ENABLED(CONFIG_IPV6)
92511 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92512 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92513 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92514 #endif
92515 }
92516
92517 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92518 info, (u8 *)icmph);
92519 #if IS_ENABLED(CONFIG_IPV6)
92520 } else if (family == AF_INET6) {
92521 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92522 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92523 info, (u8 *)icmph);
92524 #endif
92525 }
92526 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92527 return ip_recv_error(sk, msg, len);
92528 #if IS_ENABLED(CONFIG_IPV6)
92529 } else if (family == AF_INET6) {
92530 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92531 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92532 #endif
92533 }
92534 }
92535 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92536 IP6CB(skb)->iif);
92537
92538 if (inet6_sk(sk)->rxopt.all)
92539 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92540 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92541 #endif
92542 } else {
92543 BUG();
92544 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92545 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92546 0, sock_i_ino(sp),
92547 atomic_read(&sp->sk_refcnt), sp,
92548 - atomic_read(&sp->sk_drops), len);
92549 + atomic_read_unchecked(&sp->sk_drops), len);
92550 }
92551
92552 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92553 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92554 index 61e60d6..d6996cd 100644
92555 --- a/net/ipv4/raw.c
92556 +++ b/net/ipv4/raw.c
92557 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92558 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92559 {
92560 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92561 - atomic_inc(&sk->sk_drops);
92562 + atomic_inc_unchecked(&sk->sk_drops);
92563 kfree_skb(skb);
92564 return NET_RX_DROP;
92565 }
92566 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
92567
92568 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92569 {
92570 + struct icmp_filter filter;
92571 +
92572 if (optlen > sizeof(struct icmp_filter))
92573 optlen = sizeof(struct icmp_filter);
92574 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92575 + if (copy_from_user(&filter, optval, optlen))
92576 return -EFAULT;
92577 + raw_sk(sk)->filter = filter;
92578 return 0;
92579 }
92580
92581 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92582 {
92583 int len, ret = -EFAULT;
92584 + struct icmp_filter filter;
92585
92586 if (get_user(len, optlen))
92587 goto out;
92588 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92589 if (len > sizeof(struct icmp_filter))
92590 len = sizeof(struct icmp_filter);
92591 ret = -EFAULT;
92592 - if (put_user(len, optlen) ||
92593 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92594 + filter = raw_sk(sk)->filter;
92595 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92596 goto out;
92597 ret = 0;
92598 out: return ret;
92599 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92600 0, 0L, 0,
92601 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92602 0, sock_i_ino(sp),
92603 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92604 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92605 }
92606
92607 static int raw_seq_show(struct seq_file *seq, void *v)
92608 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92609 index a9a54a2..647316e 100644
92610 --- a/net/ipv4/route.c
92611 +++ b/net/ipv4/route.c
92612 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92613 .maxlen = sizeof(int),
92614 .mode = 0200,
92615 .proc_handler = ipv4_sysctl_rtcache_flush,
92616 + .extra1 = &init_net,
92617 },
92618 { },
92619 };
92620
92621 static __net_init int sysctl_route_net_init(struct net *net)
92622 {
92623 - struct ctl_table *tbl;
92624 + ctl_table_no_const *tbl = NULL;
92625
92626 - tbl = ipv4_route_flush_table;
92627 if (!net_eq(net, &init_net)) {
92628 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92629 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92630 if (tbl == NULL)
92631 goto err_dup;
92632
92633 /* Don't export sysctls to unprivileged users */
92634 if (net->user_ns != &init_user_ns)
92635 tbl[0].procname = NULL;
92636 - }
92637 - tbl[0].extra1 = net;
92638 + tbl[0].extra1 = net;
92639 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92640 + } else
92641 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92642
92643 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92644 if (net->ipv4.route_hdr == NULL)
92645 goto err_reg;
92646 return 0;
92647
92648 err_reg:
92649 - if (tbl != ipv4_route_flush_table)
92650 - kfree(tbl);
92651 + kfree(tbl);
92652 err_dup:
92653 return -ENOMEM;
92654 }
92655 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92656
92657 static __net_init int rt_genid_init(struct net *net)
92658 {
92659 - atomic_set(&net->rt_genid, 0);
92660 - atomic_set(&net->fnhe_genid, 0);
92661 + atomic_set_unchecked(&net->rt_genid, 0);
92662 + atomic_set_unchecked(&net->fnhe_genid, 0);
92663 get_random_bytes(&net->ipv4.dev_addr_genid,
92664 sizeof(net->ipv4.dev_addr_genid));
92665 return 0;
92666 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92667 index 610e324..fd42e75 100644
92668 --- a/net/ipv4/sysctl_net_ipv4.c
92669 +++ b/net/ipv4/sysctl_net_ipv4.c
92670 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92671 {
92672 int ret;
92673 int range[2];
92674 - struct ctl_table tmp = {
92675 + ctl_table_no_const tmp = {
92676 .data = &range,
92677 .maxlen = sizeof(range),
92678 .mode = table->mode,
92679 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92680 int ret;
92681 gid_t urange[2];
92682 kgid_t low, high;
92683 - struct ctl_table tmp = {
92684 + ctl_table_no_const tmp = {
92685 .data = &urange,
92686 .maxlen = sizeof(urange),
92687 .mode = table->mode,
92688 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92689 void __user *buffer, size_t *lenp, loff_t *ppos)
92690 {
92691 char val[TCP_CA_NAME_MAX];
92692 - struct ctl_table tbl = {
92693 + ctl_table_no_const tbl = {
92694 .data = val,
92695 .maxlen = TCP_CA_NAME_MAX,
92696 };
92697 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92698 void __user *buffer, size_t *lenp,
92699 loff_t *ppos)
92700 {
92701 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92702 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92703 int ret;
92704
92705 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92706 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92707 void __user *buffer, size_t *lenp,
92708 loff_t *ppos)
92709 {
92710 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92711 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92712 int ret;
92713
92714 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92715 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
92716 struct mem_cgroup *memcg;
92717 #endif
92718
92719 - struct ctl_table tmp = {
92720 + ctl_table_no_const tmp = {
92721 .data = &vec,
92722 .maxlen = sizeof(vec),
92723 .mode = ctl->mode,
92724 };
92725
92726 if (!write) {
92727 - ctl->data = &net->ipv4.sysctl_tcp_mem;
92728 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
92729 + ctl_table_no_const tcp_mem = *ctl;
92730 +
92731 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
92732 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
92733 }
92734
92735 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
92736 @@ -239,7 +241,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
92737 void __user *buffer, size_t *lenp,
92738 loff_t *ppos)
92739 {
92740 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92741 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92742 struct tcp_fastopen_context *ctxt;
92743 int ret;
92744 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
92745 @@ -482,7 +484,7 @@ static struct ctl_table ipv4_table[] = {
92746 },
92747 {
92748 .procname = "ip_local_reserved_ports",
92749 - .data = NULL, /* initialized in sysctl_ipv4_init */
92750 + .data = sysctl_local_reserved_ports,
92751 .maxlen = 65536,
92752 .mode = 0644,
92753 .proc_handler = proc_do_large_bitmap,
92754 @@ -847,11 +849,10 @@ static struct ctl_table ipv4_net_table[] = {
92755
92756 static __net_init int ipv4_sysctl_init_net(struct net *net)
92757 {
92758 - struct ctl_table *table;
92759 + ctl_table_no_const *table = NULL;
92760
92761 - table = ipv4_net_table;
92762 if (!net_eq(net, &init_net)) {
92763 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
92764 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
92765 if (table == NULL)
92766 goto err_alloc;
92767
92768 @@ -886,15 +887,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
92769
92770 tcp_init_mem(net);
92771
92772 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92773 + if (!net_eq(net, &init_net))
92774 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92775 + else
92776 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
92777 if (net->ipv4.ipv4_hdr == NULL)
92778 goto err_reg;
92779
92780 return 0;
92781
92782 err_reg:
92783 - if (!net_eq(net, &init_net))
92784 - kfree(table);
92785 + kfree(table);
92786 err_alloc:
92787 return -ENOMEM;
92788 }
92789 @@ -916,16 +919,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
92790 static __init int sysctl_ipv4_init(void)
92791 {
92792 struct ctl_table_header *hdr;
92793 - struct ctl_table *i;
92794 -
92795 - for (i = ipv4_table; i->procname; i++) {
92796 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
92797 - i->data = sysctl_local_reserved_ports;
92798 - break;
92799 - }
92800 - }
92801 - if (!i->procname)
92802 - return -EINVAL;
92803
92804 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
92805 if (hdr == NULL)
92806 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
92807 index 3ca2139..c4cc060 100644
92808 --- a/net/ipv4/tcp_input.c
92809 +++ b/net/ipv4/tcp_input.c
92810 @@ -4379,7 +4379,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
92811 * simplifies code)
92812 */
92813 static void
92814 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92815 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92816 struct sk_buff *head, struct sk_buff *tail,
92817 u32 start, u32 end)
92818 {
92819 @@ -5465,6 +5465,7 @@ discard:
92820 tcp_paws_reject(&tp->rx_opt, 0))
92821 goto discard_and_undo;
92822
92823 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
92824 if (th->syn) {
92825 /* We see SYN without ACK. It is attempt of
92826 * simultaneous connect with crossed SYNs.
92827 @@ -5515,6 +5516,7 @@ discard:
92828 goto discard;
92829 #endif
92830 }
92831 +#endif
92832 /* "fifth, if neither of the SYN or RST bits is set then
92833 * drop the segment and return."
92834 */
92835 @@ -5560,7 +5562,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
92836 goto discard;
92837
92838 if (th->syn) {
92839 - if (th->fin)
92840 + if (th->fin || th->urg || th->psh)
92841 goto discard;
92842 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
92843 return 1;
92844 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
92845 index b299da5..097db06 100644
92846 --- a/net/ipv4/tcp_ipv4.c
92847 +++ b/net/ipv4/tcp_ipv4.c
92848 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
92849 EXPORT_SYMBOL(sysctl_tcp_low_latency);
92850
92851
92852 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92853 +extern int grsec_enable_blackhole;
92854 +#endif
92855 +
92856 #ifdef CONFIG_TCP_MD5SIG
92857 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
92858 __be32 daddr, __be32 saddr, const struct tcphdr *th);
92859 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
92860 return 0;
92861
92862 reset:
92863 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92864 + if (!grsec_enable_blackhole)
92865 +#endif
92866 tcp_v4_send_reset(rsk, skb);
92867 discard:
92868 kfree_skb(skb);
92869 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
92870 TCP_SKB_CB(skb)->sacked = 0;
92871
92872 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
92873 - if (!sk)
92874 + if (!sk) {
92875 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92876 + ret = 1;
92877 +#endif
92878 goto no_tcp_socket;
92879 -
92880 + }
92881 process:
92882 - if (sk->sk_state == TCP_TIME_WAIT)
92883 + if (sk->sk_state == TCP_TIME_WAIT) {
92884 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92885 + ret = 2;
92886 +#endif
92887 goto do_time_wait;
92888 + }
92889
92890 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
92891 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
92892 @@ -2034,6 +2048,10 @@ csum_error:
92893 bad_packet:
92894 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
92895 } else {
92896 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92897 + if (!grsec_enable_blackhole || (ret == 1 &&
92898 + (skb->dev->flags & IFF_LOOPBACK)))
92899 +#endif
92900 tcp_v4_send_reset(NULL, skb);
92901 }
92902
92903 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
92904 index ab1c086..2a8d76b 100644
92905 --- a/net/ipv4/tcp_minisocks.c
92906 +++ b/net/ipv4/tcp_minisocks.c
92907 @@ -27,6 +27,10 @@
92908 #include <net/inet_common.h>
92909 #include <net/xfrm.h>
92910
92911 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92912 +extern int grsec_enable_blackhole;
92913 +#endif
92914 +
92915 int sysctl_tcp_syncookies __read_mostly = 1;
92916 EXPORT_SYMBOL(sysctl_tcp_syncookies);
92917
92918 @@ -715,7 +719,10 @@ embryonic_reset:
92919 * avoid becoming vulnerable to outside attack aiming at
92920 * resetting legit local connections.
92921 */
92922 - req->rsk_ops->send_reset(sk, skb);
92923 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92924 + if (!grsec_enable_blackhole)
92925 +#endif
92926 + req->rsk_ops->send_reset(sk, skb);
92927 } else if (fastopen) { /* received a valid RST pkt */
92928 reqsk_fastopen_remove(sk, req, true);
92929 tcp_reset(sk);
92930 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
92931 index d4943f6..e7a74a5 100644
92932 --- a/net/ipv4/tcp_probe.c
92933 +++ b/net/ipv4/tcp_probe.c
92934 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
92935 if (cnt + width >= len)
92936 break;
92937
92938 - if (copy_to_user(buf + cnt, tbuf, width))
92939 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
92940 return -EFAULT;
92941 cnt += width;
92942 }
92943 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
92944 index 4b85e6f..22f9ac9 100644
92945 --- a/net/ipv4/tcp_timer.c
92946 +++ b/net/ipv4/tcp_timer.c
92947 @@ -22,6 +22,10 @@
92948 #include <linux/gfp.h>
92949 #include <net/tcp.h>
92950
92951 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92952 +extern int grsec_lastack_retries;
92953 +#endif
92954 +
92955 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
92956 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
92957 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
92958 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
92959 }
92960 }
92961
92962 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92963 + if ((sk->sk_state == TCP_LAST_ACK) &&
92964 + (grsec_lastack_retries > 0) &&
92965 + (grsec_lastack_retries < retry_until))
92966 + retry_until = grsec_lastack_retries;
92967 +#endif
92968 +
92969 if (retransmits_timed_out(sk, retry_until,
92970 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
92971 /* Has it gone just too far? */
92972 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
92973 index 766e6ba..aff2f8d 100644
92974 --- a/net/ipv4/udp.c
92975 +++ b/net/ipv4/udp.c
92976 @@ -87,6 +87,7 @@
92977 #include <linux/types.h>
92978 #include <linux/fcntl.h>
92979 #include <linux/module.h>
92980 +#include <linux/security.h>
92981 #include <linux/socket.h>
92982 #include <linux/sockios.h>
92983 #include <linux/igmp.h>
92984 @@ -112,6 +113,10 @@
92985 #include <net/busy_poll.h>
92986 #include "udp_impl.h"
92987
92988 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92989 +extern int grsec_enable_blackhole;
92990 +#endif
92991 +
92992 struct udp_table udp_table __read_mostly;
92993 EXPORT_SYMBOL(udp_table);
92994
92995 @@ -595,6 +600,9 @@ found:
92996 return s;
92997 }
92998
92999 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
93000 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
93001 +
93002 /*
93003 * This routine is called by the ICMP module when it gets some
93004 * sort of error condition. If err < 0 then the socket should
93005 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93006 dport = usin->sin_port;
93007 if (dport == 0)
93008 return -EINVAL;
93009 +
93010 + err = gr_search_udp_sendmsg(sk, usin);
93011 + if (err)
93012 + return err;
93013 } else {
93014 if (sk->sk_state != TCP_ESTABLISHED)
93015 return -EDESTADDRREQ;
93016 +
93017 + err = gr_search_udp_sendmsg(sk, NULL);
93018 + if (err)
93019 + return err;
93020 +
93021 daddr = inet->inet_daddr;
93022 dport = inet->inet_dport;
93023 /* Open fast path for connected socket.
93024 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
93025 IS_UDPLITE(sk));
93026 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93027 IS_UDPLITE(sk));
93028 - atomic_inc(&sk->sk_drops);
93029 + atomic_inc_unchecked(&sk->sk_drops);
93030 __skb_unlink(skb, rcvq);
93031 __skb_queue_tail(&list_kill, skb);
93032 }
93033 @@ -1223,6 +1240,10 @@ try_again:
93034 if (!skb)
93035 goto out;
93036
93037 + err = gr_search_udp_recvmsg(sk, skb);
93038 + if (err)
93039 + goto out_free;
93040 +
93041 ulen = skb->len - sizeof(struct udphdr);
93042 copied = len;
93043 if (copied > ulen)
93044 @@ -1256,7 +1277,7 @@ try_again:
93045 if (unlikely(err)) {
93046 trace_kfree_skb(skb, udp_recvmsg);
93047 if (!peeked) {
93048 - atomic_inc(&sk->sk_drops);
93049 + atomic_inc_unchecked(&sk->sk_drops);
93050 UDP_INC_STATS_USER(sock_net(sk),
93051 UDP_MIB_INERRORS, is_udplite);
93052 }
93053 @@ -1543,7 +1564,7 @@ csum_error:
93054 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93055 drop:
93056 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93057 - atomic_inc(&sk->sk_drops);
93058 + atomic_inc_unchecked(&sk->sk_drops);
93059 kfree_skb(skb);
93060 return -1;
93061 }
93062 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93063 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93064
93065 if (!skb1) {
93066 - atomic_inc(&sk->sk_drops);
93067 + atomic_inc_unchecked(&sk->sk_drops);
93068 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93069 IS_UDPLITE(sk));
93070 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93071 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93072 goto csum_error;
93073
93074 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93075 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93076 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93077 +#endif
93078 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
93079
93080 /*
93081 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
93082 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93083 0, sock_i_ino(sp),
93084 atomic_read(&sp->sk_refcnt), sp,
93085 - atomic_read(&sp->sk_drops), len);
93086 + atomic_read_unchecked(&sp->sk_drops), len);
93087 }
93088
93089 int udp4_seq_show(struct seq_file *seq, void *v)
93090 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
93091 index 9a459be..c7bc04c 100644
93092 --- a/net/ipv4/xfrm4_policy.c
93093 +++ b/net/ipv4/xfrm4_policy.c
93094 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
93095 fl4->flowi4_tos = iph->tos;
93096 }
93097
93098 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
93099 +static int xfrm4_garbage_collect(struct dst_ops *ops)
93100 {
93101 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
93102
93103 - xfrm4_policy_afinfo.garbage_collect(net);
93104 + xfrm_garbage_collect_deferred(net);
93105 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
93106 }
93107
93108 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
93109
93110 static int __net_init xfrm4_net_init(struct net *net)
93111 {
93112 - struct ctl_table *table;
93113 + ctl_table_no_const *table = NULL;
93114 struct ctl_table_header *hdr;
93115
93116 - table = xfrm4_policy_table;
93117 if (!net_eq(net, &init_net)) {
93118 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93119 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93120 if (!table)
93121 goto err_alloc;
93122
93123 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
93124 - }
93125 -
93126 - hdr = register_net_sysctl(net, "net/ipv4", table);
93127 + hdr = register_net_sysctl(net, "net/ipv4", table);
93128 + } else
93129 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93130 if (!hdr)
93131 goto err_reg;
93132
93133 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93134 return 0;
93135
93136 err_reg:
93137 - if (!net_eq(net, &init_net))
93138 - kfree(table);
93139 + kfree(table);
93140 err_alloc:
93141 return -ENOMEM;
93142 }
93143 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93144 index 498ea99..42501bc 100644
93145 --- a/net/ipv6/addrconf.c
93146 +++ b/net/ipv6/addrconf.c
93147 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93148 idx = 0;
93149 head = &net->dev_index_head[h];
93150 rcu_read_lock();
93151 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93152 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93153 net->dev_base_seq;
93154 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93155 if (idx < s_idx)
93156 @@ -2381,7 +2381,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93157 p.iph.ihl = 5;
93158 p.iph.protocol = IPPROTO_IPV6;
93159 p.iph.ttl = 64;
93160 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93161 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93162
93163 if (ops->ndo_do_ioctl) {
93164 mm_segment_t oldfs = get_fs();
93165 @@ -4030,7 +4030,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93166 s_ip_idx = ip_idx = cb->args[2];
93167
93168 rcu_read_lock();
93169 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93170 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93171 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93172 idx = 0;
93173 head = &net->dev_index_head[h];
93174 @@ -4651,7 +4651,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93175 dst_free(&ifp->rt->dst);
93176 break;
93177 }
93178 - atomic_inc(&net->ipv6.dev_addr_genid);
93179 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93180 }
93181
93182 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93183 @@ -4671,7 +4671,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93184 int *valp = ctl->data;
93185 int val = *valp;
93186 loff_t pos = *ppos;
93187 - struct ctl_table lctl;
93188 + ctl_table_no_const lctl;
93189 int ret;
93190
93191 /*
93192 @@ -4756,7 +4756,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93193 int *valp = ctl->data;
93194 int val = *valp;
93195 loff_t pos = *ppos;
93196 - struct ctl_table lctl;
93197 + ctl_table_no_const lctl;
93198 int ret;
93199
93200 /*
93201 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93202 index 197e6f4..16d8396 100644
93203 --- a/net/ipv6/datagram.c
93204 +++ b/net/ipv6/datagram.c
93205 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93206 0,
93207 sock_i_ino(sp),
93208 atomic_read(&sp->sk_refcnt), sp,
93209 - atomic_read(&sp->sk_drops));
93210 + atomic_read_unchecked(&sp->sk_drops));
93211 }
93212 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93213 index 7cfc8d2..c5394b6 100644
93214 --- a/net/ipv6/icmp.c
93215 +++ b/net/ipv6/icmp.c
93216 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93217
93218 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93219 {
93220 - struct ctl_table *table;
93221 + ctl_table_no_const *table;
93222
93223 table = kmemdup(ipv6_icmp_table_template,
93224 sizeof(ipv6_icmp_table_template),
93225 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93226 index 90747f1..505320d 100644
93227 --- a/net/ipv6/ip6_gre.c
93228 +++ b/net/ipv6/ip6_gre.c
93229 @@ -74,7 +74,7 @@ struct ip6gre_net {
93230 struct net_device *fb_tunnel_dev;
93231 };
93232
93233 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93234 +static struct rtnl_link_ops ip6gre_link_ops;
93235 static int ip6gre_tunnel_init(struct net_device *dev);
93236 static void ip6gre_tunnel_setup(struct net_device *dev);
93237 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93238 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93239 }
93240
93241
93242 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93243 +static struct inet6_protocol ip6gre_protocol = {
93244 .handler = ip6gre_rcv,
93245 .err_handler = ip6gre_err,
93246 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93247 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93248 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93249 };
93250
93251 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93252 +static struct rtnl_link_ops ip6gre_link_ops = {
93253 .kind = "ip6gre",
93254 .maxtype = IFLA_GRE_MAX,
93255 .policy = ip6gre_policy,
93256 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93257 .fill_info = ip6gre_fill_info,
93258 };
93259
93260 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93261 +static struct rtnl_link_ops ip6gre_tap_ops = {
93262 .kind = "ip6gretap",
93263 .maxtype = IFLA_GRE_MAX,
93264 .policy = ip6gre_policy,
93265 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93266 index 46ba243..576f50e 100644
93267 --- a/net/ipv6/ip6_tunnel.c
93268 +++ b/net/ipv6/ip6_tunnel.c
93269 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93270
93271 static int ip6_tnl_dev_init(struct net_device *dev);
93272 static void ip6_tnl_dev_setup(struct net_device *dev);
93273 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93274 +static struct rtnl_link_ops ip6_link_ops;
93275
93276 static int ip6_tnl_net_id __read_mostly;
93277 struct ip6_tnl_net {
93278 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93279 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93280 };
93281
93282 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93283 +static struct rtnl_link_ops ip6_link_ops = {
93284 .kind = "ip6tnl",
93285 .maxtype = IFLA_IPTUN_MAX,
93286 .policy = ip6_tnl_policy,
93287 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93288 index d1e2e8e..51c19ae 100644
93289 --- a/net/ipv6/ipv6_sockglue.c
93290 +++ b/net/ipv6/ipv6_sockglue.c
93291 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93292 if (sk->sk_type != SOCK_STREAM)
93293 return -ENOPROTOOPT;
93294
93295 - msg.msg_control = optval;
93296 + msg.msg_control = (void __force_kernel *)optval;
93297 msg.msg_controllen = len;
93298 msg.msg_flags = flags;
93299
93300 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93301 index 44400c2..8e11f52 100644
93302 --- a/net/ipv6/netfilter/ip6_tables.c
93303 +++ b/net/ipv6/netfilter/ip6_tables.c
93304 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93305 #endif
93306
93307 static int get_info(struct net *net, void __user *user,
93308 - const int *len, int compat)
93309 + int len, int compat)
93310 {
93311 char name[XT_TABLE_MAXNAMELEN];
93312 struct xt_table *t;
93313 int ret;
93314
93315 - if (*len != sizeof(struct ip6t_getinfo)) {
93316 - duprintf("length %u != %zu\n", *len,
93317 + if (len != sizeof(struct ip6t_getinfo)) {
93318 + duprintf("length %u != %zu\n", len,
93319 sizeof(struct ip6t_getinfo));
93320 return -EINVAL;
93321 }
93322 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93323 info.size = private->size;
93324 strcpy(info.name, name);
93325
93326 - if (copy_to_user(user, &info, *len) != 0)
93327 + if (copy_to_user(user, &info, len) != 0)
93328 ret = -EFAULT;
93329 else
93330 ret = 0;
93331 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93332
93333 switch (cmd) {
93334 case IP6T_SO_GET_INFO:
93335 - ret = get_info(sock_net(sk), user, len, 1);
93336 + ret = get_info(sock_net(sk), user, *len, 1);
93337 break;
93338 case IP6T_SO_GET_ENTRIES:
93339 ret = compat_get_entries(sock_net(sk), user, len);
93340 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93341
93342 switch (cmd) {
93343 case IP6T_SO_GET_INFO:
93344 - ret = get_info(sock_net(sk), user, len, 0);
93345 + ret = get_info(sock_net(sk), user, *len, 0);
93346 break;
93347
93348 case IP6T_SO_GET_ENTRIES:
93349 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93350 index dffdc1a..ccc6678 100644
93351 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93352 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93353 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93354
93355 static int nf_ct_frag6_sysctl_register(struct net *net)
93356 {
93357 - struct ctl_table *table;
93358 + ctl_table_no_const *table = NULL;
93359 struct ctl_table_header *hdr;
93360
93361 - table = nf_ct_frag6_sysctl_table;
93362 if (!net_eq(net, &init_net)) {
93363 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93364 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93365 GFP_KERNEL);
93366 if (table == NULL)
93367 goto err_alloc;
93368 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93369 table[0].data = &net->nf_frag.frags.timeout;
93370 table[1].data = &net->nf_frag.frags.low_thresh;
93371 table[2].data = &net->nf_frag.frags.high_thresh;
93372 - }
93373 -
93374 - hdr = register_net_sysctl(net, "net/netfilter", table);
93375 + hdr = register_net_sysctl(net, "net/netfilter", table);
93376 + } else
93377 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93378 if (hdr == NULL)
93379 goto err_reg;
93380
93381 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93382 return 0;
93383
93384 err_reg:
93385 - if (!net_eq(net, &init_net))
93386 - kfree(table);
93387 + kfree(table);
93388 err_alloc:
93389 return -ENOMEM;
93390 }
93391 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93392 index ab92a36..bb4a528 100644
93393 --- a/net/ipv6/output_core.c
93394 +++ b/net/ipv6/output_core.c
93395 @@ -8,8 +8,8 @@
93396
93397 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93398 {
93399 - static atomic_t ipv6_fragmentation_id;
93400 - int old, new;
93401 + static atomic_unchecked_t ipv6_fragmentation_id;
93402 + int id;
93403
93404 #if IS_ENABLED(CONFIG_IPV6)
93405 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93406 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93407 }
93408 }
93409 #endif
93410 - do {
93411 - old = atomic_read(&ipv6_fragmentation_id);
93412 - new = old + 1;
93413 - if (!new)
93414 - new = 1;
93415 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93416 - fhdr->identification = htonl(new);
93417 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93418 + if (!id)
93419 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93420 + fhdr->identification = htonl(id);
93421 }
93422 EXPORT_SYMBOL(ipv6_select_ident);
93423
93424 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93425 index 18f19df..b46ada1 100644
93426 --- a/net/ipv6/ping.c
93427 +++ b/net/ipv6/ping.c
93428 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93429 };
93430 #endif
93431
93432 +static struct pingv6_ops real_pingv6_ops = {
93433 + .ipv6_recv_error = ipv6_recv_error,
93434 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93435 + .icmpv6_err_convert = icmpv6_err_convert,
93436 + .ipv6_icmp_error = ipv6_icmp_error,
93437 + .ipv6_chk_addr = ipv6_chk_addr,
93438 +};
93439 +
93440 +static struct pingv6_ops dummy_pingv6_ops = {
93441 + .ipv6_recv_error = dummy_ipv6_recv_error,
93442 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93443 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93444 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93445 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93446 +};
93447 +
93448 int __init pingv6_init(void)
93449 {
93450 #ifdef CONFIG_PROC_FS
93451 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93452 if (ret)
93453 return ret;
93454 #endif
93455 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93456 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93457 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93458 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93459 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93460 + pingv6_ops = &real_pingv6_ops;
93461 return inet6_register_protosw(&pingv6_protosw);
93462 }
93463
93464 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93465 */
93466 void pingv6_exit(void)
93467 {
93468 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93469 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93470 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93471 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93472 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93473 + pingv6_ops = &dummy_pingv6_ops;
93474 #ifdef CONFIG_PROC_FS
93475 unregister_pernet_subsys(&ping_v6_net_ops);
93476 #endif
93477 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93478 index cdaed47..515edde9 100644
93479 --- a/net/ipv6/raw.c
93480 +++ b/net/ipv6/raw.c
93481 @@ -108,7 +108,7 @@ found:
93482 */
93483 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93484 {
93485 - struct icmp6hdr *_hdr;
93486 + struct icmp6hdr _hdr;
93487 const struct icmp6hdr *hdr;
93488
93489 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93490 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93491 {
93492 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93493 skb_checksum_complete(skb)) {
93494 - atomic_inc(&sk->sk_drops);
93495 + atomic_inc_unchecked(&sk->sk_drops);
93496 kfree_skb(skb);
93497 return NET_RX_DROP;
93498 }
93499 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93500 struct raw6_sock *rp = raw6_sk(sk);
93501
93502 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93503 - atomic_inc(&sk->sk_drops);
93504 + atomic_inc_unchecked(&sk->sk_drops);
93505 kfree_skb(skb);
93506 return NET_RX_DROP;
93507 }
93508 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93509
93510 if (inet->hdrincl) {
93511 if (skb_checksum_complete(skb)) {
93512 - atomic_inc(&sk->sk_drops);
93513 + atomic_inc_unchecked(&sk->sk_drops);
93514 kfree_skb(skb);
93515 return NET_RX_DROP;
93516 }
93517 @@ -602,7 +602,7 @@ out:
93518 return err;
93519 }
93520
93521 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93522 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93523 struct flowi6 *fl6, struct dst_entry **dstp,
93524 unsigned int flags)
93525 {
93526 @@ -915,12 +915,15 @@ do_confirm:
93527 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93528 char __user *optval, int optlen)
93529 {
93530 + struct icmp6_filter filter;
93531 +
93532 switch (optname) {
93533 case ICMPV6_FILTER:
93534 if (optlen > sizeof(struct icmp6_filter))
93535 optlen = sizeof(struct icmp6_filter);
93536 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93537 + if (copy_from_user(&filter, optval, optlen))
93538 return -EFAULT;
93539 + raw6_sk(sk)->filter = filter;
93540 return 0;
93541 default:
93542 return -ENOPROTOOPT;
93543 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93544 char __user *optval, int __user *optlen)
93545 {
93546 int len;
93547 + struct icmp6_filter filter;
93548
93549 switch (optname) {
93550 case ICMPV6_FILTER:
93551 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93552 len = sizeof(struct icmp6_filter);
93553 if (put_user(len, optlen))
93554 return -EFAULT;
93555 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93556 + filter = raw6_sk(sk)->filter;
93557 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93558 return -EFAULT;
93559 return 0;
93560 default:
93561 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93562 index 1aeb473..bea761c 100644
93563 --- a/net/ipv6/reassembly.c
93564 +++ b/net/ipv6/reassembly.c
93565 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93566
93567 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93568 {
93569 - struct ctl_table *table;
93570 + ctl_table_no_const *table = NULL;
93571 struct ctl_table_header *hdr;
93572
93573 - table = ip6_frags_ns_ctl_table;
93574 if (!net_eq(net, &init_net)) {
93575 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93576 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93577 if (table == NULL)
93578 goto err_alloc;
93579
93580 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93581 /* Don't export sysctls to unprivileged users */
93582 if (net->user_ns != &init_user_ns)
93583 table[0].procname = NULL;
93584 - }
93585 + hdr = register_net_sysctl(net, "net/ipv6", table);
93586 + } else
93587 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93588
93589 - hdr = register_net_sysctl(net, "net/ipv6", table);
93590 if (hdr == NULL)
93591 goto err_reg;
93592
93593 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93594 return 0;
93595
93596 err_reg:
93597 - if (!net_eq(net, &init_net))
93598 - kfree(table);
93599 + kfree(table);
93600 err_alloc:
93601 return -ENOMEM;
93602 }
93603 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93604 index 8d9a93ed..cd89616 100644
93605 --- a/net/ipv6/route.c
93606 +++ b/net/ipv6/route.c
93607 @@ -2926,7 +2926,7 @@ struct ctl_table ipv6_route_table_template[] = {
93608
93609 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93610 {
93611 - struct ctl_table *table;
93612 + ctl_table_no_const *table;
93613
93614 table = kmemdup(ipv6_route_table_template,
93615 sizeof(ipv6_route_table_template),
93616 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93617 index 21b25dd..9a43e37 100644
93618 --- a/net/ipv6/sit.c
93619 +++ b/net/ipv6/sit.c
93620 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93621 static void ipip6_dev_free(struct net_device *dev);
93622 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93623 __be32 *v4dst);
93624 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93625 +static struct rtnl_link_ops sit_link_ops;
93626
93627 static int sit_net_id __read_mostly;
93628 struct sit_net {
93629 @@ -1547,7 +1547,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93630 #endif
93631 };
93632
93633 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93634 +static struct rtnl_link_ops sit_link_ops = {
93635 .kind = "sit",
93636 .maxtype = IFLA_IPTUN_MAX,
93637 .policy = ipip6_policy,
93638 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93639 index 107b2f1..72741a9 100644
93640 --- a/net/ipv6/sysctl_net_ipv6.c
93641 +++ b/net/ipv6/sysctl_net_ipv6.c
93642 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93643
93644 static int __net_init ipv6_sysctl_net_init(struct net *net)
93645 {
93646 - struct ctl_table *ipv6_table;
93647 + ctl_table_no_const *ipv6_table;
93648 struct ctl_table *ipv6_route_table;
93649 struct ctl_table *ipv6_icmp_table;
93650 int err;
93651 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93652 index 6e1649d..75ddb4c 100644
93653 --- a/net/ipv6/tcp_ipv6.c
93654 +++ b/net/ipv6/tcp_ipv6.c
93655 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93656 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93657 }
93658
93659 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93660 +extern int grsec_enable_blackhole;
93661 +#endif
93662 +
93663 static void tcp_v6_hash(struct sock *sk)
93664 {
93665 if (sk->sk_state != TCP_CLOSE) {
93666 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93667 return 0;
93668
93669 reset:
93670 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93671 + if (!grsec_enable_blackhole)
93672 +#endif
93673 tcp_v6_send_reset(sk, skb);
93674 discard:
93675 if (opt_skb)
93676 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
93677 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
93678 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
93679 if (np->rxopt.bits.rxtclass)
93680 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
93681 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
93682 if (ipv6_opt_accepted(sk, opt_skb)) {
93683 skb_set_owner_r(opt_skb, sk);
93684 opt_skb = xchg(&np->pktoptions, opt_skb);
93685 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
93686 TCP_SKB_CB(skb)->sacked = 0;
93687
93688 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93689 - if (!sk)
93690 + if (!sk) {
93691 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93692 + ret = 1;
93693 +#endif
93694 goto no_tcp_socket;
93695 + }
93696
93697 process:
93698 - if (sk->sk_state == TCP_TIME_WAIT)
93699 + if (sk->sk_state == TCP_TIME_WAIT) {
93700 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93701 + ret = 2;
93702 +#endif
93703 goto do_time_wait;
93704 + }
93705
93706 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
93707 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93708 @@ -1538,6 +1553,10 @@ csum_error:
93709 bad_packet:
93710 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93711 } else {
93712 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93713 + if (!grsec_enable_blackhole || (ret == 1 &&
93714 + (skb->dev->flags & IFF_LOOPBACK)))
93715 +#endif
93716 tcp_v6_send_reset(NULL, skb);
93717 }
93718
93719 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
93720 index f405815..45a68a6 100644
93721 --- a/net/ipv6/udp.c
93722 +++ b/net/ipv6/udp.c
93723 @@ -53,6 +53,10 @@
93724 #include <trace/events/skb.h>
93725 #include "udp_impl.h"
93726
93727 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93728 +extern int grsec_enable_blackhole;
93729 +#endif
93730 +
93731 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
93732 {
93733 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
93734 @@ -420,7 +424,7 @@ try_again:
93735 if (unlikely(err)) {
93736 trace_kfree_skb(skb, udpv6_recvmsg);
93737 if (!peeked) {
93738 - atomic_inc(&sk->sk_drops);
93739 + atomic_inc_unchecked(&sk->sk_drops);
93740 if (is_udp4)
93741 UDP_INC_STATS_USER(sock_net(sk),
93742 UDP_MIB_INERRORS,
93743 @@ -666,7 +670,7 @@ csum_error:
93744 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93745 drop:
93746 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93747 - atomic_inc(&sk->sk_drops);
93748 + atomic_inc_unchecked(&sk->sk_drops);
93749 kfree_skb(skb);
93750 return -1;
93751 }
93752 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93753 if (likely(skb1 == NULL))
93754 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93755 if (!skb1) {
93756 - atomic_inc(&sk->sk_drops);
93757 + atomic_inc_unchecked(&sk->sk_drops);
93758 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93759 IS_UDPLITE(sk));
93760 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93761 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93762 goto csum_error;
93763
93764 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93765 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93766 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93767 +#endif
93768 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
93769
93770 kfree_skb(skb);
93771 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
93772 index 23ed03d..6532e67 100644
93773 --- a/net/ipv6/xfrm6_policy.c
93774 +++ b/net/ipv6/xfrm6_policy.c
93775 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
93776 }
93777 }
93778
93779 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
93780 +static int xfrm6_garbage_collect(struct dst_ops *ops)
93781 {
93782 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
93783
93784 - xfrm6_policy_afinfo.garbage_collect(net);
93785 + xfrm_garbage_collect_deferred(net);
93786 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
93787 }
93788
93789 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
93790
93791 static int __net_init xfrm6_net_init(struct net *net)
93792 {
93793 - struct ctl_table *table;
93794 + ctl_table_no_const *table = NULL;
93795 struct ctl_table_header *hdr;
93796
93797 - table = xfrm6_policy_table;
93798 if (!net_eq(net, &init_net)) {
93799 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93800 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93801 if (!table)
93802 goto err_alloc;
93803
93804 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
93805 - }
93806 + hdr = register_net_sysctl(net, "net/ipv6", table);
93807 + } else
93808 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
93809
93810 - hdr = register_net_sysctl(net, "net/ipv6", table);
93811 if (!hdr)
93812 goto err_reg;
93813
93814 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
93815 return 0;
93816
93817 err_reg:
93818 - if (!net_eq(net, &init_net))
93819 - kfree(table);
93820 + kfree(table);
93821 err_alloc:
93822 return -ENOMEM;
93823 }
93824 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
93825 index 41ac7938..75e3bb1 100644
93826 --- a/net/irda/ircomm/ircomm_tty.c
93827 +++ b/net/irda/ircomm/ircomm_tty.c
93828 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93829 add_wait_queue(&port->open_wait, &wait);
93830
93831 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
93832 - __FILE__, __LINE__, tty->driver->name, port->count);
93833 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93834
93835 spin_lock_irqsave(&port->lock, flags);
93836 if (!tty_hung_up_p(filp))
93837 - port->count--;
93838 + atomic_dec(&port->count);
93839 port->blocked_open++;
93840 spin_unlock_irqrestore(&port->lock, flags);
93841
93842 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93843 }
93844
93845 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
93846 - __FILE__, __LINE__, tty->driver->name, port->count);
93847 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93848
93849 schedule();
93850 }
93851 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93852
93853 spin_lock_irqsave(&port->lock, flags);
93854 if (!tty_hung_up_p(filp))
93855 - port->count++;
93856 + atomic_inc(&port->count);
93857 port->blocked_open--;
93858 spin_unlock_irqrestore(&port->lock, flags);
93859
93860 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
93861 - __FILE__, __LINE__, tty->driver->name, port->count);
93862 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93863
93864 if (!retval)
93865 port->flags |= ASYNC_NORMAL_ACTIVE;
93866 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
93867
93868 /* ++ is not atomic, so this should be protected - Jean II */
93869 spin_lock_irqsave(&self->port.lock, flags);
93870 - self->port.count++;
93871 + atomic_inc(&self->port.count);
93872 spin_unlock_irqrestore(&self->port.lock, flags);
93873 tty_port_tty_set(&self->port, tty);
93874
93875 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
93876 - self->line, self->port.count);
93877 + self->line, atomic_read(&self->port.count));
93878
93879 /* Not really used by us, but lets do it anyway */
93880 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
93881 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
93882 tty_kref_put(port->tty);
93883 }
93884 port->tty = NULL;
93885 - port->count = 0;
93886 + atomic_set(&port->count, 0);
93887 spin_unlock_irqrestore(&port->lock, flags);
93888
93889 wake_up_interruptible(&port->open_wait);
93890 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
93891 seq_putc(m, '\n');
93892
93893 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
93894 - seq_printf(m, "Open count: %d\n", self->port.count);
93895 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
93896 seq_printf(m, "Max data size: %d\n", self->max_data_size);
93897 seq_printf(m, "Max header size: %d\n", self->max_header_size);
93898
93899 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
93900 index 168aff5..9d43132 100644
93901 --- a/net/iucv/af_iucv.c
93902 +++ b/net/iucv/af_iucv.c
93903 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
93904
93905 write_lock_bh(&iucv_sk_list.lock);
93906
93907 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
93908 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
93909 while (__iucv_get_sock_by_name(name)) {
93910 sprintf(name, "%08x",
93911 - atomic_inc_return(&iucv_sk_list.autobind_name));
93912 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
93913 }
93914
93915 write_unlock_bh(&iucv_sk_list.lock);
93916 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
93917 index cd5b8ec..f205e6b 100644
93918 --- a/net/iucv/iucv.c
93919 +++ b/net/iucv/iucv.c
93920 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
93921 return NOTIFY_OK;
93922 }
93923
93924 -static struct notifier_block __refdata iucv_cpu_notifier = {
93925 +static struct notifier_block iucv_cpu_notifier = {
93926 .notifier_call = iucv_cpu_notify,
93927 };
93928
93929 diff --git a/net/key/af_key.c b/net/key/af_key.c
93930 index ab8bd2c..cd2d641 100644
93931 --- a/net/key/af_key.c
93932 +++ b/net/key/af_key.c
93933 @@ -3048,10 +3048,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
93934 static u32 get_acqseq(void)
93935 {
93936 u32 res;
93937 - static atomic_t acqseq;
93938 + static atomic_unchecked_t acqseq;
93939
93940 do {
93941 - res = atomic_inc_return(&acqseq);
93942 + res = atomic_inc_return_unchecked(&acqseq);
93943 } while (!res);
93944 return res;
93945 }
93946 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
93947 index 43dd752..63a23bc 100644
93948 --- a/net/mac80211/cfg.c
93949 +++ b/net/mac80211/cfg.c
93950 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
93951 ret = ieee80211_vif_use_channel(sdata, chandef,
93952 IEEE80211_CHANCTX_EXCLUSIVE);
93953 }
93954 - } else if (local->open_count == local->monitors) {
93955 + } else if (local_read(&local->open_count) == local->monitors) {
93956 local->_oper_chandef = *chandef;
93957 ieee80211_hw_config(local, 0);
93958 }
93959 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
93960 else
93961 local->probe_req_reg--;
93962
93963 - if (!local->open_count)
93964 + if (!local_read(&local->open_count))
93965 break;
93966
93967 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
93968 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
93969 if (chanctx_conf) {
93970 *chandef = chanctx_conf->def;
93971 ret = 0;
93972 - } else if (local->open_count > 0 &&
93973 - local->open_count == local->monitors &&
93974 + } else if (local_read(&local->open_count) > 0 &&
93975 + local_read(&local->open_count) == local->monitors &&
93976 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
93977 if (local->use_chanctx)
93978 *chandef = local->monitor_chandef;
93979 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
93980 index 8412a30..6e00181 100644
93981 --- a/net/mac80211/ieee80211_i.h
93982 +++ b/net/mac80211/ieee80211_i.h
93983 @@ -28,6 +28,7 @@
93984 #include <net/ieee80211_radiotap.h>
93985 #include <net/cfg80211.h>
93986 #include <net/mac80211.h>
93987 +#include <asm/local.h>
93988 #include "key.h"
93989 #include "sta_info.h"
93990 #include "debug.h"
93991 @@ -907,7 +908,7 @@ struct ieee80211_local {
93992 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
93993 spinlock_t queue_stop_reason_lock;
93994
93995 - int open_count;
93996 + local_t open_count;
93997 int monitors, cooked_mntrs;
93998 /* number of interfaces with corresponding FIF_ flags */
93999 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
94000 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
94001 index cc11759..11d5541 100644
94002 --- a/net/mac80211/iface.c
94003 +++ b/net/mac80211/iface.c
94004 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94005 break;
94006 }
94007
94008 - if (local->open_count == 0) {
94009 + if (local_read(&local->open_count) == 0) {
94010 res = drv_start(local);
94011 if (res)
94012 goto err_del_bss;
94013 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94014 res = drv_add_interface(local, sdata);
94015 if (res)
94016 goto err_stop;
94017 - } else if (local->monitors == 0 && local->open_count == 0) {
94018 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
94019 res = ieee80211_add_virtual_monitor(local);
94020 if (res)
94021 goto err_stop;
94022 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94023 atomic_inc(&local->iff_promiscs);
94024
94025 if (coming_up)
94026 - local->open_count++;
94027 + local_inc(&local->open_count);
94028
94029 if (hw_reconf_flags)
94030 ieee80211_hw_config(local, hw_reconf_flags);
94031 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94032 err_del_interface:
94033 drv_remove_interface(local, sdata);
94034 err_stop:
94035 - if (!local->open_count)
94036 + if (!local_read(&local->open_count))
94037 drv_stop(local);
94038 err_del_bss:
94039 sdata->bss = NULL;
94040 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94041 }
94042
94043 if (going_down)
94044 - local->open_count--;
94045 + local_dec(&local->open_count);
94046
94047 switch (sdata->vif.type) {
94048 case NL80211_IFTYPE_AP_VLAN:
94049 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94050 }
94051 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94052
94053 - if (local->open_count == 0)
94054 + if (local_read(&local->open_count) == 0)
94055 ieee80211_clear_tx_pending(local);
94056
94057 /*
94058 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94059
94060 ieee80211_recalc_ps(local, -1);
94061
94062 - if (local->open_count == 0) {
94063 + if (local_read(&local->open_count) == 0) {
94064 ieee80211_stop_device(local);
94065
94066 /* no reconfiguring after stop! */
94067 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94068 ieee80211_configure_filter(local);
94069 ieee80211_hw_config(local, hw_reconf_flags);
94070
94071 - if (local->monitors == local->open_count)
94072 + if (local->monitors == local_read(&local->open_count))
94073 ieee80211_add_virtual_monitor(local);
94074 }
94075
94076 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94077 index 091088a..daf43c7 100644
94078 --- a/net/mac80211/main.c
94079 +++ b/net/mac80211/main.c
94080 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94081 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94082 IEEE80211_CONF_CHANGE_POWER);
94083
94084 - if (changed && local->open_count) {
94085 + if (changed && local_read(&local->open_count)) {
94086 ret = drv_config(local, changed);
94087 /*
94088 * Goal:
94089 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94090 index 3401262..d5cd68d 100644
94091 --- a/net/mac80211/pm.c
94092 +++ b/net/mac80211/pm.c
94093 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94094 struct ieee80211_sub_if_data *sdata;
94095 struct sta_info *sta;
94096
94097 - if (!local->open_count)
94098 + if (!local_read(&local->open_count))
94099 goto suspend;
94100
94101 ieee80211_scan_cancel(local);
94102 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94103 cancel_work_sync(&local->dynamic_ps_enable_work);
94104 del_timer_sync(&local->dynamic_ps_timer);
94105
94106 - local->wowlan = wowlan && local->open_count;
94107 + local->wowlan = wowlan && local_read(&local->open_count);
94108 if (local->wowlan) {
94109 int err = drv_suspend(local, wowlan);
94110 if (err < 0) {
94111 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94112 WARN_ON(!list_empty(&local->chanctx_list));
94113
94114 /* stop hardware - this must stop RX */
94115 - if (local->open_count)
94116 + if (local_read(&local->open_count))
94117 ieee80211_stop_device(local);
94118
94119 suspend:
94120 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94121 index 30d58d2..449ac8e 100644
94122 --- a/net/mac80211/rate.c
94123 +++ b/net/mac80211/rate.c
94124 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94125
94126 ASSERT_RTNL();
94127
94128 - if (local->open_count)
94129 + if (local_read(&local->open_count))
94130 return -EBUSY;
94131
94132 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94133 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94134 index c97a065..ff61928 100644
94135 --- a/net/mac80211/rc80211_pid_debugfs.c
94136 +++ b/net/mac80211/rc80211_pid_debugfs.c
94137 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94138
94139 spin_unlock_irqrestore(&events->lock, status);
94140
94141 - if (copy_to_user(buf, pb, p))
94142 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94143 return -EFAULT;
94144
94145 return p;
94146 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94147 index 2265445..ba14971 100644
94148 --- a/net/mac80211/util.c
94149 +++ b/net/mac80211/util.c
94150 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94151 }
94152 #endif
94153 /* everything else happens only if HW was up & running */
94154 - if (!local->open_count)
94155 + if (!local_read(&local->open_count))
94156 goto wake_up;
94157
94158 /*
94159 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94160 local->in_reconfig = false;
94161 barrier();
94162
94163 - if (local->monitors == local->open_count && local->monitors > 0)
94164 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94165 ieee80211_add_virtual_monitor(local);
94166
94167 /*
94168 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94169 index 56d22ca..87c778f 100644
94170 --- a/net/netfilter/Kconfig
94171 +++ b/net/netfilter/Kconfig
94172 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94173
94174 To compile it as a module, choose M here. If unsure, say N.
94175
94176 +config NETFILTER_XT_MATCH_GRADM
94177 + tristate '"gradm" match support'
94178 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94179 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94180 + ---help---
94181 + The gradm match allows to match on grsecurity RBAC being enabled.
94182 + It is useful when iptables rules are applied early on bootup to
94183 + prevent connections to the machine (except from a trusted host)
94184 + while the RBAC system is disabled.
94185 +
94186 config NETFILTER_XT_MATCH_HASHLIMIT
94187 tristate '"hashlimit" match support'
94188 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94189 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94190 index a1abf87..dbcb7ee 100644
94191 --- a/net/netfilter/Makefile
94192 +++ b/net/netfilter/Makefile
94193 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94194 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94195 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94196 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94197 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94198 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94199 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94200 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94201 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94202 index f771390..145b765 100644
94203 --- a/net/netfilter/ipset/ip_set_core.c
94204 +++ b/net/netfilter/ipset/ip_set_core.c
94205 @@ -1820,7 +1820,7 @@ done:
94206 return ret;
94207 }
94208
94209 -static struct nf_sockopt_ops so_set __read_mostly = {
94210 +static struct nf_sockopt_ops so_set = {
94211 .pf = PF_INET,
94212 .get_optmin = SO_IP_SET,
94213 .get_optmax = SO_IP_SET + 1,
94214 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94215 index 4c8e5c0..5a79b4d 100644
94216 --- a/net/netfilter/ipvs/ip_vs_conn.c
94217 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94218 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94219 /* Increase the refcnt counter of the dest */
94220 ip_vs_dest_hold(dest);
94221
94222 - conn_flags = atomic_read(&dest->conn_flags);
94223 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94224 if (cp->protocol != IPPROTO_UDP)
94225 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94226 flags = cp->flags;
94227 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94228
94229 cp->control = NULL;
94230 atomic_set(&cp->n_control, 0);
94231 - atomic_set(&cp->in_pkts, 0);
94232 + atomic_set_unchecked(&cp->in_pkts, 0);
94233
94234 cp->packet_xmit = NULL;
94235 cp->app = NULL;
94236 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94237
94238 /* Don't drop the entry if its number of incoming packets is not
94239 located in [0, 8] */
94240 - i = atomic_read(&cp->in_pkts);
94241 + i = atomic_read_unchecked(&cp->in_pkts);
94242 if (i > 8 || i < 0) return 0;
94243
94244 if (!todrop_rate[i]) return 0;
94245 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94246 index 4f69e83..da2d8bf 100644
94247 --- a/net/netfilter/ipvs/ip_vs_core.c
94248 +++ b/net/netfilter/ipvs/ip_vs_core.c
94249 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94250 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94251 /* do not touch skb anymore */
94252
94253 - atomic_inc(&cp->in_pkts);
94254 + atomic_inc_unchecked(&cp->in_pkts);
94255 ip_vs_conn_put(cp);
94256 return ret;
94257 }
94258 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94259 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94260 pkts = sysctl_sync_threshold(ipvs);
94261 else
94262 - pkts = atomic_add_return(1, &cp->in_pkts);
94263 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94264
94265 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94266 ip_vs_sync_conn(net, cp, pkts);
94267 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94268 index c8148e4..eff604f 100644
94269 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94270 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94271 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94272 */
94273 ip_vs_rs_hash(ipvs, dest);
94274 }
94275 - atomic_set(&dest->conn_flags, conn_flags);
94276 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94277
94278 /* bind the service */
94279 if (!dest->svc) {
94280 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94281 * align with netns init in ip_vs_control_net_init()
94282 */
94283
94284 -static struct ctl_table vs_vars[] = {
94285 +static ctl_table_no_const vs_vars[] __read_only = {
94286 {
94287 .procname = "amemthresh",
94288 .maxlen = sizeof(int),
94289 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94290 " %-7s %-6d %-10d %-10d\n",
94291 &dest->addr.in6,
94292 ntohs(dest->port),
94293 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94294 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94295 atomic_read(&dest->weight),
94296 atomic_read(&dest->activeconns),
94297 atomic_read(&dest->inactconns));
94298 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94299 "%-7s %-6d %-10d %-10d\n",
94300 ntohl(dest->addr.ip),
94301 ntohs(dest->port),
94302 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94303 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94304 atomic_read(&dest->weight),
94305 atomic_read(&dest->activeconns),
94306 atomic_read(&dest->inactconns));
94307 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94308
94309 entry.addr = dest->addr.ip;
94310 entry.port = dest->port;
94311 - entry.conn_flags = atomic_read(&dest->conn_flags);
94312 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94313 entry.weight = atomic_read(&dest->weight);
94314 entry.u_threshold = dest->u_threshold;
94315 entry.l_threshold = dest->l_threshold;
94316 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94317 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94318 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94319 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94320 - (atomic_read(&dest->conn_flags) &
94321 + (atomic_read_unchecked(&dest->conn_flags) &
94322 IP_VS_CONN_F_FWD_MASK)) ||
94323 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94324 atomic_read(&dest->weight)) ||
94325 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94326 {
94327 int idx;
94328 struct netns_ipvs *ipvs = net_ipvs(net);
94329 - struct ctl_table *tbl;
94330 + ctl_table_no_const *tbl;
94331
94332 atomic_set(&ipvs->dropentry, 0);
94333 spin_lock_init(&ipvs->dropentry_lock);
94334 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94335 index 1383b0e..91f68ae 100644
94336 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94337 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94338 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94339 * IPVS LBLC sysctl table
94340 */
94341 #ifdef CONFIG_SYSCTL
94342 -static struct ctl_table vs_vars_table[] = {
94343 +static struct ctl_table vs_vars_table[] __read_only = {
94344 {
94345 .procname = "lblc_expiration",
94346 .data = NULL,
94347 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94348 index 3cd85b2..b45b17e 100644
94349 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94350 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94351 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94352 * IPVS LBLCR sysctl table
94353 */
94354
94355 -static struct ctl_table vs_vars_table[] = {
94356 +static struct ctl_table vs_vars_table[] __read_only = {
94357 {
94358 .procname = "lblcr_expiration",
94359 .data = NULL,
94360 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94361 index f448471..995f131 100644
94362 --- a/net/netfilter/ipvs/ip_vs_sync.c
94363 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94364 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94365 cp = cp->control;
94366 if (cp) {
94367 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94368 - pkts = atomic_add_return(1, &cp->in_pkts);
94369 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94370 else
94371 pkts = sysctl_sync_threshold(ipvs);
94372 ip_vs_sync_conn(net, cp->control, pkts);
94373 @@ -771,7 +771,7 @@ control:
94374 if (!cp)
94375 return;
94376 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94377 - pkts = atomic_add_return(1, &cp->in_pkts);
94378 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94379 else
94380 pkts = sysctl_sync_threshold(ipvs);
94381 goto sloop;
94382 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94383
94384 if (opt)
94385 memcpy(&cp->in_seq, opt, sizeof(*opt));
94386 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94387 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94388 cp->state = state;
94389 cp->old_state = cp->state;
94390 /*
94391 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94392 index b75ff64..0c51bbe 100644
94393 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94394 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94395 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94396 else
94397 rc = NF_ACCEPT;
94398 /* do not touch skb anymore */
94399 - atomic_inc(&cp->in_pkts);
94400 + atomic_inc_unchecked(&cp->in_pkts);
94401 goto out;
94402 }
94403
94404 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94405 else
94406 rc = NF_ACCEPT;
94407 /* do not touch skb anymore */
94408 - atomic_inc(&cp->in_pkts);
94409 + atomic_inc_unchecked(&cp->in_pkts);
94410 goto out;
94411 }
94412
94413 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94414 index 2d3030a..7ba1c0a 100644
94415 --- a/net/netfilter/nf_conntrack_acct.c
94416 +++ b/net/netfilter/nf_conntrack_acct.c
94417 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94418 #ifdef CONFIG_SYSCTL
94419 static int nf_conntrack_acct_init_sysctl(struct net *net)
94420 {
94421 - struct ctl_table *table;
94422 + ctl_table_no_const *table;
94423
94424 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94425 GFP_KERNEL);
94426 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94427 index 0283bae..5febcb0 100644
94428 --- a/net/netfilter/nf_conntrack_core.c
94429 +++ b/net/netfilter/nf_conntrack_core.c
94430 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94431 #define DYING_NULLS_VAL ((1<<30)+1)
94432 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94433
94434 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94435 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94436 +#endif
94437 +
94438 int nf_conntrack_init_net(struct net *net)
94439 {
94440 int ret;
94441 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94442 goto err_stat;
94443 }
94444
94445 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94446 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94447 +#else
94448 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94449 +#endif
94450 if (!net->ct.slabname) {
94451 ret = -ENOMEM;
94452 goto err_slabname;
94453 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94454 index 1df1761..ce8b88a 100644
94455 --- a/net/netfilter/nf_conntrack_ecache.c
94456 +++ b/net/netfilter/nf_conntrack_ecache.c
94457 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94458 #ifdef CONFIG_SYSCTL
94459 static int nf_conntrack_event_init_sysctl(struct net *net)
94460 {
94461 - struct ctl_table *table;
94462 + ctl_table_no_const *table;
94463
94464 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94465 GFP_KERNEL);
94466 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94467 index 974a2a4..52cc6ff 100644
94468 --- a/net/netfilter/nf_conntrack_helper.c
94469 +++ b/net/netfilter/nf_conntrack_helper.c
94470 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94471
94472 static int nf_conntrack_helper_init_sysctl(struct net *net)
94473 {
94474 - struct ctl_table *table;
94475 + ctl_table_no_const *table;
94476
94477 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94478 GFP_KERNEL);
94479 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94480 index 0ab9636..cea3c6a 100644
94481 --- a/net/netfilter/nf_conntrack_proto.c
94482 +++ b/net/netfilter/nf_conntrack_proto.c
94483 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94484
94485 static void
94486 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94487 - struct ctl_table **table,
94488 + ctl_table_no_const **table,
94489 unsigned int users)
94490 {
94491 if (users > 0)
94492 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94493 index a99b6c3..cb372f9 100644
94494 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94495 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94496 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94497 const char *msg;
94498 u_int8_t state;
94499
94500 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94501 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94502 BUG_ON(dh == NULL);
94503
94504 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94505 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94506 out_invalid:
94507 if (LOG_INVALID(net, IPPROTO_DCCP))
94508 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94509 - NULL, msg);
94510 + NULL, "%s", msg);
94511 return false;
94512 }
94513
94514 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94515 u_int8_t type, old_state, new_state;
94516 enum ct_dccp_roles role;
94517
94518 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94519 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94520 BUG_ON(dh == NULL);
94521 type = dh->dccph_type;
94522
94523 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94524 unsigned int cscov;
94525 const char *msg;
94526
94527 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94528 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94529 if (dh == NULL) {
94530 msg = "nf_ct_dccp: short packet ";
94531 goto out_invalid;
94532 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94533
94534 out_invalid:
94535 if (LOG_INVALID(net, IPPROTO_DCCP))
94536 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94537 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94538 return -NF_ACCEPT;
94539 }
94540
94541 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94542 index f641751..d3c5b51 100644
94543 --- a/net/netfilter/nf_conntrack_standalone.c
94544 +++ b/net/netfilter/nf_conntrack_standalone.c
94545 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94546
94547 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94548 {
94549 - struct ctl_table *table;
94550 + ctl_table_no_const *table;
94551
94552 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94553 GFP_KERNEL);
94554 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94555 index 902fb0a..87f7fdb 100644
94556 --- a/net/netfilter/nf_conntrack_timestamp.c
94557 +++ b/net/netfilter/nf_conntrack_timestamp.c
94558 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94559 #ifdef CONFIG_SYSCTL
94560 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94561 {
94562 - struct ctl_table *table;
94563 + ctl_table_no_const *table;
94564
94565 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94566 GFP_KERNEL);
94567 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94568 index 85296d4..8becdec 100644
94569 --- a/net/netfilter/nf_log.c
94570 +++ b/net/netfilter/nf_log.c
94571 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94572
94573 #ifdef CONFIG_SYSCTL
94574 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94575 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94576 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94577
94578 static int nf_log_proc_dostring(struct ctl_table *table, int write,
94579 void __user *buffer, size_t *lenp, loff_t *ppos)
94580 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
94581 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
94582 mutex_unlock(&nf_log_mutex);
94583 } else {
94584 + ctl_table_no_const nf_log_table = *table;
94585 +
94586 mutex_lock(&nf_log_mutex);
94587 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
94588 lockdep_is_held(&nf_log_mutex));
94589 if (!logger)
94590 - table->data = "NONE";
94591 + nf_log_table.data = "NONE";
94592 else
94593 - table->data = logger->name;
94594 - r = proc_dostring(table, write, buffer, lenp, ppos);
94595 + nf_log_table.data = logger->name;
94596 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
94597 mutex_unlock(&nf_log_mutex);
94598 }
94599
94600 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
94601 index f042ae5..30ea486 100644
94602 --- a/net/netfilter/nf_sockopt.c
94603 +++ b/net/netfilter/nf_sockopt.c
94604 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
94605 }
94606 }
94607
94608 - list_add(&reg->list, &nf_sockopts);
94609 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
94610 out:
94611 mutex_unlock(&nf_sockopt_mutex);
94612 return ret;
94613 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
94614 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
94615 {
94616 mutex_lock(&nf_sockopt_mutex);
94617 - list_del(&reg->list);
94618 + pax_list_del((struct list_head *)&reg->list);
94619 mutex_unlock(&nf_sockopt_mutex);
94620 }
94621 EXPORT_SYMBOL(nf_unregister_sockopt);
94622 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
94623 index d92cc31..e46f350 100644
94624 --- a/net/netfilter/nfnetlink_log.c
94625 +++ b/net/netfilter/nfnetlink_log.c
94626 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
94627 struct nfnl_log_net {
94628 spinlock_t instances_lock;
94629 struct hlist_head instance_table[INSTANCE_BUCKETS];
94630 - atomic_t global_seq;
94631 + atomic_unchecked_t global_seq;
94632 };
94633
94634 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
94635 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
94636 /* global sequence number */
94637 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
94638 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
94639 - htonl(atomic_inc_return(&log->global_seq))))
94640 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
94641 goto nla_put_failure;
94642
94643 if (data_len) {
94644 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
94645 new file mode 100644
94646 index 0000000..c566332
94647 --- /dev/null
94648 +++ b/net/netfilter/xt_gradm.c
94649 @@ -0,0 +1,51 @@
94650 +/*
94651 + * gradm match for netfilter
94652 + * Copyright © Zbigniew Krzystolik, 2010
94653 + *
94654 + * This program is free software; you can redistribute it and/or modify
94655 + * it under the terms of the GNU General Public License; either version
94656 + * 2 or 3 as published by the Free Software Foundation.
94657 + */
94658 +#include <linux/module.h>
94659 +#include <linux/moduleparam.h>
94660 +#include <linux/skbuff.h>
94661 +#include <linux/netfilter/x_tables.h>
94662 +#include <linux/grsecurity.h>
94663 +#include <linux/netfilter/xt_gradm.h>
94664 +
94665 +static bool
94666 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
94667 +{
94668 + const struct xt_gradm_mtinfo *info = par->matchinfo;
94669 + bool retval = false;
94670 + if (gr_acl_is_enabled())
94671 + retval = true;
94672 + return retval ^ info->invflags;
94673 +}
94674 +
94675 +static struct xt_match gradm_mt_reg __read_mostly = {
94676 + .name = "gradm",
94677 + .revision = 0,
94678 + .family = NFPROTO_UNSPEC,
94679 + .match = gradm_mt,
94680 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
94681 + .me = THIS_MODULE,
94682 +};
94683 +
94684 +static int __init gradm_mt_init(void)
94685 +{
94686 + return xt_register_match(&gradm_mt_reg);
94687 +}
94688 +
94689 +static void __exit gradm_mt_exit(void)
94690 +{
94691 + xt_unregister_match(&gradm_mt_reg);
94692 +}
94693 +
94694 +module_init(gradm_mt_init);
94695 +module_exit(gradm_mt_exit);
94696 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
94697 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
94698 +MODULE_LICENSE("GPL");
94699 +MODULE_ALIAS("ipt_gradm");
94700 +MODULE_ALIAS("ip6t_gradm");
94701 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
94702 index 4fe4fb4..87a89e5 100644
94703 --- a/net/netfilter/xt_statistic.c
94704 +++ b/net/netfilter/xt_statistic.c
94705 @@ -19,7 +19,7 @@
94706 #include <linux/module.h>
94707
94708 struct xt_statistic_priv {
94709 - atomic_t count;
94710 + atomic_unchecked_t count;
94711 } ____cacheline_aligned_in_smp;
94712
94713 MODULE_LICENSE("GPL");
94714 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
94715 break;
94716 case XT_STATISTIC_MODE_NTH:
94717 do {
94718 - oval = atomic_read(&info->master->count);
94719 + oval = atomic_read_unchecked(&info->master->count);
94720 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
94721 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
94722 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
94723 if (nval == 0)
94724 ret = !ret;
94725 break;
94726 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
94727 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
94728 if (info->master == NULL)
94729 return -ENOMEM;
94730 - atomic_set(&info->master->count, info->u.nth.count);
94731 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
94732
94733 return 0;
94734 }
94735 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
94736 index 0c61b59..941bddd 100644
94737 --- a/net/netlink/af_netlink.c
94738 +++ b/net/netlink/af_netlink.c
94739 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
94740 sk->sk_error_report(sk);
94741 }
94742 }
94743 - atomic_inc(&sk->sk_drops);
94744 + atomic_inc_unchecked(&sk->sk_drops);
94745 }
94746
94747 static void netlink_rcv_wake(struct sock *sk)
94748 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
94749 sk_wmem_alloc_get(s),
94750 nlk->cb,
94751 atomic_read(&s->sk_refcnt),
94752 - atomic_read(&s->sk_drops),
94753 + atomic_read_unchecked(&s->sk_drops),
94754 sock_i_ino(s)
94755 );
94756
94757 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
94758 index 0c741ce..f63c3f5 100644
94759 --- a/net/netlink/genetlink.c
94760 +++ b/net/netlink/genetlink.c
94761 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
94762 goto errout;
94763 }
94764
94765 + pax_open_kernel();
94766 if (ops->dumpit)
94767 - ops->flags |= GENL_CMD_CAP_DUMP;
94768 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
94769 if (ops->doit)
94770 - ops->flags |= GENL_CMD_CAP_DO;
94771 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
94772 if (ops->policy)
94773 - ops->flags |= GENL_CMD_CAP_HASPOL;
94774 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
94775 + pax_close_kernel();
94776
94777 genl_lock_all();
94778 - list_add_tail(&ops->ops_list, &family->ops_list);
94779 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
94780 genl_unlock_all();
94781
94782 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
94783 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
94784 err = 0;
94785 errout:
94786 return err;
94787 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
94788 genl_lock_all();
94789 list_for_each_entry(rc, &family->ops_list, ops_list) {
94790 if (rc == ops) {
94791 - list_del(&ops->ops_list);
94792 + pax_list_del((struct list_head *)&ops->ops_list);
94793 genl_unlock_all();
94794 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
94795 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
94796 return 0;
94797 }
94798 }
94799 @@ -832,6 +834,10 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
94800 struct net *net = sock_net(skb->sk);
94801 int chains_to_skip = cb->args[0];
94802 int fams_to_skip = cb->args[1];
94803 + bool need_locking = chains_to_skip || fams_to_skip;
94804 +
94805 + if (need_locking)
94806 + genl_lock();
94807
94808 for (i = chains_to_skip; i < GENL_FAM_TAB_SIZE; i++) {
94809 n = 0;
94810 @@ -853,6 +859,9 @@ errout:
94811 cb->args[0] = i;
94812 cb->args[1] = n;
94813
94814 + if (need_locking)
94815 + genl_unlock();
94816 +
94817 return skb->len;
94818 }
94819
94820 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
94821 index 698814b..7cfde4e 100644
94822 --- a/net/netrom/af_netrom.c
94823 +++ b/net/netrom/af_netrom.c
94824 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
94825 *uaddr_len = sizeof(struct full_sockaddr_ax25);
94826 } else {
94827 sax->fsa_ax25.sax25_family = AF_NETROM;
94828 - sax->fsa_ax25.sax25_ndigis = 0;
94829 sax->fsa_ax25.sax25_call = nr->source_addr;
94830 *uaddr_len = sizeof(struct sockaddr_ax25);
94831 }
94832 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
94833 index 75c8bbf..ee9be59 100644
94834 --- a/net/packet/af_packet.c
94835 +++ b/net/packet/af_packet.c
94836 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94837
94838 spin_lock(&sk->sk_receive_queue.lock);
94839 po->stats.stats1.tp_packets++;
94840 - skb->dropcount = atomic_read(&sk->sk_drops);
94841 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
94842 __skb_queue_tail(&sk->sk_receive_queue, skb);
94843 spin_unlock(&sk->sk_receive_queue.lock);
94844 sk->sk_data_ready(sk, skb->len);
94845 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94846 drop_n_acct:
94847 spin_lock(&sk->sk_receive_queue.lock);
94848 po->stats.stats1.tp_drops++;
94849 - atomic_inc(&sk->sk_drops);
94850 + atomic_inc_unchecked(&sk->sk_drops);
94851 spin_unlock(&sk->sk_receive_queue.lock);
94852
94853 drop_n_restore:
94854 @@ -2640,6 +2640,7 @@ out:
94855
94856 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
94857 {
94858 + struct sock_extended_err ee;
94859 struct sock_exterr_skb *serr;
94860 struct sk_buff *skb, *skb2;
94861 int copied, err;
94862 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
94863 sock_recv_timestamp(msg, sk, skb);
94864
94865 serr = SKB_EXT_ERR(skb);
94866 + ee = serr->ee;
94867 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
94868 - sizeof(serr->ee), &serr->ee);
94869 + sizeof ee, &ee);
94870
94871 msg->msg_flags |= MSG_ERRQUEUE;
94872 err = copied;
94873 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
94874 case PACKET_HDRLEN:
94875 if (len > sizeof(int))
94876 len = sizeof(int);
94877 - if (copy_from_user(&val, optval, len))
94878 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
94879 return -EFAULT;
94880 switch (val) {
94881 case TPACKET_V1:
94882 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
94883 len = lv;
94884 if (put_user(len, optlen))
94885 return -EFAULT;
94886 - if (copy_to_user(optval, data, len))
94887 + if (len > sizeof(st) || copy_to_user(optval, data, len))
94888 return -EFAULT;
94889 return 0;
94890 }
94891 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
94892 index e774117..900b8b7 100644
94893 --- a/net/phonet/pep.c
94894 +++ b/net/phonet/pep.c
94895 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
94896
94897 case PNS_PEP_CTRL_REQ:
94898 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
94899 - atomic_inc(&sk->sk_drops);
94900 + atomic_inc_unchecked(&sk->sk_drops);
94901 break;
94902 }
94903 __skb_pull(skb, 4);
94904 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
94905 }
94906
94907 if (pn->rx_credits == 0) {
94908 - atomic_inc(&sk->sk_drops);
94909 + atomic_inc_unchecked(&sk->sk_drops);
94910 err = -ENOBUFS;
94911 break;
94912 }
94913 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
94914 }
94915
94916 if (pn->rx_credits == 0) {
94917 - atomic_inc(&sk->sk_drops);
94918 + atomic_inc_unchecked(&sk->sk_drops);
94919 err = NET_RX_DROP;
94920 break;
94921 }
94922 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
94923 index 1afd138..0b42453 100644
94924 --- a/net/phonet/socket.c
94925 +++ b/net/phonet/socket.c
94926 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
94927 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
94928 sock_i_ino(sk),
94929 atomic_read(&sk->sk_refcnt), sk,
94930 - atomic_read(&sk->sk_drops), &len);
94931 + atomic_read_unchecked(&sk->sk_drops), &len);
94932 }
94933 seq_printf(seq, "%*s\n", 127 - len, "");
94934 return 0;
94935 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
94936 index c02a8c4..3c5b600 100644
94937 --- a/net/phonet/sysctl.c
94938 +++ b/net/phonet/sysctl.c
94939 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
94940 {
94941 int ret;
94942 int range[2] = {local_port_range[0], local_port_range[1]};
94943 - struct ctl_table tmp = {
94944 + ctl_table_no_const tmp = {
94945 .data = &range,
94946 .maxlen = sizeof(range),
94947 .mode = table->mode,
94948 diff --git a/net/rds/cong.c b/net/rds/cong.c
94949 index e5b65ac..f3b6fb7 100644
94950 --- a/net/rds/cong.c
94951 +++ b/net/rds/cong.c
94952 @@ -78,7 +78,7 @@
94953 * finds that the saved generation number is smaller than the global generation
94954 * number, it wakes up the process.
94955 */
94956 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
94957 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
94958
94959 /*
94960 * Congestion monitoring
94961 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
94962 rdsdebug("waking map %p for %pI4\n",
94963 map, &map->m_addr);
94964 rds_stats_inc(s_cong_update_received);
94965 - atomic_inc(&rds_cong_generation);
94966 + atomic_inc_unchecked(&rds_cong_generation);
94967 if (waitqueue_active(&map->m_waitq))
94968 wake_up(&map->m_waitq);
94969 if (waitqueue_active(&rds_poll_waitq))
94970 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
94971
94972 int rds_cong_updated_since(unsigned long *recent)
94973 {
94974 - unsigned long gen = atomic_read(&rds_cong_generation);
94975 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
94976
94977 if (likely(*recent == gen))
94978 return 0;
94979 diff --git a/net/rds/ib.h b/net/rds/ib.h
94980 index 7280ab8..e04f4ea 100644
94981 --- a/net/rds/ib.h
94982 +++ b/net/rds/ib.h
94983 @@ -128,7 +128,7 @@ struct rds_ib_connection {
94984 /* sending acks */
94985 unsigned long i_ack_flags;
94986 #ifdef KERNEL_HAS_ATOMIC64
94987 - atomic64_t i_ack_next; /* next ACK to send */
94988 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
94989 #else
94990 spinlock_t i_ack_lock; /* protect i_ack_next */
94991 u64 i_ack_next; /* next ACK to send */
94992 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
94993 index 31b74f5..dc1fbfa 100644
94994 --- a/net/rds/ib_cm.c
94995 +++ b/net/rds/ib_cm.c
94996 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
94997 /* Clear the ACK state */
94998 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
94999 #ifdef KERNEL_HAS_ATOMIC64
95000 - atomic64_set(&ic->i_ack_next, 0);
95001 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95002 #else
95003 ic->i_ack_next = 0;
95004 #endif
95005 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
95006 index 8eb9501..0c386ff 100644
95007 --- a/net/rds/ib_recv.c
95008 +++ b/net/rds/ib_recv.c
95009 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95010 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
95011 int ack_required)
95012 {
95013 - atomic64_set(&ic->i_ack_next, seq);
95014 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95015 if (ack_required) {
95016 smp_mb__before_clear_bit();
95017 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95018 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95019 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95020 smp_mb__after_clear_bit();
95021
95022 - return atomic64_read(&ic->i_ack_next);
95023 + return atomic64_read_unchecked(&ic->i_ack_next);
95024 }
95025 #endif
95026
95027 diff --git a/net/rds/iw.h b/net/rds/iw.h
95028 index 04ce3b1..48119a6 100644
95029 --- a/net/rds/iw.h
95030 +++ b/net/rds/iw.h
95031 @@ -134,7 +134,7 @@ struct rds_iw_connection {
95032 /* sending acks */
95033 unsigned long i_ack_flags;
95034 #ifdef KERNEL_HAS_ATOMIC64
95035 - atomic64_t i_ack_next; /* next ACK to send */
95036 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95037 #else
95038 spinlock_t i_ack_lock; /* protect i_ack_next */
95039 u64 i_ack_next; /* next ACK to send */
95040 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
95041 index a91e1db..cf3053f 100644
95042 --- a/net/rds/iw_cm.c
95043 +++ b/net/rds/iw_cm.c
95044 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
95045 /* Clear the ACK state */
95046 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95047 #ifdef KERNEL_HAS_ATOMIC64
95048 - atomic64_set(&ic->i_ack_next, 0);
95049 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95050 #else
95051 ic->i_ack_next = 0;
95052 #endif
95053 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95054 index 4503335..db566b4 100644
95055 --- a/net/rds/iw_recv.c
95056 +++ b/net/rds/iw_recv.c
95057 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95058 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95059 int ack_required)
95060 {
95061 - atomic64_set(&ic->i_ack_next, seq);
95062 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95063 if (ack_required) {
95064 smp_mb__before_clear_bit();
95065 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95066 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95067 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95068 smp_mb__after_clear_bit();
95069
95070 - return atomic64_read(&ic->i_ack_next);
95071 + return atomic64_read_unchecked(&ic->i_ack_next);
95072 }
95073 #endif
95074
95075 diff --git a/net/rds/rds.h b/net/rds/rds.h
95076 index ec1d731..90a3a8d 100644
95077 --- a/net/rds/rds.h
95078 +++ b/net/rds/rds.h
95079 @@ -449,7 +449,7 @@ struct rds_transport {
95080 void (*sync_mr)(void *trans_private, int direction);
95081 void (*free_mr)(void *trans_private, int invalidate);
95082 void (*flush_mrs)(void);
95083 -};
95084 +} __do_const;
95085
95086 struct rds_sock {
95087 struct sock rs_sk;
95088 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95089 index edac9ef..16bcb98 100644
95090 --- a/net/rds/tcp.c
95091 +++ b/net/rds/tcp.c
95092 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95093 int val = 1;
95094
95095 set_fs(KERNEL_DS);
95096 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95097 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95098 sizeof(val));
95099 set_fs(oldfs);
95100 }
95101 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95102 index 81cf5a4..b5826ff 100644
95103 --- a/net/rds/tcp_send.c
95104 +++ b/net/rds/tcp_send.c
95105 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95106
95107 oldfs = get_fs();
95108 set_fs(KERNEL_DS);
95109 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95110 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95111 sizeof(val));
95112 set_fs(oldfs);
95113 }
95114 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95115 index e61aa60..f07cc89 100644
95116 --- a/net/rxrpc/af_rxrpc.c
95117 +++ b/net/rxrpc/af_rxrpc.c
95118 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95119 __be32 rxrpc_epoch;
95120
95121 /* current debugging ID */
95122 -atomic_t rxrpc_debug_id;
95123 +atomic_unchecked_t rxrpc_debug_id;
95124
95125 /* count of skbs currently in use */
95126 atomic_t rxrpc_n_skbs;
95127 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95128 index e4d9cbc..b229649 100644
95129 --- a/net/rxrpc/ar-ack.c
95130 +++ b/net/rxrpc/ar-ack.c
95131 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95132
95133 _enter("{%d,%d,%d,%d},",
95134 call->acks_hard, call->acks_unacked,
95135 - atomic_read(&call->sequence),
95136 + atomic_read_unchecked(&call->sequence),
95137 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95138
95139 stop = 0;
95140 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95141
95142 /* each Tx packet has a new serial number */
95143 sp->hdr.serial =
95144 - htonl(atomic_inc_return(&call->conn->serial));
95145 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95146
95147 hdr = (struct rxrpc_header *) txb->head;
95148 hdr->serial = sp->hdr.serial;
95149 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95150 */
95151 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95152 {
95153 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95154 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95155 }
95156
95157 /*
95158 @@ -629,7 +629,7 @@ process_further:
95159
95160 latest = ntohl(sp->hdr.serial);
95161 hard = ntohl(ack.firstPacket);
95162 - tx = atomic_read(&call->sequence);
95163 + tx = atomic_read_unchecked(&call->sequence);
95164
95165 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95166 latest,
95167 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95168 goto maybe_reschedule;
95169
95170 send_ACK_with_skew:
95171 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95172 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95173 ntohl(ack.serial));
95174 send_ACK:
95175 mtu = call->conn->trans->peer->if_mtu;
95176 @@ -1173,7 +1173,7 @@ send_ACK:
95177 ackinfo.rxMTU = htonl(5692);
95178 ackinfo.jumbo_max = htonl(4);
95179
95180 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95181 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95182 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95183 ntohl(hdr.serial),
95184 ntohs(ack.maxSkew),
95185 @@ -1191,7 +1191,7 @@ send_ACK:
95186 send_message:
95187 _debug("send message");
95188
95189 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95190 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95191 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95192 send_message_2:
95193
95194 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95195 index a3bbb36..3341fb9 100644
95196 --- a/net/rxrpc/ar-call.c
95197 +++ b/net/rxrpc/ar-call.c
95198 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95199 spin_lock_init(&call->lock);
95200 rwlock_init(&call->state_lock);
95201 atomic_set(&call->usage, 1);
95202 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95203 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95204 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95205
95206 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95207 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95208 index 4106ca9..a338d7a 100644
95209 --- a/net/rxrpc/ar-connection.c
95210 +++ b/net/rxrpc/ar-connection.c
95211 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95212 rwlock_init(&conn->lock);
95213 spin_lock_init(&conn->state_lock);
95214 atomic_set(&conn->usage, 1);
95215 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95216 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95217 conn->avail_calls = RXRPC_MAXCALLS;
95218 conn->size_align = 4;
95219 conn->header_size = sizeof(struct rxrpc_header);
95220 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95221 index e7ed43a..6afa140 100644
95222 --- a/net/rxrpc/ar-connevent.c
95223 +++ b/net/rxrpc/ar-connevent.c
95224 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95225
95226 len = iov[0].iov_len + iov[1].iov_len;
95227
95228 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95229 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95230 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95231
95232 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95233 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95234 index 529572f..c758ca7 100644
95235 --- a/net/rxrpc/ar-input.c
95236 +++ b/net/rxrpc/ar-input.c
95237 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95238 /* track the latest serial number on this connection for ACK packet
95239 * information */
95240 serial = ntohl(sp->hdr.serial);
95241 - hi_serial = atomic_read(&call->conn->hi_serial);
95242 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95243 while (serial > hi_serial)
95244 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95245 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95246 serial);
95247
95248 /* request ACK generation for any ACK or DATA packet that requests
95249 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95250 index a693aca..81e7293 100644
95251 --- a/net/rxrpc/ar-internal.h
95252 +++ b/net/rxrpc/ar-internal.h
95253 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95254 int error; /* error code for local abort */
95255 int debug_id; /* debug ID for printks */
95256 unsigned int call_counter; /* call ID counter */
95257 - atomic_t serial; /* packet serial number counter */
95258 - atomic_t hi_serial; /* highest serial number received */
95259 + atomic_unchecked_t serial; /* packet serial number counter */
95260 + atomic_unchecked_t hi_serial; /* highest serial number received */
95261 u8 avail_calls; /* number of calls available */
95262 u8 size_align; /* data size alignment (for security) */
95263 u8 header_size; /* rxrpc + security header size */
95264 @@ -346,7 +346,7 @@ struct rxrpc_call {
95265 spinlock_t lock;
95266 rwlock_t state_lock; /* lock for state transition */
95267 atomic_t usage;
95268 - atomic_t sequence; /* Tx data packet sequence counter */
95269 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95270 u32 abort_code; /* local/remote abort code */
95271 enum { /* current state of call */
95272 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95273 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95274 */
95275 extern atomic_t rxrpc_n_skbs;
95276 extern __be32 rxrpc_epoch;
95277 -extern atomic_t rxrpc_debug_id;
95278 +extern atomic_unchecked_t rxrpc_debug_id;
95279 extern struct workqueue_struct *rxrpc_workqueue;
95280
95281 /*
95282 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95283 index 87f7135..74d3703 100644
95284 --- a/net/rxrpc/ar-local.c
95285 +++ b/net/rxrpc/ar-local.c
95286 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95287 spin_lock_init(&local->lock);
95288 rwlock_init(&local->services_lock);
95289 atomic_set(&local->usage, 1);
95290 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95291 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95292 memcpy(&local->srx, srx, sizeof(*srx));
95293 }
95294
95295 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95296 index e1ac183..b43e10e 100644
95297 --- a/net/rxrpc/ar-output.c
95298 +++ b/net/rxrpc/ar-output.c
95299 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95300 sp->hdr.cid = call->cid;
95301 sp->hdr.callNumber = call->call_id;
95302 sp->hdr.seq =
95303 - htonl(atomic_inc_return(&call->sequence));
95304 + htonl(atomic_inc_return_unchecked(&call->sequence));
95305 sp->hdr.serial =
95306 - htonl(atomic_inc_return(&conn->serial));
95307 + htonl(atomic_inc_return_unchecked(&conn->serial));
95308 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95309 sp->hdr.userStatus = 0;
95310 sp->hdr.securityIndex = conn->security_ix;
95311 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95312 index bebaa43..2644591 100644
95313 --- a/net/rxrpc/ar-peer.c
95314 +++ b/net/rxrpc/ar-peer.c
95315 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95316 INIT_LIST_HEAD(&peer->error_targets);
95317 spin_lock_init(&peer->lock);
95318 atomic_set(&peer->usage, 1);
95319 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95320 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95321 memcpy(&peer->srx, srx, sizeof(*srx));
95322
95323 rxrpc_assess_MTU_size(peer);
95324 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95325 index 38047f7..9f48511 100644
95326 --- a/net/rxrpc/ar-proc.c
95327 +++ b/net/rxrpc/ar-proc.c
95328 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95329 atomic_read(&conn->usage),
95330 rxrpc_conn_states[conn->state],
95331 key_serial(conn->key),
95332 - atomic_read(&conn->serial),
95333 - atomic_read(&conn->hi_serial));
95334 + atomic_read_unchecked(&conn->serial),
95335 + atomic_read_unchecked(&conn->hi_serial));
95336
95337 return 0;
95338 }
95339 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95340 index 92df566..87ec1bf 100644
95341 --- a/net/rxrpc/ar-transport.c
95342 +++ b/net/rxrpc/ar-transport.c
95343 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95344 spin_lock_init(&trans->client_lock);
95345 rwlock_init(&trans->conn_lock);
95346 atomic_set(&trans->usage, 1);
95347 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95348 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95349
95350 if (peer->srx.transport.family == AF_INET) {
95351 switch (peer->srx.transport_type) {
95352 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95353 index f226709..0e735a8 100644
95354 --- a/net/rxrpc/rxkad.c
95355 +++ b/net/rxrpc/rxkad.c
95356 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95357
95358 len = iov[0].iov_len + iov[1].iov_len;
95359
95360 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95361 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95362 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95363
95364 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95365 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95366
95367 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95368
95369 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95370 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95371 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95372
95373 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95374 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95375 index 09ffcc9..3eff2c2 100644
95376 --- a/net/sctp/ipv6.c
95377 +++ b/net/sctp/ipv6.c
95378 @@ -210,44 +210,23 @@ out:
95379 in6_dev_put(idev);
95380 }
95381
95382 -/* Based on tcp_v6_xmit() in tcp_ipv6.c. */
95383 static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
95384 {
95385 struct sock *sk = skb->sk;
95386 struct ipv6_pinfo *np = inet6_sk(sk);
95387 - struct flowi6 fl6;
95388 -
95389 - memset(&fl6, 0, sizeof(fl6));
95390 -
95391 - fl6.flowi6_proto = sk->sk_protocol;
95392 -
95393 - /* Fill in the dest address from the route entry passed with the skb
95394 - * and the source address from the transport.
95395 - */
95396 - fl6.daddr = transport->ipaddr.v6.sin6_addr;
95397 - fl6.saddr = transport->saddr.v6.sin6_addr;
95398 -
95399 - fl6.flowlabel = np->flow_label;
95400 - IP6_ECN_flow_xmit(sk, fl6.flowlabel);
95401 - if (ipv6_addr_type(&fl6.saddr) & IPV6_ADDR_LINKLOCAL)
95402 - fl6.flowi6_oif = transport->saddr.v6.sin6_scope_id;
95403 - else
95404 - fl6.flowi6_oif = sk->sk_bound_dev_if;
95405 -
95406 - if (np->opt && np->opt->srcrt) {
95407 - struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
95408 - fl6.daddr = *rt0->addr;
95409 - }
95410 + struct flowi6 *fl6 = &transport->fl.u.ip6;
95411
95412 pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb,
95413 - skb->len, &fl6.saddr, &fl6.daddr);
95414 + skb->len, &fl6->saddr, &fl6->daddr);
95415
95416 - SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
95417 + IP6_ECN_flow_xmit(sk, fl6->flowlabel);
95418
95419 if (!(transport->param_flags & SPP_PMTUD_ENABLE))
95420 skb->local_df = 1;
95421
95422 - return ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);
95423 + SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
95424 +
95425 + return ip6_xmit(sk, skb, fl6, np->opt, np->tclass);
95426 }
95427
95428 /* Returns the dst cache entry for the given source and destination ip
95429 @@ -260,10 +239,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95430 struct dst_entry *dst = NULL;
95431 struct flowi6 *fl6 = &fl->u.ip6;
95432 struct sctp_bind_addr *bp;
95433 + struct ipv6_pinfo *np = inet6_sk(sk);
95434 struct sctp_sockaddr_entry *laddr;
95435 union sctp_addr *baddr = NULL;
95436 union sctp_addr *daddr = &t->ipaddr;
95437 union sctp_addr dst_saddr;
95438 + struct in6_addr *final_p, final;
95439 __u8 matchlen = 0;
95440 __u8 bmatchlen;
95441 sctp_scope_t scope;
95442 @@ -287,7 +268,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95443 pr_debug("src=%pI6 - ", &fl6->saddr);
95444 }
95445
95446 - dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
95447 + final_p = fl6_update_dst(fl6, np->opt, &final);
95448 + dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
95449 if (!asoc || saddr)
95450 goto out;
95451
95452 @@ -339,10 +321,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95453 }
95454 }
95455 rcu_read_unlock();
95456 +
95457 if (baddr) {
95458 fl6->saddr = baddr->v6.sin6_addr;
95459 fl6->fl6_sport = baddr->v6.sin6_port;
95460 - dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
95461 + final_p = fl6_update_dst(fl6, np->opt, &final);
95462 + dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
95463 }
95464
95465 out:
95466 @@ -984,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95467 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95468 };
95469
95470 -static struct sctp_af sctp_af_inet6 = {
95471 +static struct sctp_af sctp_af_inet6 __read_only = {
95472 .sa_family = AF_INET6,
95473 .sctp_xmit = sctp_v6_xmit,
95474 .setsockopt = ipv6_setsockopt,
95475 @@ -1016,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95476 #endif
95477 };
95478
95479 -static struct sctp_pf sctp_pf_inet6 = {
95480 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95481 .event_msgname = sctp_inet6_event_msgname,
95482 .skb_msgname = sctp_inet6_skb_msgname,
95483 .af_supported = sctp_inet6_af_supported,
95484 @@ -1041,7 +1025,7 @@ void sctp_v6_pf_init(void)
95485
95486 void sctp_v6_pf_exit(void)
95487 {
95488 - list_del(&sctp_af_inet6.list);
95489 + pax_list_del(&sctp_af_inet6.list);
95490 }
95491
95492 /* Initialize IPv6 support and register with socket layer. */
95493 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95494 index 62526c4..36a13c5 100644
95495 --- a/net/sctp/proc.c
95496 +++ b/net/sctp/proc.c
95497 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95498 seq_printf(seq,
95499 "%8pK %8pK %-3d %-3d %-2d %-4d "
95500 "%4d %8d %8d %7d %5lu %-5d %5d ",
95501 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95502 + assoc, sk,
95503 + sctp_sk(sk)->type, sk->sk_state,
95504 assoc->state, hash,
95505 assoc->assoc_id,
95506 assoc->sndbuf_used,
95507 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95508 index 4a17494d..f7e3fa0 100644
95509 --- a/net/sctp/protocol.c
95510 +++ b/net/sctp/protocol.c
95511 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95512 return 0;
95513 }
95514
95515 + pax_open_kernel();
95516 INIT_LIST_HEAD(&af->list);
95517 - list_add_tail(&af->list, &sctp_address_families);
95518 + pax_close_kernel();
95519 + pax_list_add_tail(&af->list, &sctp_address_families);
95520 return 1;
95521 }
95522
95523 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95524
95525 static struct sctp_af sctp_af_inet;
95526
95527 -static struct sctp_pf sctp_pf_inet = {
95528 +static struct sctp_pf sctp_pf_inet __read_only = {
95529 .event_msgname = sctp_inet_event_msgname,
95530 .skb_msgname = sctp_inet_skb_msgname,
95531 .af_supported = sctp_inet_af_supported,
95532 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95533 };
95534
95535 /* IPv4 address related functions. */
95536 -static struct sctp_af sctp_af_inet = {
95537 +static struct sctp_af sctp_af_inet __read_only = {
95538 .sa_family = AF_INET,
95539 .sctp_xmit = sctp_v4_xmit,
95540 .setsockopt = ip_setsockopt,
95541 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95542
95543 static void sctp_v4_pf_exit(void)
95544 {
95545 - list_del(&sctp_af_inet.list);
95546 + pax_list_del(&sctp_af_inet.list);
95547 }
95548
95549 static int sctp_v4_protosw_init(void)
95550 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95551 index 9da6885..7571898 100644
95552 --- a/net/sctp/sm_sideeffect.c
95553 +++ b/net/sctp/sm_sideeffect.c
95554 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95555 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95556 }
95557
95558 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95559 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95560 NULL,
95561 sctp_generate_t1_cookie_event,
95562 sctp_generate_t1_init_event,
95563 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95564 index c6670d2..6313e65 100644
95565 --- a/net/sctp/socket.c
95566 +++ b/net/sctp/socket.c
95567 @@ -2156,11 +2156,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95568 {
95569 struct sctp_association *asoc;
95570 struct sctp_ulpevent *event;
95571 + struct sctp_event_subscribe subscribe;
95572
95573 if (optlen > sizeof(struct sctp_event_subscribe))
95574 return -EINVAL;
95575 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95576 + if (copy_from_user(&subscribe, optval, optlen))
95577 return -EFAULT;
95578 + sctp_sk(sk)->subscribe = subscribe;
95579
95580 /*
95581 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95582 @@ -4216,13 +4218,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95583 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95584 int __user *optlen)
95585 {
95586 + struct sctp_event_subscribe subscribe;
95587 +
95588 if (len <= 0)
95589 return -EINVAL;
95590 if (len > sizeof(struct sctp_event_subscribe))
95591 len = sizeof(struct sctp_event_subscribe);
95592 if (put_user(len, optlen))
95593 return -EFAULT;
95594 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95595 + subscribe = sctp_sk(sk)->subscribe;
95596 + if (copy_to_user(optval, &subscribe, len))
95597 return -EFAULT;
95598 return 0;
95599 }
95600 @@ -4240,6 +4245,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95601 */
95602 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95603 {
95604 + __u32 autoclose;
95605 +
95606 /* Applicable to UDP-style socket only */
95607 if (sctp_style(sk, TCP))
95608 return -EOPNOTSUPP;
95609 @@ -4248,7 +4255,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95610 len = sizeof(int);
95611 if (put_user(len, optlen))
95612 return -EFAULT;
95613 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95614 + autoclose = sctp_sk(sk)->autoclose;
95615 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95616 return -EFAULT;
95617 return 0;
95618 }
95619 @@ -4620,12 +4628,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95620 */
95621 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95622 {
95623 + struct sctp_initmsg initmsg;
95624 +
95625 if (len < sizeof(struct sctp_initmsg))
95626 return -EINVAL;
95627 len = sizeof(struct sctp_initmsg);
95628 if (put_user(len, optlen))
95629 return -EFAULT;
95630 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95631 + initmsg = sctp_sk(sk)->initmsg;
95632 + if (copy_to_user(optval, &initmsg, len))
95633 return -EFAULT;
95634 return 0;
95635 }
95636 @@ -4666,6 +4677,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95637 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95638 if (space_left < addrlen)
95639 return -ENOMEM;
95640 + if (addrlen > sizeof(temp) || addrlen < 0)
95641 + return -EFAULT;
95642 if (copy_to_user(to, &temp, addrlen))
95643 return -EFAULT;
95644 to += addrlen;
95645 @@ -6182,7 +6195,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
95646 /* Is there any exceptional events? */
95647 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
95648 mask |= POLLERR |
95649 - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
95650 + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
95651 if (sk->sk_shutdown & RCV_SHUTDOWN)
95652 mask |= POLLRDHUP | POLLIN | POLLRDNORM;
95653 if (sk->sk_shutdown == SHUTDOWN_MASK)
95654 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95655 index 9a5c4c9..46e4b29 100644
95656 --- a/net/sctp/sysctl.c
95657 +++ b/net/sctp/sysctl.c
95658 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95659 {
95660 struct net *net = current->nsproxy->net_ns;
95661 char tmp[8];
95662 - struct ctl_table tbl;
95663 + ctl_table_no_const tbl;
95664 int ret;
95665 int changed = 0;
95666 char *none = "none";
95667 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95668
95669 int sctp_sysctl_net_register(struct net *net)
95670 {
95671 - struct ctl_table *table;
95672 + ctl_table_no_const *table;
95673 int i;
95674
95675 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95676 diff --git a/net/socket.c b/net/socket.c
95677 index b2d7c62..04f19ea 100644
95678 --- a/net/socket.c
95679 +++ b/net/socket.c
95680 @@ -88,6 +88,7 @@
95681 #include <linux/magic.h>
95682 #include <linux/slab.h>
95683 #include <linux/xattr.h>
95684 +#include <linux/in.h>
95685
95686 #include <asm/uaccess.h>
95687 #include <asm/unistd.h>
95688 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
95689 unsigned int sysctl_net_busy_poll __read_mostly;
95690 #endif
95691
95692 +#include <linux/grsock.h>
95693 +
95694 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
95695 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
95696 unsigned long nr_segs, loff_t pos);
95697 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
95698 &sockfs_dentry_operations, SOCKFS_MAGIC);
95699 }
95700
95701 -static struct vfsmount *sock_mnt __read_mostly;
95702 +struct vfsmount *sock_mnt __read_mostly;
95703
95704 static struct file_system_type sock_fs_type = {
95705 .name = "sockfs",
95706 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95707 return -EAFNOSUPPORT;
95708 if (type < 0 || type >= SOCK_MAX)
95709 return -EINVAL;
95710 + if (protocol < 0)
95711 + return -EINVAL;
95712
95713 /* Compatibility.
95714
95715 @@ -1394,6 +1399,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
95716 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
95717 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
95718
95719 + if(!gr_search_socket(family, type, protocol)) {
95720 + retval = -EACCES;
95721 + goto out;
95722 + }
95723 +
95724 + if (gr_handle_sock_all(family, type, protocol)) {
95725 + retval = -EACCES;
95726 + goto out;
95727 + }
95728 +
95729 retval = sock_create(family, type, protocol, &sock);
95730 if (retval < 0)
95731 goto out;
95732 @@ -1521,6 +1536,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95733 if (sock) {
95734 err = move_addr_to_kernel(umyaddr, addrlen, &address);
95735 if (err >= 0) {
95736 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
95737 + err = -EACCES;
95738 + goto error;
95739 + }
95740 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
95741 + if (err)
95742 + goto error;
95743 +
95744 err = security_socket_bind(sock,
95745 (struct sockaddr *)&address,
95746 addrlen);
95747 @@ -1529,6 +1552,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95748 (struct sockaddr *)
95749 &address, addrlen);
95750 }
95751 +error:
95752 fput_light(sock->file, fput_needed);
95753 }
95754 return err;
95755 @@ -1552,10 +1576,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
95756 if ((unsigned int)backlog > somaxconn)
95757 backlog = somaxconn;
95758
95759 + if (gr_handle_sock_server_other(sock->sk)) {
95760 + err = -EPERM;
95761 + goto error;
95762 + }
95763 +
95764 + err = gr_search_listen(sock);
95765 + if (err)
95766 + goto error;
95767 +
95768 err = security_socket_listen(sock, backlog);
95769 if (!err)
95770 err = sock->ops->listen(sock, backlog);
95771
95772 +error:
95773 fput_light(sock->file, fput_needed);
95774 }
95775 return err;
95776 @@ -1599,6 +1633,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95777 newsock->type = sock->type;
95778 newsock->ops = sock->ops;
95779
95780 + if (gr_handle_sock_server_other(sock->sk)) {
95781 + err = -EPERM;
95782 + sock_release(newsock);
95783 + goto out_put;
95784 + }
95785 +
95786 + err = gr_search_accept(sock);
95787 + if (err) {
95788 + sock_release(newsock);
95789 + goto out_put;
95790 + }
95791 +
95792 /*
95793 * We don't need try_module_get here, as the listening socket (sock)
95794 * has the protocol module (sock->ops->owner) held.
95795 @@ -1644,6 +1690,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95796 fd_install(newfd, newfile);
95797 err = newfd;
95798
95799 + gr_attach_curr_ip(newsock->sk);
95800 +
95801 out_put:
95802 fput_light(sock->file, fput_needed);
95803 out:
95804 @@ -1676,6 +1724,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95805 int, addrlen)
95806 {
95807 struct socket *sock;
95808 + struct sockaddr *sck;
95809 struct sockaddr_storage address;
95810 int err, fput_needed;
95811
95812 @@ -1686,6 +1735,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95813 if (err < 0)
95814 goto out_put;
95815
95816 + sck = (struct sockaddr *)&address;
95817 +
95818 + if (gr_handle_sock_client(sck)) {
95819 + err = -EACCES;
95820 + goto out_put;
95821 + }
95822 +
95823 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
95824 + if (err)
95825 + goto out_put;
95826 +
95827 err =
95828 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
95829 if (err)
95830 @@ -1767,6 +1827,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
95831 * the protocol.
95832 */
95833
95834 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
95835 +
95836 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
95837 unsigned int, flags, struct sockaddr __user *, addr,
95838 int, addr_len)
95839 @@ -1833,7 +1895,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
95840 struct socket *sock;
95841 struct iovec iov;
95842 struct msghdr msg;
95843 - struct sockaddr_storage address;
95844 + struct sockaddr_storage address = { };
95845 int err, err2;
95846 int fput_needed;
95847
95848 @@ -2040,7 +2102,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
95849 * checking falls down on this.
95850 */
95851 if (copy_from_user(ctl_buf,
95852 - (void __user __force *)msg_sys->msg_control,
95853 + (void __force_user *)msg_sys->msg_control,
95854 ctl_len))
95855 goto out_freectl;
95856 msg_sys->msg_control = ctl_buf;
95857 @@ -2191,7 +2253,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95858 int err, total_len, len;
95859
95860 /* kernel mode address */
95861 - struct sockaddr_storage addr;
95862 + struct sockaddr_storage addr = { };
95863
95864 /* user mode address pointers */
95865 struct sockaddr __user *uaddr;
95866 @@ -2219,7 +2281,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95867 * kernel msghdr to use the kernel address space)
95868 */
95869
95870 - uaddr = (__force void __user *)msg_sys->msg_name;
95871 + uaddr = (void __force_user *)msg_sys->msg_name;
95872 uaddr_len = COMPAT_NAMELEN(msg);
95873 if (MSG_CMSG_COMPAT & flags) {
95874 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
95875 @@ -2974,7 +3036,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
95876 old_fs = get_fs();
95877 set_fs(KERNEL_DS);
95878 err = dev_ioctl(net, cmd,
95879 - (struct ifreq __user __force *) &kifr);
95880 + (struct ifreq __force_user *) &kifr);
95881 set_fs(old_fs);
95882
95883 return err;
95884 @@ -3083,7 +3145,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
95885
95886 old_fs = get_fs();
95887 set_fs(KERNEL_DS);
95888 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
95889 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
95890 set_fs(old_fs);
95891
95892 if (cmd == SIOCGIFMAP && !err) {
95893 @@ -3188,7 +3250,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
95894 ret |= __get_user(rtdev, &(ur4->rt_dev));
95895 if (rtdev) {
95896 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
95897 - r4.rt_dev = (char __user __force *)devname;
95898 + r4.rt_dev = (char __force_user *)devname;
95899 devname[15] = 0;
95900 } else
95901 r4.rt_dev = NULL;
95902 @@ -3414,8 +3476,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
95903 int __user *uoptlen;
95904 int err;
95905
95906 - uoptval = (char __user __force *) optval;
95907 - uoptlen = (int __user __force *) optlen;
95908 + uoptval = (char __force_user *) optval;
95909 + uoptlen = (int __force_user *) optlen;
95910
95911 set_fs(KERNEL_DS);
95912 if (level == SOL_SOCKET)
95913 @@ -3435,7 +3497,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
95914 char __user *uoptval;
95915 int err;
95916
95917 - uoptval = (char __user __force *) optval;
95918 + uoptval = (char __force_user *) optval;
95919
95920 set_fs(KERNEL_DS);
95921 if (level == SOL_SOCKET)
95922 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
95923 index 09fb638..2e6a5c5 100644
95924 --- a/net/sunrpc/auth_gss/svcauth_gss.c
95925 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
95926 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95927 uint64_t *handle)
95928 {
95929 struct rsc rsci, *rscp = NULL;
95930 - static atomic64_t ctxhctr;
95931 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
95932 long long ctxh;
95933 struct gss_api_mech *gm = NULL;
95934 time_t expiry;
95935 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95936 status = -ENOMEM;
95937 /* the handle needs to be just a unique id,
95938 * use a static counter */
95939 - ctxh = atomic64_inc_return(&ctxhctr);
95940 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
95941
95942 /* make a copy for the caller */
95943 *handle = ctxh;
95944 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
95945 index ecbc4e3..ad25df8 100644
95946 --- a/net/sunrpc/clnt.c
95947 +++ b/net/sunrpc/clnt.c
95948 @@ -1304,7 +1304,9 @@ call_start(struct rpc_task *task)
95949 (RPC_IS_ASYNC(task) ? "async" : "sync"));
95950
95951 /* Increment call count */
95952 - task->tk_msg.rpc_proc->p_count++;
95953 + pax_open_kernel();
95954 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
95955 + pax_close_kernel();
95956 clnt->cl_stats->rpccnt++;
95957 task->tk_action = call_reserve;
95958 }
95959 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
95960 index 93a7a4e..3b98b9f 100644
95961 --- a/net/sunrpc/sched.c
95962 +++ b/net/sunrpc/sched.c
95963 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
95964 #ifdef RPC_DEBUG
95965 static void rpc_task_set_debuginfo(struct rpc_task *task)
95966 {
95967 - static atomic_t rpc_pid;
95968 + static atomic_unchecked_t rpc_pid;
95969
95970 - task->tk_pid = atomic_inc_return(&rpc_pid);
95971 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
95972 }
95973 #else
95974 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
95975 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
95976 index b974571..678ed90 100644
95977 --- a/net/sunrpc/svc.c
95978 +++ b/net/sunrpc/svc.c
95979 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
95980 svc_putnl(resv, RPC_SUCCESS);
95981
95982 /* Bump per-procedure stats counter */
95983 - procp->pc_count++;
95984 + pax_open_kernel();
95985 + (*(unsigned int *)&procp->pc_count)++;
95986 + pax_close_kernel();
95987
95988 /* Initialize storage for argp and resp */
95989 memset(rqstp->rq_argp, 0, procp->pc_argsize);
95990 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
95991 index c1b6270..05089c1 100644
95992 --- a/net/sunrpc/xprtrdma/svc_rdma.c
95993 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
95994 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
95995 static unsigned int min_max_inline = 4096;
95996 static unsigned int max_max_inline = 65536;
95997
95998 -atomic_t rdma_stat_recv;
95999 -atomic_t rdma_stat_read;
96000 -atomic_t rdma_stat_write;
96001 -atomic_t rdma_stat_sq_starve;
96002 -atomic_t rdma_stat_rq_starve;
96003 -atomic_t rdma_stat_rq_poll;
96004 -atomic_t rdma_stat_rq_prod;
96005 -atomic_t rdma_stat_sq_poll;
96006 -atomic_t rdma_stat_sq_prod;
96007 +atomic_unchecked_t rdma_stat_recv;
96008 +atomic_unchecked_t rdma_stat_read;
96009 +atomic_unchecked_t rdma_stat_write;
96010 +atomic_unchecked_t rdma_stat_sq_starve;
96011 +atomic_unchecked_t rdma_stat_rq_starve;
96012 +atomic_unchecked_t rdma_stat_rq_poll;
96013 +atomic_unchecked_t rdma_stat_rq_prod;
96014 +atomic_unchecked_t rdma_stat_sq_poll;
96015 +atomic_unchecked_t rdma_stat_sq_prod;
96016
96017 /* Temporary NFS request map and context caches */
96018 struct kmem_cache *svc_rdma_map_cachep;
96019 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
96020 len -= *ppos;
96021 if (len > *lenp)
96022 len = *lenp;
96023 - if (len && copy_to_user(buffer, str_buf, len))
96024 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
96025 return -EFAULT;
96026 *lenp = len;
96027 *ppos += len;
96028 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
96029 {
96030 .procname = "rdma_stat_read",
96031 .data = &rdma_stat_read,
96032 - .maxlen = sizeof(atomic_t),
96033 + .maxlen = sizeof(atomic_unchecked_t),
96034 .mode = 0644,
96035 .proc_handler = read_reset_stat,
96036 },
96037 {
96038 .procname = "rdma_stat_recv",
96039 .data = &rdma_stat_recv,
96040 - .maxlen = sizeof(atomic_t),
96041 + .maxlen = sizeof(atomic_unchecked_t),
96042 .mode = 0644,
96043 .proc_handler = read_reset_stat,
96044 },
96045 {
96046 .procname = "rdma_stat_write",
96047 .data = &rdma_stat_write,
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_sq_starve",
96055 .data = &rdma_stat_sq_starve,
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_rq_starve",
96063 .data = &rdma_stat_rq_starve,
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_rq_poll",
96071 .data = &rdma_stat_rq_poll,
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_prod",
96079 .data = &rdma_stat_rq_prod,
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_sq_poll",
96087 .data = &rdma_stat_sq_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_sq_prod",
96095 .data = &rdma_stat_sq_prod,
96096 - .maxlen = sizeof(atomic_t),
96097 + .maxlen = sizeof(atomic_unchecked_t),
96098 .mode = 0644,
96099 .proc_handler = read_reset_stat,
96100 },
96101 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96102 index 0ce7552..d074459 100644
96103 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96104 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96105 @@ -501,7 +501,7 @@ next_sge:
96106 svc_rdma_put_context(ctxt, 0);
96107 goto out;
96108 }
96109 - atomic_inc(&rdma_stat_read);
96110 + atomic_inc_unchecked(&rdma_stat_read);
96111
96112 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
96113 chl_map->ch[ch_no].count -= read_wr.num_sge;
96114 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96115 dto_q);
96116 list_del_init(&ctxt->dto_q);
96117 } else {
96118 - atomic_inc(&rdma_stat_rq_starve);
96119 + atomic_inc_unchecked(&rdma_stat_rq_starve);
96120 clear_bit(XPT_DATA, &xprt->xpt_flags);
96121 ctxt = NULL;
96122 }
96123 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96124 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
96125 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
96126 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
96127 - atomic_inc(&rdma_stat_recv);
96128 + atomic_inc_unchecked(&rdma_stat_recv);
96129
96130 /* Build up the XDR from the receive buffers. */
96131 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
96132 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96133 index c1d124d..acfc59e 100644
96134 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96135 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96136 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96137 write_wr.wr.rdma.remote_addr = to;
96138
96139 /* Post It */
96140 - atomic_inc(&rdma_stat_write);
96141 + atomic_inc_unchecked(&rdma_stat_write);
96142 if (svc_rdma_send(xprt, &write_wr))
96143 goto err;
96144 return 0;
96145 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96146 index 62e4f9b..dd3f2d7 100644
96147 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96148 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96149 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96150 return;
96151
96152 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96153 - atomic_inc(&rdma_stat_rq_poll);
96154 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96155
96156 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96157 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96158 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96159 }
96160
96161 if (ctxt)
96162 - atomic_inc(&rdma_stat_rq_prod);
96163 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96164
96165 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96166 /*
96167 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96168 return;
96169
96170 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96171 - atomic_inc(&rdma_stat_sq_poll);
96172 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96173 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96174 if (wc.status != IB_WC_SUCCESS)
96175 /* Close the transport */
96176 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96177 }
96178
96179 if (ctxt)
96180 - atomic_inc(&rdma_stat_sq_prod);
96181 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96182 }
96183
96184 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96185 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96186 spin_lock_bh(&xprt->sc_lock);
96187 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96188 spin_unlock_bh(&xprt->sc_lock);
96189 - atomic_inc(&rdma_stat_sq_starve);
96190 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96191
96192 /* See if we can opportunistically reap SQ WR to make room */
96193 sq_cq_reap(xprt);
96194 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96195 index 9bc6db0..47ac8c0 100644
96196 --- a/net/sysctl_net.c
96197 +++ b/net/sysctl_net.c
96198 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96199 kgid_t root_gid = make_kgid(net->user_ns, 0);
96200
96201 /* Allow network administrator to have same access as root. */
96202 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96203 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96204 uid_eq(root_uid, current_uid())) {
96205 int mode = (table->mode >> 6) & 7;
96206 return (mode << 6) | (mode << 3) | mode;
96207 diff --git a/net/tipc/link.c b/net/tipc/link.c
96208 index 0cc3d90..cc42021 100644
96209 --- a/net/tipc/link.c
96210 +++ b/net/tipc/link.c
96211 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96212 struct tipc_msg fragm_hdr;
96213 struct sk_buff *buf, *buf_chain, *prev;
96214 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96215 - const unchar *sect_crs;
96216 + const unchar __user *sect_crs;
96217 int curr_sect;
96218 u32 fragm_no;
96219 int res = 0;
96220 @@ -1207,7 +1207,7 @@ again:
96221
96222 if (!sect_rest) {
96223 sect_rest = msg_sect[++curr_sect].iov_len;
96224 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96225 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96226 }
96227
96228 if (sect_rest < fragm_rest)
96229 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96230 index ced60e2..54eab6c 100644
96231 --- a/net/tipc/msg.c
96232 +++ b/net/tipc/msg.c
96233 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96234 skb_copy_to_linear_data(*buf, hdr, hsz);
96235 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96236 skb_copy_to_linear_data_offset(*buf, pos,
96237 - msg_sect[cnt].iov_base,
96238 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96239 msg_sect[cnt].iov_len);
96240 pos += msg_sect[cnt].iov_len;
96241 }
96242 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96243 index d38bb45..4fd6ac6 100644
96244 --- a/net/tipc/subscr.c
96245 +++ b/net/tipc/subscr.c
96246 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96247 struct kvec msg_sect;
96248 int ret;
96249
96250 - msg_sect.iov_base = (void *)&sub->evt;
96251 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96252 msg_sect.iov_len = sizeof(struct tipc_event);
96253
96254 sub->evt.event = htohl(event, sub->swap);
96255 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96256 index c4ce243..2be7c59 100644
96257 --- a/net/unix/af_unix.c
96258 +++ b/net/unix/af_unix.c
96259 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96260 err = -ECONNREFUSED;
96261 if (!S_ISSOCK(inode->i_mode))
96262 goto put_fail;
96263 +
96264 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96265 + err = -EACCES;
96266 + goto put_fail;
96267 + }
96268 +
96269 u = unix_find_socket_byinode(inode);
96270 if (!u)
96271 goto put_fail;
96272 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96273 if (u) {
96274 struct dentry *dentry;
96275 dentry = unix_sk(u)->path.dentry;
96276 +
96277 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96278 + err = -EPERM;
96279 + sock_put(u);
96280 + goto fail;
96281 + }
96282 +
96283 if (dentry)
96284 touch_atime(&unix_sk(u)->path);
96285 } else
96286 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96287 */
96288 err = security_path_mknod(&path, dentry, mode, 0);
96289 if (!err) {
96290 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96291 + err = -EACCES;
96292 + goto out;
96293 + }
96294 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96295 if (!err) {
96296 res->mnt = mntget(path.mnt);
96297 res->dentry = dget(dentry);
96298 + gr_handle_create(dentry, path.mnt);
96299 }
96300 }
96301 +out:
96302 done_path_create(&path, dentry);
96303 return err;
96304 }
96305 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96306 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96307 "Inode Path\n");
96308 else {
96309 - struct sock *s = v;
96310 + struct sock *s = v, *peer;
96311 struct unix_sock *u = unix_sk(s);
96312 unix_state_lock(s);
96313 + peer = unix_peer(s);
96314 + unix_state_unlock(s);
96315 +
96316 + unix_state_double_lock(s, peer);
96317
96318 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
96319 s,
96320 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96321 }
96322 for ( ; i < len; i++)
96323 seq_putc(seq, u->addr->name->sun_path[i]);
96324 - }
96325 - unix_state_unlock(s);
96326 + } else if (peer)
96327 + seq_printf(seq, " P%lu", sock_i_ino(peer));
96328 +
96329 + unix_state_double_unlock(s, peer);
96330 seq_putc(seq, '\n');
96331 }
96332
96333 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
96334 index b3d5150..ff3a837 100644
96335 --- a/net/unix/sysctl_net_unix.c
96336 +++ b/net/unix/sysctl_net_unix.c
96337 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
96338
96339 int __net_init unix_sysctl_register(struct net *net)
96340 {
96341 - struct ctl_table *table;
96342 + ctl_table_no_const *table;
96343
96344 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96345 if (table == NULL)
96346 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96347 index c8717c1..08539f5 100644
96348 --- a/net/wireless/wext-core.c
96349 +++ b/net/wireless/wext-core.c
96350 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96351 */
96352
96353 /* Support for very large requests */
96354 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96355 - (user_length > descr->max_tokens)) {
96356 + if (user_length > descr->max_tokens) {
96357 /* Allow userspace to GET more than max so
96358 * we can support any size GET requests.
96359 * There is still a limit : -ENOMEM.
96360 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96361 }
96362 }
96363
96364 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96365 - /*
96366 - * If this is a GET, but not NOMAX, it means that the extra
96367 - * data is not bounded by userspace, but by max_tokens. Thus
96368 - * set the length to max_tokens. This matches the extra data
96369 - * allocation.
96370 - * The driver should fill it with the number of tokens it
96371 - * provided, and it may check iwp->length rather than having
96372 - * knowledge of max_tokens. If the driver doesn't change the
96373 - * iwp->length, this ioctl just copies back max_token tokens
96374 - * filled with zeroes. Hopefully the driver isn't claiming
96375 - * them to be valid data.
96376 - */
96377 - iwp->length = descr->max_tokens;
96378 - }
96379 -
96380 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96381
96382 iwp->length += essid_compat;
96383 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96384 index f77c371..e412fa6 100644
96385 --- a/net/xfrm/xfrm_policy.c
96386 +++ b/net/xfrm/xfrm_policy.c
96387 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96388 {
96389 policy->walk.dead = 1;
96390
96391 - atomic_inc(&policy->genid);
96392 + atomic_inc_unchecked(&policy->genid);
96393
96394 del_timer(&policy->polq.hold_timer);
96395 xfrm_queue_purge(&policy->polq.hold_queue);
96396 @@ -657,7 +657,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96397 hlist_add_head(&policy->bydst, chain);
96398 xfrm_pol_hold(policy);
96399 net->xfrm.policy_count[dir]++;
96400 - atomic_inc(&flow_cache_genid);
96401 + atomic_inc_unchecked(&flow_cache_genid);
96402 rt_genid_bump(net);
96403 if (delpol) {
96404 xfrm_policy_requeue(delpol, policy);
96405 @@ -1627,7 +1627,7 @@ free_dst:
96406 goto out;
96407 }
96408
96409 -static int inline
96410 +static inline int
96411 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96412 {
96413 if (!*target) {
96414 @@ -1639,7 +1639,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96415 return 0;
96416 }
96417
96418 -static int inline
96419 +static inline int
96420 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96421 {
96422 #ifdef CONFIG_XFRM_SUB_POLICY
96423 @@ -1651,7 +1651,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96424 #endif
96425 }
96426
96427 -static int inline
96428 +static inline int
96429 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96430 {
96431 #ifdef CONFIG_XFRM_SUB_POLICY
96432 @@ -1745,7 +1745,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96433
96434 xdst->num_pols = num_pols;
96435 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96436 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96437 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96438
96439 return xdst;
96440 }
96441 @@ -2557,11 +2557,12 @@ void xfrm_garbage_collect(struct net *net)
96442 }
96443 EXPORT_SYMBOL(xfrm_garbage_collect);
96444
96445 -static void xfrm_garbage_collect_deferred(struct net *net)
96446 +void xfrm_garbage_collect_deferred(struct net *net)
96447 {
96448 flow_cache_flush_deferred();
96449 __xfrm_garbage_collect(net);
96450 }
96451 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
96452
96453 static void xfrm_init_pmtu(struct dst_entry *dst)
96454 {
96455 @@ -2611,7 +2612,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
96456 if (xdst->xfrm_genid != dst->xfrm->genid)
96457 return 0;
96458 if (xdst->num_pols > 0 &&
96459 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
96460 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
96461 return 0;
96462
96463 mtu = dst_mtu(dst->child);
96464 @@ -2699,8 +2700,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
96465 dst_ops->link_failure = xfrm_link_failure;
96466 if (likely(dst_ops->neigh_lookup == NULL))
96467 dst_ops->neigh_lookup = xfrm_neigh_lookup;
96468 - if (likely(afinfo->garbage_collect == NULL))
96469 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
96470 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
96471 }
96472 spin_unlock(&xfrm_policy_afinfo_lock);
96473 @@ -2754,7 +2753,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
96474 dst_ops->check = NULL;
96475 dst_ops->negative_advice = NULL;
96476 dst_ops->link_failure = NULL;
96477 - afinfo->garbage_collect = NULL;
96478 }
96479 return err;
96480 }
96481 @@ -3137,7 +3135,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
96482 sizeof(pol->xfrm_vec[i].saddr));
96483 pol->xfrm_vec[i].encap_family = mp->new_family;
96484 /* flush bundles */
96485 - atomic_inc(&pol->genid);
96486 + atomic_inc_unchecked(&pol->genid);
96487 }
96488 }
96489
96490 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
96491 index 54c0acd..56814bd 100644
96492 --- a/net/xfrm/xfrm_state.c
96493 +++ b/net/xfrm/xfrm_state.c
96494 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
96495
96496 if (unlikely(afinfo == NULL))
96497 return -EAFNOSUPPORT;
96498 - typemap = afinfo->type_map;
96499 + typemap = (const struct xfrm_type **)afinfo->type_map;
96500 spin_lock_bh(&xfrm_type_lock);
96501
96502 - if (likely(typemap[type->proto] == NULL))
96503 + if (likely(typemap[type->proto] == NULL)) {
96504 + pax_open_kernel();
96505 typemap[type->proto] = type;
96506 - else
96507 + pax_close_kernel();
96508 + } else
96509 err = -EEXIST;
96510 spin_unlock_bh(&xfrm_type_lock);
96511 xfrm_state_put_afinfo(afinfo);
96512 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
96513
96514 if (unlikely(afinfo == NULL))
96515 return -EAFNOSUPPORT;
96516 - typemap = afinfo->type_map;
96517 + typemap = (const struct xfrm_type **)afinfo->type_map;
96518 spin_lock_bh(&xfrm_type_lock);
96519
96520 if (unlikely(typemap[type->proto] != type))
96521 err = -ENOENT;
96522 - else
96523 + else {
96524 + pax_open_kernel();
96525 typemap[type->proto] = NULL;
96526 + pax_close_kernel();
96527 + }
96528 spin_unlock_bh(&xfrm_type_lock);
96529 xfrm_state_put_afinfo(afinfo);
96530 return err;
96531 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
96532 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
96533 {
96534 struct xfrm_state_afinfo *afinfo;
96535 - const struct xfrm_type **typemap;
96536 const struct xfrm_type *type;
96537 int modload_attempted = 0;
96538
96539 @@ -219,9 +223,8 @@ retry:
96540 afinfo = xfrm_state_get_afinfo(family);
96541 if (unlikely(afinfo == NULL))
96542 return NULL;
96543 - typemap = afinfo->type_map;
96544
96545 - type = typemap[proto];
96546 + type = afinfo->type_map[proto];
96547 if (unlikely(type && !try_module_get(type->owner)))
96548 type = NULL;
96549 if (!type && !modload_attempted) {
96550 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96551 return -EAFNOSUPPORT;
96552
96553 err = -EEXIST;
96554 - modemap = afinfo->mode_map;
96555 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96556 spin_lock_bh(&xfrm_mode_lock);
96557 if (modemap[mode->encap])
96558 goto out;
96559 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96560 if (!try_module_get(afinfo->owner))
96561 goto out;
96562
96563 - mode->afinfo = afinfo;
96564 + pax_open_kernel();
96565 + *(const void **)&mode->afinfo = afinfo;
96566 modemap[mode->encap] = mode;
96567 + pax_close_kernel();
96568 err = 0;
96569
96570 out:
96571 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
96572 return -EAFNOSUPPORT;
96573
96574 err = -ENOENT;
96575 - modemap = afinfo->mode_map;
96576 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96577 spin_lock_bh(&xfrm_mode_lock);
96578 if (likely(modemap[mode->encap] == mode)) {
96579 + pax_open_kernel();
96580 modemap[mode->encap] = NULL;
96581 + pax_close_kernel();
96582 module_put(mode->afinfo->owner);
96583 err = 0;
96584 }
96585 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
96586 u32 xfrm_get_acqseq(void)
96587 {
96588 u32 res;
96589 - static atomic_t acqseq;
96590 + static atomic_unchecked_t acqseq;
96591
96592 do {
96593 - res = atomic_inc_return(&acqseq);
96594 + res = atomic_inc_return_unchecked(&acqseq);
96595 } while (!res);
96596
96597 return res;
96598 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
96599 index 05a6e3d..6716ec9 100644
96600 --- a/net/xfrm/xfrm_sysctl.c
96601 +++ b/net/xfrm/xfrm_sysctl.c
96602 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
96603
96604 int __net_init xfrm_sysctl_init(struct net *net)
96605 {
96606 - struct ctl_table *table;
96607 + ctl_table_no_const *table;
96608
96609 __xfrm_sysctl_init(net);
96610
96611 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
96612 index 3f565e4..4b26cee 100644
96613 --- a/net/xfrm/xfrm_user.c
96614 +++ b/net/xfrm/xfrm_user.c
96615 @@ -1856,7 +1856,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
96616 if (x->km.state != XFRM_STATE_VALID)
96617 goto out;
96618
96619 - err = xfrm_replay_verify_len(x->replay_esn, rp);
96620 + err = xfrm_replay_verify_len(x->replay_esn, re);
96621 if (err)
96622 goto out;
96623
96624 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
96625 index d5d859c..781cbcb 100644
96626 --- a/scripts/Makefile.build
96627 +++ b/scripts/Makefile.build
96628 @@ -111,7 +111,7 @@ endif
96629 endif
96630
96631 # Do not include host rules unless needed
96632 -ifneq ($(hostprogs-y)$(hostprogs-m),)
96633 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
96634 include scripts/Makefile.host
96635 endif
96636
96637 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
96638 index 686cb0d..9d653bf 100644
96639 --- a/scripts/Makefile.clean
96640 +++ b/scripts/Makefile.clean
96641 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
96642 __clean-files := $(extra-y) $(always) \
96643 $(targets) $(clean-files) \
96644 $(host-progs) \
96645 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
96646 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
96647 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
96648
96649 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
96650
96651 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
96652 index 1ac414f..38575f7 100644
96653 --- a/scripts/Makefile.host
96654 +++ b/scripts/Makefile.host
96655 @@ -31,6 +31,8 @@
96656 # Note: Shared libraries consisting of C++ files are not supported
96657
96658 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
96659 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
96660 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
96661
96662 # C code
96663 # Executables compiled from a single .c file
96664 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
96665 # Shared libaries (only .c supported)
96666 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
96667 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
96668 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
96669 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
96670 # Remove .so files from "xxx-objs"
96671 host-cobjs := $(filter-out %.so,$(host-cobjs))
96672 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
96673
96674 -#Object (.o) files used by the shared libaries
96675 +# Object (.o) files used by the shared libaries
96676 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
96677 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
96678
96679 # output directory for programs/.o files
96680 # hostprogs-y := tools/build may have been specified. Retrieve directory
96681 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
96682 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
96683 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
96684 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
96685 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
96686 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
96687 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
96688 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
96689
96690 obj-dirs += $(host-objdirs)
96691 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
96692 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
96693 $(call if_changed_dep,host-cshobjs)
96694
96695 +# Compile .c file, create position independent .o file
96696 +# host-cxxshobjs -> .o
96697 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
96698 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
96699 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
96700 + $(call if_changed_dep,host-cxxshobjs)
96701 +
96702 # Link a shared library, based on position independent .o files
96703 # *.o -> .so shared library (host-cshlib)
96704 quiet_cmd_host-cshlib = HOSTLLD -shared $@
96705 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
96706 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
96707 $(call if_changed,host-cshlib)
96708
96709 +# Link a shared library, based on position independent .o files
96710 +# *.o -> .so shared library (host-cxxshlib)
96711 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
96712 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
96713 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
96714 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
96715 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
96716 + $(call if_changed,host-cxxshlib)
96717 +
96718 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
96719 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
96720 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
96721
96722 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
96723 index 078fe1d..fbdb363 100644
96724 --- a/scripts/basic/fixdep.c
96725 +++ b/scripts/basic/fixdep.c
96726 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
96727 /*
96728 * Lookup a value in the configuration string.
96729 */
96730 -static int is_defined_config(const char *name, int len, unsigned int hash)
96731 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
96732 {
96733 struct item *aux;
96734
96735 @@ -211,10 +211,10 @@ static void clear_config(void)
96736 /*
96737 * Record the use of a CONFIG_* word.
96738 */
96739 -static void use_config(const char *m, int slen)
96740 +static void use_config(const char *m, unsigned int slen)
96741 {
96742 unsigned int hash = strhash(m, slen);
96743 - int c, i;
96744 + unsigned int c, i;
96745
96746 if (is_defined_config(m, slen, hash))
96747 return;
96748 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
96749
96750 static void parse_config_file(const char *map, size_t len)
96751 {
96752 - const int *end = (const int *) (map + len);
96753 + const unsigned int *end = (const unsigned int *) (map + len);
96754 /* start at +1, so that p can never be < map */
96755 - const int *m = (const int *) map + 1;
96756 + const unsigned int *m = (const unsigned int *) map + 1;
96757 const char *p, *q;
96758
96759 for (; m < end; m++) {
96760 @@ -435,7 +435,7 @@ static void print_deps(void)
96761 static void traps(void)
96762 {
96763 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
96764 - int *p = (int *)test;
96765 + unsigned int *p = (unsigned int *)test;
96766
96767 if (*p != INT_CONF) {
96768 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
96769 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
96770 new file mode 100644
96771 index 0000000..5e0222d
96772 --- /dev/null
96773 +++ b/scripts/gcc-plugin.sh
96774 @@ -0,0 +1,17 @@
96775 +#!/bin/bash
96776 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
96777 +#include "gcc-plugin.h"
96778 +#include "tree.h"
96779 +#include "tm.h"
96780 +#include "rtl.h"
96781 +#ifdef ENABLE_BUILD_WITH_CXX
96782 +#warning $2
96783 +#else
96784 +#warning $1
96785 +#endif
96786 +EOF`
96787 +if [ $? -eq 0 ]
96788 +then
96789 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
96790 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
96791 +fi
96792 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
96793 index 5de5660..d3deb89 100644
96794 --- a/scripts/headers_install.sh
96795 +++ b/scripts/headers_install.sh
96796 @@ -32,6 +32,7 @@ do
96797 FILE="$(basename "$i")"
96798 sed -r \
96799 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
96800 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
96801 -e 's/__attribute_const__([ \t]|$)/\1/g' \
96802 -e 's@^#include <linux/compiler.h>@@' \
96803 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
96804 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
96805 index 0149949..d482a0d 100644
96806 --- a/scripts/link-vmlinux.sh
96807 +++ b/scripts/link-vmlinux.sh
96808 @@ -158,7 +158,7 @@ else
96809 fi;
96810
96811 # final build of init/
96812 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
96813 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
96814
96815 kallsymso=""
96816 kallsyms_vmlinux=""
96817 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
96818 index 2370863..212fbca 100644
96819 --- a/scripts/mod/file2alias.c
96820 +++ b/scripts/mod/file2alias.c
96821 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
96822 unsigned long size, unsigned long id_size,
96823 void *symval)
96824 {
96825 - int i;
96826 + unsigned int i;
96827
96828 if (size % id_size || size < id_size) {
96829 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
96830 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
96831 /* USB is special because the bcdDevice can be matched against a numeric range */
96832 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
96833 static void do_usb_entry(void *symval,
96834 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
96835 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
96836 unsigned char range_lo, unsigned char range_hi,
96837 unsigned char max, struct module *mod)
96838 {
96839 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
96840 {
96841 unsigned int devlo, devhi;
96842 unsigned char chi, clo, max;
96843 - int ndigits;
96844 + unsigned int ndigits;
96845
96846 DEF_FIELD(symval, usb_device_id, match_flags);
96847 DEF_FIELD(symval, usb_device_id, idVendor);
96848 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
96849 for (i = 0; i < count; i++) {
96850 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
96851 char acpi_id[sizeof(*id)];
96852 - int j;
96853 + unsigned int j;
96854
96855 buf_printf(&mod->dev_table_buf,
96856 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
96857 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
96858
96859 for (j = 0; j < PNP_MAX_DEVICES; j++) {
96860 const char *id = (char *)(*devs)[j].id;
96861 - int i2, j2;
96862 + unsigned int i2, j2;
96863 int dup = 0;
96864
96865 if (!id[0])
96866 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
96867 /* add an individual alias for every device entry */
96868 if (!dup) {
96869 char acpi_id[PNP_ID_LEN];
96870 - int k;
96871 + unsigned int k;
96872
96873 buf_printf(&mod->dev_table_buf,
96874 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
96875 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
96876 static int do_dmi_entry(const char *filename, void *symval,
96877 char *alias)
96878 {
96879 - int i, j;
96880 + unsigned int i, j;
96881 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
96882 sprintf(alias, "dmi*");
96883
96884 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
96885 index 6216434..050cf89 100644
96886 --- a/scripts/mod/modpost.c
96887 +++ b/scripts/mod/modpost.c
96888 @@ -930,6 +930,7 @@ enum mismatch {
96889 ANY_INIT_TO_ANY_EXIT,
96890 ANY_EXIT_TO_ANY_INIT,
96891 EXPORT_TO_INIT_EXIT,
96892 + DATA_TO_TEXT
96893 };
96894
96895 struct sectioncheck {
96896 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
96897 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
96898 .mismatch = EXPORT_TO_INIT_EXIT,
96899 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
96900 +},
96901 +/* Do not reference code from writable data */
96902 +{
96903 + .fromsec = { DATA_SECTIONS, NULL },
96904 + .tosec = { TEXT_SECTIONS, NULL },
96905 + .mismatch = DATA_TO_TEXT
96906 }
96907 };
96908
96909 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
96910 continue;
96911 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
96912 continue;
96913 - if (sym->st_value == addr)
96914 - return sym;
96915 /* Find a symbol nearby - addr are maybe negative */
96916 d = sym->st_value - addr;
96917 + if (d == 0)
96918 + return sym;
96919 if (d < 0)
96920 d = addr - sym->st_value;
96921 if (d < distance) {
96922 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
96923 tosym, prl_to, prl_to, tosym);
96924 free(prl_to);
96925 break;
96926 + case DATA_TO_TEXT:
96927 +#if 0
96928 + fprintf(stderr,
96929 + "The %s %s:%s references\n"
96930 + "the %s %s:%s%s\n",
96931 + from, fromsec, fromsym, to, tosec, tosym, to_p);
96932 +#endif
96933 + break;
96934 }
96935 fprintf(stderr, "\n");
96936 }
96937 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
96938 static void check_sec_ref(struct module *mod, const char *modname,
96939 struct elf_info *elf)
96940 {
96941 - int i;
96942 + unsigned int i;
96943 Elf_Shdr *sechdrs = elf->sechdrs;
96944
96945 /* Walk through all sections */
96946 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
96947 va_end(ap);
96948 }
96949
96950 -void buf_write(struct buffer *buf, const char *s, int len)
96951 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
96952 {
96953 if (buf->size - buf->pos < len) {
96954 buf->size += len + SZ;
96955 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
96956 if (fstat(fileno(file), &st) < 0)
96957 goto close_write;
96958
96959 - if (st.st_size != b->pos)
96960 + if (st.st_size != (off_t)b->pos)
96961 goto close_write;
96962
96963 tmp = NOFAIL(malloc(b->pos));
96964 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
96965 index 51207e4..f7d603d 100644
96966 --- a/scripts/mod/modpost.h
96967 +++ b/scripts/mod/modpost.h
96968 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
96969
96970 struct buffer {
96971 char *p;
96972 - int pos;
96973 - int size;
96974 + unsigned int pos;
96975 + unsigned int size;
96976 };
96977
96978 void __attribute__((format(printf, 2, 3)))
96979 buf_printf(struct buffer *buf, const char *fmt, ...);
96980
96981 void
96982 -buf_write(struct buffer *buf, const char *s, int len);
96983 +buf_write(struct buffer *buf, const char *s, unsigned int len);
96984
96985 struct module {
96986 struct module *next;
96987 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
96988 index 9dfcd6d..099068e 100644
96989 --- a/scripts/mod/sumversion.c
96990 +++ b/scripts/mod/sumversion.c
96991 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
96992 goto out;
96993 }
96994
96995 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
96996 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
96997 warn("writing sum in %s failed: %s\n",
96998 filename, strerror(errno));
96999 goto out;
97000 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97001 index acb8650..b8c5f02 100644
97002 --- a/scripts/package/builddeb
97003 +++ b/scripts/package/builddeb
97004 @@ -246,6 +246,7 @@ fi
97005 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97006 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97007 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97008 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97009 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97010 mkdir -p "$destdir"
97011 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97012 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97013 index 68bb4ef..2f419e1 100644
97014 --- a/scripts/pnmtologo.c
97015 +++ b/scripts/pnmtologo.c
97016 @@ -244,14 +244,14 @@ static void write_header(void)
97017 fprintf(out, " * Linux logo %s\n", logoname);
97018 fputs(" */\n\n", out);
97019 fputs("#include <linux/linux_logo.h>\n\n", out);
97020 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97021 + fprintf(out, "static unsigned char %s_data[] = {\n",
97022 logoname);
97023 }
97024
97025 static void write_footer(void)
97026 {
97027 fputs("\n};\n\n", out);
97028 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97029 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97030 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97031 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97032 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97033 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97034 fputs("\n};\n\n", out);
97035
97036 /* write logo clut */
97037 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97038 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97039 logoname);
97040 write_hex_cnt = 0;
97041 for (i = 0; i < logo_clutsize; i++) {
97042 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97043 index f5eb43d..1814de8 100644
97044 --- a/scripts/sortextable.h
97045 +++ b/scripts/sortextable.h
97046 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97047 const char *secstrtab;
97048 const char *strtab;
97049 char *extab_image;
97050 - int extab_index = 0;
97051 - int i;
97052 - int idx;
97053 + unsigned int extab_index = 0;
97054 + unsigned int i;
97055 + unsigned int idx;
97056
97057 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97058 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97059 diff --git a/security/Kconfig b/security/Kconfig
97060 index e9c6ac7..c5d45c8 100644
97061 --- a/security/Kconfig
97062 +++ b/security/Kconfig
97063 @@ -4,6 +4,959 @@
97064
97065 menu "Security options"
97066
97067 +menu "Grsecurity"
97068 +
97069 + config ARCH_TRACK_EXEC_LIMIT
97070 + bool
97071 +
97072 + config PAX_KERNEXEC_PLUGIN
97073 + bool
97074 +
97075 + config PAX_PER_CPU_PGD
97076 + bool
97077 +
97078 + config TASK_SIZE_MAX_SHIFT
97079 + int
97080 + depends on X86_64
97081 + default 47 if !PAX_PER_CPU_PGD
97082 + default 42 if PAX_PER_CPU_PGD
97083 +
97084 + config PAX_ENABLE_PAE
97085 + bool
97086 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97087 +
97088 + config PAX_USERCOPY_SLABS
97089 + bool
97090 +
97091 +config GRKERNSEC
97092 + bool "Grsecurity"
97093 + select CRYPTO
97094 + select CRYPTO_SHA256
97095 + select PROC_FS
97096 + select STOP_MACHINE
97097 + select TTY
97098 + help
97099 + If you say Y here, you will be able to configure many features
97100 + that will enhance the security of your system. It is highly
97101 + recommended that you say Y here and read through the help
97102 + for each option so that you fully understand the features and
97103 + can evaluate their usefulness for your machine.
97104 +
97105 +choice
97106 + prompt "Configuration Method"
97107 + depends on GRKERNSEC
97108 + default GRKERNSEC_CONFIG_CUSTOM
97109 + help
97110 +
97111 +config GRKERNSEC_CONFIG_AUTO
97112 + bool "Automatic"
97113 + help
97114 + If you choose this configuration method, you'll be able to answer a small
97115 + number of simple questions about how you plan to use this kernel.
97116 + The settings of grsecurity and PaX will be automatically configured for
97117 + the highest commonly-used settings within the provided constraints.
97118 +
97119 + If you require additional configuration, custom changes can still be made
97120 + from the "custom configuration" menu.
97121 +
97122 +config GRKERNSEC_CONFIG_CUSTOM
97123 + bool "Custom"
97124 + help
97125 + If you choose this configuration method, you'll be able to configure all
97126 + grsecurity and PaX settings manually. Via this method, no options are
97127 + automatically enabled.
97128 +
97129 +endchoice
97130 +
97131 +choice
97132 + prompt "Usage Type"
97133 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97134 + default GRKERNSEC_CONFIG_SERVER
97135 + help
97136 +
97137 +config GRKERNSEC_CONFIG_SERVER
97138 + bool "Server"
97139 + help
97140 + Choose this option if you plan to use this kernel on a server.
97141 +
97142 +config GRKERNSEC_CONFIG_DESKTOP
97143 + bool "Desktop"
97144 + help
97145 + Choose this option if you plan to use this kernel on a desktop.
97146 +
97147 +endchoice
97148 +
97149 +choice
97150 + prompt "Virtualization Type"
97151 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
97152 + default GRKERNSEC_CONFIG_VIRT_NONE
97153 + help
97154 +
97155 +config GRKERNSEC_CONFIG_VIRT_NONE
97156 + bool "None"
97157 + help
97158 + Choose this option if this kernel will be run on bare metal.
97159 +
97160 +config GRKERNSEC_CONFIG_VIRT_GUEST
97161 + bool "Guest"
97162 + help
97163 + Choose this option if this kernel will be run as a VM guest.
97164 +
97165 +config GRKERNSEC_CONFIG_VIRT_HOST
97166 + bool "Host"
97167 + help
97168 + Choose this option if this kernel will be run as a VM host.
97169 +
97170 +endchoice
97171 +
97172 +choice
97173 + prompt "Virtualization Hardware"
97174 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97175 + help
97176 +
97177 +config GRKERNSEC_CONFIG_VIRT_EPT
97178 + bool "EPT/RVI Processor Support"
97179 + depends on X86
97180 + help
97181 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
97182 + hardware virtualization. This allows for additional kernel hardening protections
97183 + to operate without additional performance impact.
97184 +
97185 + To see if your Intel processor supports EPT, see:
97186 + http://ark.intel.com/Products/VirtualizationTechnology
97187 + (Most Core i3/5/7 support EPT)
97188 +
97189 + To see if your AMD processor supports RVI, see:
97190 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
97191 +
97192 +config GRKERNSEC_CONFIG_VIRT_SOFT
97193 + bool "First-gen/No Hardware Virtualization"
97194 + help
97195 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
97196 + support hardware virtualization or doesn't support the EPT/RVI extensions.
97197 +
97198 +endchoice
97199 +
97200 +choice
97201 + prompt "Virtualization Software"
97202 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97203 + help
97204 +
97205 +config GRKERNSEC_CONFIG_VIRT_XEN
97206 + bool "Xen"
97207 + help
97208 + Choose this option if this kernel is running as a Xen guest or host.
97209 +
97210 +config GRKERNSEC_CONFIG_VIRT_VMWARE
97211 + bool "VMWare"
97212 + help
97213 + Choose this option if this kernel is running as a VMWare guest or host.
97214 +
97215 +config GRKERNSEC_CONFIG_VIRT_KVM
97216 + bool "KVM"
97217 + help
97218 + Choose this option if this kernel is running as a KVM guest or host.
97219 +
97220 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
97221 + bool "VirtualBox"
97222 + help
97223 + Choose this option if this kernel is running as a VirtualBox guest or host.
97224 +
97225 +endchoice
97226 +
97227 +choice
97228 + prompt "Required Priorities"
97229 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97230 + default GRKERNSEC_CONFIG_PRIORITY_PERF
97231 + help
97232 +
97233 +config GRKERNSEC_CONFIG_PRIORITY_PERF
97234 + bool "Performance"
97235 + help
97236 + Choose this option if performance is of highest priority for this deployment
97237 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
97238 + clearing of structures intended for userland, and freed memory sanitizing will
97239 + be disabled.
97240 +
97241 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
97242 + bool "Security"
97243 + help
97244 + Choose this option if security is of highest priority for this deployment of
97245 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
97246 + for userland, and freed memory sanitizing will be enabled for this kernel.
97247 + In a worst-case scenario, these features can introduce a 20% performance hit
97248 + (UDEREF on x64 contributing half of this hit).
97249 +
97250 +endchoice
97251 +
97252 +menu "Default Special Groups"
97253 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97254 +
97255 +config GRKERNSEC_PROC_GID
97256 + int "GID exempted from /proc restrictions"
97257 + default 1001
97258 + help
97259 + Setting this GID determines which group will be exempted from
97260 + grsecurity's /proc restrictions, allowing users of the specified
97261 + group to view network statistics and the existence of other users'
97262 + processes on the system. This GID may also be chosen at boot time
97263 + via "grsec_proc_gid=" on the kernel commandline.
97264 +
97265 +config GRKERNSEC_TPE_UNTRUSTED_GID
97266 + int "GID for TPE-untrusted users"
97267 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
97268 + default 1005
97269 + help
97270 + Setting this GID determines which group untrusted users should
97271 + be added to. These users will be placed under grsecurity's Trusted Path
97272 + Execution mechanism, preventing them from executing their own binaries.
97273 + The users will only be able to execute binaries in directories owned and
97274 + writable only by the root user. If the sysctl option is enabled, a sysctl
97275 + option with name "tpe_gid" is created.
97276 +
97277 +config GRKERNSEC_TPE_TRUSTED_GID
97278 + int "GID for TPE-trusted users"
97279 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
97280 + default 1005
97281 + help
97282 + Setting this GID determines what group TPE restrictions will be
97283 + *disabled* for. If the sysctl option is enabled, a sysctl option
97284 + with name "tpe_gid" is created.
97285 +
97286 +config GRKERNSEC_SYMLINKOWN_GID
97287 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
97288 + depends on GRKERNSEC_CONFIG_SERVER
97289 + default 1006
97290 + help
97291 + Setting this GID determines what group kernel-enforced
97292 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
97293 + is enabled, a sysctl option with name "symlinkown_gid" is created.
97294 +
97295 +
97296 +endmenu
97297 +
97298 +menu "Customize Configuration"
97299 +depends on GRKERNSEC
97300 +
97301 +menu "PaX"
97302 +
97303 +config PAX
97304 + bool "Enable various PaX features"
97305 + default y if GRKERNSEC_CONFIG_AUTO
97306 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
97307 + help
97308 + This allows you to enable various PaX features. PaX adds
97309 + intrusion prevention mechanisms to the kernel that reduce
97310 + the risks posed by exploitable memory corruption bugs.
97311 +
97312 +menu "PaX Control"
97313 + depends on PAX
97314 +
97315 +config PAX_SOFTMODE
97316 + bool 'Support soft mode'
97317 + help
97318 + Enabling this option will allow you to run PaX in soft mode, that
97319 + is, PaX features will not be enforced by default, only on executables
97320 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
97321 + support as they are the only way to mark executables for soft mode use.
97322 +
97323 + Soft mode can be activated by using the "pax_softmode=1" kernel command
97324 + line option on boot. Furthermore you can control various PaX features
97325 + at runtime via the entries in /proc/sys/kernel/pax.
97326 +
97327 +config PAX_EI_PAX
97328 + bool 'Use legacy ELF header marking'
97329 + default y if GRKERNSEC_CONFIG_AUTO
97330 + help
97331 + Enabling this option will allow you to control PaX features on
97332 + a per executable basis via the 'chpax' utility available at
97333 + http://pax.grsecurity.net/. The control flags will be read from
97334 + an otherwise reserved part of the ELF header. This marking has
97335 + numerous drawbacks (no support for soft-mode, toolchain does not
97336 + know about the non-standard use of the ELF header) therefore it
97337 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
97338 + support.
97339 +
97340 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
97341 + support as well, they will override the legacy EI_PAX marks.
97342 +
97343 + If you enable none of the marking options then all applications
97344 + will run with PaX enabled on them by default.
97345 +
97346 +config PAX_PT_PAX_FLAGS
97347 + bool 'Use ELF program header marking'
97348 + default y if GRKERNSEC_CONFIG_AUTO
97349 + help
97350 + Enabling this option will allow you to control PaX features on
97351 + a per executable basis via the 'paxctl' utility available at
97352 + http://pax.grsecurity.net/. The control flags will be read from
97353 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
97354 + has the benefits of supporting both soft mode and being fully
97355 + integrated into the toolchain (the binutils patch is available
97356 + from http://pax.grsecurity.net).
97357 +
97358 + Note that if you enable the legacy EI_PAX marking support as well,
97359 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
97360 +
97361 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97362 + must make sure that the marks are the same if a binary has both marks.
97363 +
97364 + If you enable none of the marking options then all applications
97365 + will run with PaX enabled on them by default.
97366 +
97367 +config PAX_XATTR_PAX_FLAGS
97368 + bool 'Use filesystem extended attributes marking'
97369 + default y if GRKERNSEC_CONFIG_AUTO
97370 + select CIFS_XATTR if CIFS
97371 + select EXT2_FS_XATTR if EXT2_FS
97372 + select EXT3_FS_XATTR if EXT3_FS
97373 + select EXT4_FS_XATTR if EXT4_FS
97374 + select JFFS2_FS_XATTR if JFFS2_FS
97375 + select REISERFS_FS_XATTR if REISERFS_FS
97376 + select SQUASHFS_XATTR if SQUASHFS
97377 + select TMPFS_XATTR if TMPFS
97378 + select UBIFS_FS_XATTR if UBIFS_FS
97379 + help
97380 + Enabling this option will allow you to control PaX features on
97381 + a per executable basis via the 'setfattr' utility. The control
97382 + flags will be read from the user.pax.flags extended attribute of
97383 + the file. This marking has the benefit of supporting binary-only
97384 + applications that self-check themselves (e.g., skype) and would
97385 + not tolerate chpax/paxctl changes. The main drawback is that
97386 + extended attributes are not supported by some filesystems (e.g.,
97387 + isofs, udf, vfat) so copying files through such filesystems will
97388 + lose the extended attributes and these PaX markings.
97389 +
97390 + Note that if you enable the legacy EI_PAX marking support as well,
97391 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
97392 +
97393 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97394 + must make sure that the marks are the same if a binary has both marks.
97395 +
97396 + If you enable none of the marking options then all applications
97397 + will run with PaX enabled on them by default.
97398 +
97399 +choice
97400 + prompt 'MAC system integration'
97401 + default PAX_HAVE_ACL_FLAGS
97402 + help
97403 + Mandatory Access Control systems have the option of controlling
97404 + PaX flags on a per executable basis, choose the method supported
97405 + by your particular system.
97406 +
97407 + - "none": if your MAC system does not interact with PaX,
97408 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
97409 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
97410 +
97411 + NOTE: this option is for developers/integrators only.
97412 +
97413 + config PAX_NO_ACL_FLAGS
97414 + bool 'none'
97415 +
97416 + config PAX_HAVE_ACL_FLAGS
97417 + bool 'direct'
97418 +
97419 + config PAX_HOOK_ACL_FLAGS
97420 + bool 'hook'
97421 +endchoice
97422 +
97423 +endmenu
97424 +
97425 +menu "Non-executable pages"
97426 + depends on PAX
97427 +
97428 +config PAX_NOEXEC
97429 + bool "Enforce non-executable pages"
97430 + default y if GRKERNSEC_CONFIG_AUTO
97431 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
97432 + help
97433 + By design some architectures do not allow for protecting memory
97434 + pages against execution or even if they do, Linux does not make
97435 + use of this feature. In practice this means that if a page is
97436 + readable (such as the stack or heap) it is also executable.
97437 +
97438 + There is a well known exploit technique that makes use of this
97439 + fact and a common programming mistake where an attacker can
97440 + introduce code of his choice somewhere in the attacked program's
97441 + memory (typically the stack or the heap) and then execute it.
97442 +
97443 + If the attacked program was running with different (typically
97444 + higher) privileges than that of the attacker, then he can elevate
97445 + his own privilege level (e.g. get a root shell, write to files for
97446 + which he does not have write access to, etc).
97447 +
97448 + Enabling this option will let you choose from various features
97449 + that prevent the injection and execution of 'foreign' code in
97450 + a program.
97451 +
97452 + This will also break programs that rely on the old behaviour and
97453 + expect that dynamically allocated memory via the malloc() family
97454 + of functions is executable (which it is not). Notable examples
97455 + are the XFree86 4.x server, the java runtime and wine.
97456 +
97457 +config PAX_PAGEEXEC
97458 + bool "Paging based non-executable pages"
97459 + default y if GRKERNSEC_CONFIG_AUTO
97460 + 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)
97461 + select ARCH_TRACK_EXEC_LIMIT if X86_32
97462 + help
97463 + This implementation is based on the paging feature of the CPU.
97464 + On i386 without hardware non-executable bit support there is a
97465 + variable but usually low performance impact, however on Intel's
97466 + P4 core based CPUs it is very high so you should not enable this
97467 + for kernels meant to be used on such CPUs.
97468 +
97469 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
97470 + with hardware non-executable bit support there is no performance
97471 + impact, on ppc the impact is negligible.
97472 +
97473 + Note that several architectures require various emulations due to
97474 + badly designed userland ABIs, this will cause a performance impact
97475 + but will disappear as soon as userland is fixed. For example, ppc
97476 + userland MUST have been built with secure-plt by a recent toolchain.
97477 +
97478 +config PAX_SEGMEXEC
97479 + bool "Segmentation based non-executable pages"
97480 + default y if GRKERNSEC_CONFIG_AUTO
97481 + depends on PAX_NOEXEC && X86_32
97482 + help
97483 + This implementation is based on the segmentation feature of the
97484 + CPU and has a very small performance impact, however applications
97485 + will be limited to a 1.5 GB address space instead of the normal
97486 + 3 GB.
97487 +
97488 +config PAX_EMUTRAMP
97489 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
97490 + default y if PARISC
97491 + help
97492 + There are some programs and libraries that for one reason or
97493 + another attempt to execute special small code snippets from
97494 + non-executable memory pages. Most notable examples are the
97495 + signal handler return code generated by the kernel itself and
97496 + the GCC trampolines.
97497 +
97498 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
97499 + such programs will no longer work under your kernel.
97500 +
97501 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
97502 + utilities to enable trampoline emulation for the affected programs
97503 + yet still have the protection provided by the non-executable pages.
97504 +
97505 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
97506 + your system will not even boot.
97507 +
97508 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
97509 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
97510 + for the affected files.
97511 +
97512 + NOTE: enabling this feature *may* open up a loophole in the
97513 + protection provided by non-executable pages that an attacker
97514 + could abuse. Therefore the best solution is to not have any
97515 + files on your system that would require this option. This can
97516 + be achieved by not using libc5 (which relies on the kernel
97517 + signal handler return code) and not using or rewriting programs
97518 + that make use of the nested function implementation of GCC.
97519 + Skilled users can just fix GCC itself so that it implements
97520 + nested function calls in a way that does not interfere with PaX.
97521 +
97522 +config PAX_EMUSIGRT
97523 + bool "Automatically emulate sigreturn trampolines"
97524 + depends on PAX_EMUTRAMP && PARISC
97525 + default y
97526 + help
97527 + Enabling this option will have the kernel automatically detect
97528 + and emulate signal return trampolines executing on the stack
97529 + that would otherwise lead to task termination.
97530 +
97531 + This solution is intended as a temporary one for users with
97532 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
97533 + Modula-3 runtime, etc) or executables linked to such, basically
97534 + everything that does not specify its own SA_RESTORER function in
97535 + normal executable memory like glibc 2.1+ does.
97536 +
97537 + On parisc you MUST enable this option, otherwise your system will
97538 + not even boot.
97539 +
97540 + NOTE: this feature cannot be disabled on a per executable basis
97541 + and since it *does* open up a loophole in the protection provided
97542 + by non-executable pages, the best solution is to not have any
97543 + files on your system that would require this option.
97544 +
97545 +config PAX_MPROTECT
97546 + bool "Restrict mprotect()"
97547 + default y if GRKERNSEC_CONFIG_AUTO
97548 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
97549 + help
97550 + Enabling this option will prevent programs from
97551 + - changing the executable status of memory pages that were
97552 + not originally created as executable,
97553 + - making read-only executable pages writable again,
97554 + - creating executable pages from anonymous memory,
97555 + - making read-only-after-relocations (RELRO) data pages writable again.
97556 +
97557 + You should say Y here to complete the protection provided by
97558 + the enforcement of non-executable pages.
97559 +
97560 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97561 + this feature on a per file basis.
97562 +
97563 +config PAX_MPROTECT_COMPAT
97564 + bool "Use legacy/compat protection demoting (read help)"
97565 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97566 + depends on PAX_MPROTECT
97567 + help
97568 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
97569 + by sending the proper error code to the application. For some broken
97570 + userland, this can cause problems with Python or other applications. The
97571 + current implementation however allows for applications like clamav to
97572 + detect if JIT compilation/execution is allowed and to fall back gracefully
97573 + to an interpreter-based mode if it does not. While we encourage everyone
97574 + to use the current implementation as-is and push upstream to fix broken
97575 + userland (note that the RWX logging option can assist with this), in some
97576 + environments this may not be possible. Having to disable MPROTECT
97577 + completely on certain binaries reduces the security benefit of PaX,
97578 + so this option is provided for those environments to revert to the old
97579 + behavior.
97580 +
97581 +config PAX_ELFRELOCS
97582 + bool "Allow ELF text relocations (read help)"
97583 + depends on PAX_MPROTECT
97584 + default n
97585 + help
97586 + Non-executable pages and mprotect() restrictions are effective
97587 + in preventing the introduction of new executable code into an
97588 + attacked task's address space. There remain only two venues
97589 + for this kind of attack: if the attacker can execute already
97590 + existing code in the attacked task then he can either have it
97591 + create and mmap() a file containing his code or have it mmap()
97592 + an already existing ELF library that does not have position
97593 + independent code in it and use mprotect() on it to make it
97594 + writable and copy his code there. While protecting against
97595 + the former approach is beyond PaX, the latter can be prevented
97596 + by having only PIC ELF libraries on one's system (which do not
97597 + need to relocate their code). If you are sure this is your case,
97598 + as is the case with all modern Linux distributions, then leave
97599 + this option disabled. You should say 'n' here.
97600 +
97601 +config PAX_ETEXECRELOCS
97602 + bool "Allow ELF ET_EXEC text relocations"
97603 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
97604 + select PAX_ELFRELOCS
97605 + default y
97606 + help
97607 + On some architectures there are incorrectly created applications
97608 + that require text relocations and would not work without enabling
97609 + this option. If you are an alpha, ia64 or parisc user, you should
97610 + enable this option and disable it once you have made sure that
97611 + none of your applications need it.
97612 +
97613 +config PAX_EMUPLT
97614 + bool "Automatically emulate ELF PLT"
97615 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
97616 + default y
97617 + help
97618 + Enabling this option will have the kernel automatically detect
97619 + and emulate the Procedure Linkage Table entries in ELF files.
97620 + On some architectures such entries are in writable memory, and
97621 + become non-executable leading to task termination. Therefore
97622 + it is mandatory that you enable this option on alpha, parisc,
97623 + sparc and sparc64, otherwise your system would not even boot.
97624 +
97625 + NOTE: this feature *does* open up a loophole in the protection
97626 + provided by the non-executable pages, therefore the proper
97627 + solution is to modify the toolchain to produce a PLT that does
97628 + not need to be writable.
97629 +
97630 +config PAX_DLRESOLVE
97631 + bool 'Emulate old glibc resolver stub'
97632 + depends on PAX_EMUPLT && SPARC
97633 + default n
97634 + help
97635 + This option is needed if userland has an old glibc (before 2.4)
97636 + that puts a 'save' instruction into the runtime generated resolver
97637 + stub that needs special emulation.
97638 +
97639 +config PAX_KERNEXEC
97640 + bool "Enforce non-executable kernel pages"
97641 + 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))
97642 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
97643 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
97644 + select PAX_KERNEXEC_PLUGIN if X86_64
97645 + help
97646 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
97647 + that is, enabling this option will make it harder to inject
97648 + and execute 'foreign' code in kernel memory itself.
97649 +
97650 +choice
97651 + prompt "Return Address Instrumentation Method"
97652 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
97653 + depends on PAX_KERNEXEC_PLUGIN
97654 + help
97655 + Select the method used to instrument function pointer dereferences.
97656 + Note that binary modules cannot be instrumented by this approach.
97657 +
97658 + Note that the implementation requires a gcc with plugin support,
97659 + i.e., gcc 4.5 or newer. You may need to install the supporting
97660 + headers explicitly in addition to the normal gcc package.
97661 +
97662 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
97663 + bool "bts"
97664 + help
97665 + This method is compatible with binary only modules but has
97666 + a higher runtime overhead.
97667 +
97668 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
97669 + bool "or"
97670 + depends on !PARAVIRT
97671 + help
97672 + This method is incompatible with binary only modules but has
97673 + a lower runtime overhead.
97674 +endchoice
97675 +
97676 +config PAX_KERNEXEC_PLUGIN_METHOD
97677 + string
97678 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
97679 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
97680 + default ""
97681 +
97682 +config PAX_KERNEXEC_MODULE_TEXT
97683 + int "Minimum amount of memory reserved for module code"
97684 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
97685 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97686 + depends on PAX_KERNEXEC && X86_32
97687 + help
97688 + Due to implementation details the kernel must reserve a fixed
97689 + amount of memory for runtime allocated code (such as modules)
97690 + at compile time that cannot be changed at runtime. Here you
97691 + can specify the minimum amount in MB that will be reserved.
97692 + Due to the same implementation details this size will always
97693 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
97694 + the actually available memory for runtime allocated code will
97695 + usually be more than this minimum.
97696 +
97697 + The default 4 MB should be enough for most users but if you have
97698 + an excessive number of modules (e.g., most distribution configs
97699 + compile many drivers as modules) or use huge modules such as
97700 + nvidia's kernel driver, you will need to adjust this amount.
97701 + A good rule of thumb is to look at your currently loaded kernel
97702 + modules and add up their sizes.
97703 +
97704 +endmenu
97705 +
97706 +menu "Address Space Layout Randomization"
97707 + depends on PAX
97708 +
97709 +config PAX_ASLR
97710 + bool "Address Space Layout Randomization"
97711 + default y if GRKERNSEC_CONFIG_AUTO
97712 + help
97713 + Many if not most exploit techniques rely on the knowledge of
97714 + certain addresses in the attacked program. The following options
97715 + will allow the kernel to apply a certain amount of randomization
97716 + to specific parts of the program thereby forcing an attacker to
97717 + guess them in most cases. Any failed guess will most likely crash
97718 + the attacked program which allows the kernel to detect such attempts
97719 + and react on them. PaX itself provides no reaction mechanisms,
97720 + instead it is strongly encouraged that you make use of Nergal's
97721 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
97722 + (http://www.grsecurity.net/) built-in crash detection features or
97723 + develop one yourself.
97724 +
97725 + By saying Y here you can choose to randomize the following areas:
97726 + - top of the task's kernel stack
97727 + - top of the task's userland stack
97728 + - base address for mmap() requests that do not specify one
97729 + (this includes all libraries)
97730 + - base address of the main executable
97731 +
97732 + It is strongly recommended to say Y here as address space layout
97733 + randomization has negligible impact on performance yet it provides
97734 + a very effective protection.
97735 +
97736 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97737 + this feature on a per file basis.
97738 +
97739 +config PAX_RANDKSTACK
97740 + bool "Randomize kernel stack base"
97741 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
97742 + depends on X86_TSC && X86
97743 + help
97744 + By saying Y here the kernel will randomize every task's kernel
97745 + stack on every system call. This will not only force an attacker
97746 + to guess it but also prevent him from making use of possible
97747 + leaked information about it.
97748 +
97749 + Since the kernel stack is a rather scarce resource, randomization
97750 + may cause unexpected stack overflows, therefore you should very
97751 + carefully test your system. Note that once enabled in the kernel
97752 + configuration, this feature cannot be disabled on a per file basis.
97753 +
97754 +config PAX_RANDUSTACK
97755 + bool "Randomize user stack base"
97756 + default y if GRKERNSEC_CONFIG_AUTO
97757 + depends on PAX_ASLR
97758 + help
97759 + By saying Y here the kernel will randomize every task's userland
97760 + stack. The randomization is done in two steps where the second
97761 + one may apply a big amount of shift to the top of the stack and
97762 + cause problems for programs that want to use lots of memory (more
97763 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
97764 + For this reason the second step can be controlled by 'chpax' or
97765 + 'paxctl' on a per file basis.
97766 +
97767 +config PAX_RANDMMAP
97768 + bool "Randomize mmap() base"
97769 + default y if GRKERNSEC_CONFIG_AUTO
97770 + depends on PAX_ASLR
97771 + help
97772 + By saying Y here the kernel will use a randomized base address for
97773 + mmap() requests that do not specify one themselves. As a result
97774 + all dynamically loaded libraries will appear at random addresses
97775 + and therefore be harder to exploit by a technique where an attacker
97776 + attempts to execute library code for his purposes (e.g. spawn a
97777 + shell from an exploited program that is running at an elevated
97778 + privilege level).
97779 +
97780 + Furthermore, if a program is relinked as a dynamic ELF file, its
97781 + base address will be randomized as well, completing the full
97782 + randomization of the address space layout. Attacking such programs
97783 + becomes a guess game. You can find an example of doing this at
97784 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
97785 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
97786 +
97787 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
97788 + feature on a per file basis.
97789 +
97790 +endmenu
97791 +
97792 +menu "Miscellaneous hardening features"
97793 +
97794 +config PAX_MEMORY_SANITIZE
97795 + bool "Sanitize all freed memory"
97796 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97797 + depends on !HIBERNATION
97798 + help
97799 + By saying Y here the kernel will erase memory pages and slab objects
97800 + as soon as they are freed. This in turn reduces the lifetime of data
97801 + stored in them, making it less likely that sensitive information such
97802 + as passwords, cryptographic secrets, etc stay in memory for too long.
97803 +
97804 + This is especially useful for programs whose runtime is short, long
97805 + lived processes and the kernel itself benefit from this as long as
97806 + they ensure timely freeing of memory that may hold sensitive
97807 + information.
97808 +
97809 + A nice side effect of the sanitization of slab objects is the
97810 + reduction of possible info leaks caused by padding bytes within the
97811 + leaky structures. Use-after-free bugs for structures containing
97812 + pointers can also be detected as dereferencing the sanitized pointer
97813 + will generate an access violation.
97814 +
97815 + The tradeoff is performance impact, on a single CPU system kernel
97816 + compilation sees a 3% slowdown, other systems and workloads may vary
97817 + and you are advised to test this feature on your expected workload
97818 + before deploying it.
97819 +
97820 + To reduce the performance penalty by sanitizing pages only, albeit
97821 + limiting the effectiveness of this feature at the same time, slab
97822 + sanitization can be disabled with the kernel commandline parameter
97823 + "pax_sanitize_slab=0".
97824 +
97825 + Note that this feature does not protect data stored in live pages,
97826 + e.g., process memory swapped to disk may stay there for a long time.
97827 +
97828 +config PAX_MEMORY_STACKLEAK
97829 + bool "Sanitize kernel stack"
97830 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97831 + depends on X86
97832 + help
97833 + By saying Y here the kernel will erase the kernel stack before it
97834 + returns from a system call. This in turn reduces the information
97835 + that a kernel stack leak bug can reveal.
97836 +
97837 + Note that such a bug can still leak information that was put on
97838 + the stack by the current system call (the one eventually triggering
97839 + the bug) but traces of earlier system calls on the kernel stack
97840 + cannot leak anymore.
97841 +
97842 + The tradeoff is performance impact: on a single CPU system kernel
97843 + compilation sees a 1% slowdown, other systems and workloads may vary
97844 + and you are advised to test this feature on your expected workload
97845 + before deploying it.
97846 +
97847 + Note that the full feature requires a gcc with plugin support,
97848 + i.e., gcc 4.5 or newer. You may need to install the supporting
97849 + headers explicitly in addition to the normal gcc package. Using
97850 + older gcc versions means that functions with large enough stack
97851 + frames may leave uninitialized memory behind that may be exposed
97852 + to a later syscall leaking the stack.
97853 +
97854 +config PAX_MEMORY_STRUCTLEAK
97855 + bool "Forcibly initialize local variables copied to userland"
97856 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97857 + help
97858 + By saying Y here the kernel will zero initialize some local
97859 + variables that are going to be copied to userland. This in
97860 + turn prevents unintended information leakage from the kernel
97861 + stack should later code forget to explicitly set all parts of
97862 + the copied variable.
97863 +
97864 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
97865 + at a much smaller coverage.
97866 +
97867 + Note that the implementation requires a gcc with plugin support,
97868 + i.e., gcc 4.5 or newer. You may need to install the supporting
97869 + headers explicitly in addition to the normal gcc package.
97870 +
97871 +config PAX_MEMORY_UDEREF
97872 + bool "Prevent invalid userland pointer dereference"
97873 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
97874 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
97875 + select PAX_PER_CPU_PGD if X86_64
97876 + help
97877 + By saying Y here the kernel will be prevented from dereferencing
97878 + userland pointers in contexts where the kernel expects only kernel
97879 + pointers. This is both a useful runtime debugging feature and a
97880 + security measure that prevents exploiting a class of kernel bugs.
97881 +
97882 + The tradeoff is that some virtualization solutions may experience
97883 + a huge slowdown and therefore you should not enable this feature
97884 + for kernels meant to run in such environments. Whether a given VM
97885 + solution is affected or not is best determined by simply trying it
97886 + out, the performance impact will be obvious right on boot as this
97887 + mechanism engages from very early on. A good rule of thumb is that
97888 + VMs running on CPUs without hardware virtualization support (i.e.,
97889 + the majority of IA-32 CPUs) will likely experience the slowdown.
97890 +
97891 + On X86_64 the kernel will make use of PCID support when available
97892 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
97893 + or performance impact. Pass pax_weakuderef on the kernel command
97894 + line to choose the latter.
97895 +
97896 +config PAX_REFCOUNT
97897 + bool "Prevent various kernel object reference counter overflows"
97898 + default y if GRKERNSEC_CONFIG_AUTO
97899 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
97900 + help
97901 + By saying Y here the kernel will detect and prevent overflowing
97902 + various (but not all) kinds of object reference counters. Such
97903 + overflows can normally occur due to bugs only and are often, if
97904 + not always, exploitable.
97905 +
97906 + The tradeoff is that data structures protected by an overflowed
97907 + refcount will never be freed and therefore will leak memory. Note
97908 + that this leak also happens even without this protection but in
97909 + that case the overflow can eventually trigger the freeing of the
97910 + data structure while it is still being used elsewhere, resulting
97911 + in the exploitable situation that this feature prevents.
97912 +
97913 + Since this has a negligible performance impact, you should enable
97914 + this feature.
97915 +
97916 +config PAX_CONSTIFY_PLUGIN
97917 + bool "Automatically constify eligible structures"
97918 + default y
97919 + depends on !UML && PAX_KERNEXEC
97920 + help
97921 + By saying Y here the compiler will automatically constify a class
97922 + of types that contain only function pointers. This reduces the
97923 + kernel's attack surface and also produces a better memory layout.
97924 +
97925 + Note that the implementation requires a gcc with plugin support,
97926 + i.e., gcc 4.5 or newer. You may need to install the supporting
97927 + headers explicitly in addition to the normal gcc package.
97928 +
97929 + Note that if some code really has to modify constified variables
97930 + then the source code will have to be patched to allow it. Examples
97931 + can be found in PaX itself (the no_const attribute) and for some
97932 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
97933 +
97934 +config PAX_USERCOPY
97935 + bool "Harden heap object copies between kernel and userland"
97936 + default y if GRKERNSEC_CONFIG_AUTO
97937 + depends on ARM || IA64 || PPC || SPARC || X86
97938 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
97939 + select PAX_USERCOPY_SLABS
97940 + help
97941 + By saying Y here the kernel will enforce the size of heap objects
97942 + when they are copied in either direction between the kernel and
97943 + userland, even if only a part of the heap object is copied.
97944 +
97945 + Specifically, this checking prevents information leaking from the
97946 + kernel heap during kernel to userland copies (if the kernel heap
97947 + object is otherwise fully initialized) and prevents kernel heap
97948 + overflows during userland to kernel copies.
97949 +
97950 + Note that the current implementation provides the strictest bounds
97951 + checks for the SLUB allocator.
97952 +
97953 + Enabling this option also enables per-slab cache protection against
97954 + data in a given cache being copied into/out of via userland
97955 + accessors. Though the whitelist of regions will be reduced over
97956 + time, it notably protects important data structures like task structs.
97957 +
97958 + If frame pointers are enabled on x86, this option will also restrict
97959 + copies into and out of the kernel stack to local variables within a
97960 + single frame.
97961 +
97962 + Since this has a negligible performance impact, you should enable
97963 + this feature.
97964 +
97965 +config PAX_USERCOPY_DEBUG
97966 + bool
97967 + depends on X86 && PAX_USERCOPY
97968 + default n
97969 +
97970 +config PAX_SIZE_OVERFLOW
97971 + bool "Prevent various integer overflows in function size parameters"
97972 + default y if GRKERNSEC_CONFIG_AUTO
97973 + depends on X86
97974 + help
97975 + By saying Y here the kernel recomputes expressions of function
97976 + arguments marked by a size_overflow attribute with double integer
97977 + precision (DImode/TImode for 32/64 bit integer types).
97978 +
97979 + The recomputed argument is checked against TYPE_MAX and an event
97980 + is logged on overflow and the triggering process is killed.
97981 +
97982 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
97983 +
97984 + Note that the implementation requires a gcc with plugin support,
97985 + i.e., gcc 4.5 or newer. You may need to install the supporting
97986 + headers explicitly in addition to the normal gcc package.
97987 +
97988 +config PAX_LATENT_ENTROPY
97989 + bool "Generate some entropy during boot"
97990 + default y if GRKERNSEC_CONFIG_AUTO
97991 + help
97992 + By saying Y here the kernel will instrument early boot code to
97993 + extract some entropy from both original and artificially created
97994 + program state. This will help especially embedded systems where
97995 + there is little 'natural' source of entropy normally. The cost
97996 + is some slowdown of the boot process.
97997 +
97998 + When pax_extra_latent_entropy is passed on the kernel command line,
97999 + entropy will be extracted from up to the first 4GB of RAM while the
98000 + runtime memory allocator is being initialized. This costs even more
98001 + slowdown of the boot process.
98002 +
98003 + Note that the implementation requires a gcc with plugin support,
98004 + i.e., gcc 4.5 or newer. You may need to install the supporting
98005 + headers explicitly in addition to the normal gcc package.
98006 +
98007 + Note that entropy extracted this way is not cryptographically
98008 + secure!
98009 +
98010 +endmenu
98011 +
98012 +endmenu
98013 +
98014 +source grsecurity/Kconfig
98015 +
98016 +endmenu
98017 +
98018 +endmenu
98019 +
98020 source security/keys/Kconfig
98021
98022 config SECURITY_DMESG_RESTRICT
98023 @@ -103,7 +1056,7 @@ config INTEL_TXT
98024 config LSM_MMAP_MIN_ADDR
98025 int "Low address space for LSM to protect from user allocation"
98026 depends on SECURITY && SECURITY_SELINUX
98027 - default 32768 if ARM
98028 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98029 default 65536
98030 help
98031 This is the portion of low virtual memory which should be protected
98032 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98033 index 9b9013b..51ebf96 100644
98034 --- a/security/apparmor/Kconfig
98035 +++ b/security/apparmor/Kconfig
98036 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98037 boot.
98038
98039 If you are unsure how to answer this question, answer 1.
98040 +
98041 +config SECURITY_APPARMOR_COMPAT_24
98042 + bool "Enable AppArmor 2.4 compatability"
98043 + depends on SECURITY_APPARMOR
98044 + default y
98045 + help
98046 + This option enables compatability with AppArmor 2.4. It is
98047 + recommended if compatability with older versions of AppArmor
98048 + is desired.
98049 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98050 index 16c15ec..42b7c9f 100644
98051 --- a/security/apparmor/apparmorfs.c
98052 +++ b/security/apparmor/apparmorfs.c
98053 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98054 .release = single_release,
98055 };
98056
98057 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98058 +/**
98059 + * __next_namespace - find the next namespace to list
98060 + * @root: root namespace to stop search at (NOT NULL)
98061 + * @ns: current ns position (NOT NULL)
98062 + *
98063 + * Find the next namespace from @ns under @root and handle all locking needed
98064 + * while switching current namespace.
98065 + *
98066 + * Returns: next namespace or NULL if at last namespace under @root
98067 + * NOTE: will not unlock root->lock
98068 + */
98069 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98070 + struct aa_namespace *ns)
98071 +{
98072 + struct aa_namespace *parent;
98073 +
98074 + /* is next namespace a child */
98075 + if (!list_empty(&ns->sub_ns)) {
98076 + struct aa_namespace *next;
98077 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98078 + read_lock(&next->lock);
98079 + return next;
98080 + }
98081 +
98082 + /* check if the next ns is a sibling, parent, gp, .. */
98083 + parent = ns->parent;
98084 + while (parent) {
98085 + read_unlock(&ns->lock);
98086 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98087 + read_lock(&ns->lock);
98088 + return ns;
98089 + }
98090 + if (parent == root)
98091 + return NULL;
98092 + ns = parent;
98093 + parent = parent->parent;
98094 + }
98095 +
98096 + return NULL;
98097 +}
98098 +
98099 +/**
98100 + * __first_profile - find the first profile in a namespace
98101 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98102 + * @ns: namespace to start in (NOT NULL)
98103 + *
98104 + * Returns: unrefcounted profile or NULL if no profile
98105 + */
98106 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98107 + struct aa_namespace *ns)
98108 +{
98109 + for ( ; ns; ns = __next_namespace(root, ns)) {
98110 + if (!list_empty(&ns->base.profiles))
98111 + return list_first_entry(&ns->base.profiles,
98112 + struct aa_profile, base.list);
98113 + }
98114 + return NULL;
98115 +}
98116 +
98117 +/**
98118 + * __next_profile - step to the next profile in a profile tree
98119 + * @profile: current profile in tree (NOT NULL)
98120 + *
98121 + * Perform a depth first taversal on the profile tree in a namespace
98122 + *
98123 + * Returns: next profile or NULL if done
98124 + * Requires: profile->ns.lock to be held
98125 + */
98126 +static struct aa_profile *__next_profile(struct aa_profile *p)
98127 +{
98128 + struct aa_profile *parent;
98129 + struct aa_namespace *ns = p->ns;
98130 +
98131 + /* is next profile a child */
98132 + if (!list_empty(&p->base.profiles))
98133 + return list_first_entry(&p->base.profiles, typeof(*p),
98134 + base.list);
98135 +
98136 + /* is next profile a sibling, parent sibling, gp, subling, .. */
98137 + parent = p->parent;
98138 + while (parent) {
98139 + list_for_each_entry_continue(p, &parent->base.profiles,
98140 + base.list)
98141 + return p;
98142 + p = parent;
98143 + parent = parent->parent;
98144 + }
98145 +
98146 + /* is next another profile in the namespace */
98147 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
98148 + return p;
98149 +
98150 + return NULL;
98151 +}
98152 +
98153 +/**
98154 + * next_profile - step to the next profile in where ever it may be
98155 + * @root: root namespace (NOT NULL)
98156 + * @profile: current profile (NOT NULL)
98157 + *
98158 + * Returns: next profile or NULL if there isn't one
98159 + */
98160 +static struct aa_profile *next_profile(struct aa_namespace *root,
98161 + struct aa_profile *profile)
98162 +{
98163 + struct aa_profile *next = __next_profile(profile);
98164 + if (next)
98165 + return next;
98166 +
98167 + /* finished all profiles in namespace move to next namespace */
98168 + return __first_profile(root, __next_namespace(root, profile->ns));
98169 +}
98170 +
98171 +/**
98172 + * p_start - start a depth first traversal of profile tree
98173 + * @f: seq_file to fill
98174 + * @pos: current position
98175 + *
98176 + * Returns: first profile under current namespace or NULL if none found
98177 + *
98178 + * acquires first ns->lock
98179 + */
98180 +static void *p_start(struct seq_file *f, loff_t *pos)
98181 + __acquires(root->lock)
98182 +{
98183 + struct aa_profile *profile = NULL;
98184 + struct aa_namespace *root = aa_current_profile()->ns;
98185 + loff_t l = *pos;
98186 + f->private = aa_get_namespace(root);
98187 +
98188 +
98189 + /* find the first profile */
98190 + read_lock(&root->lock);
98191 + profile = __first_profile(root, root);
98192 +
98193 + /* skip to position */
98194 + for (; profile && l > 0; l--)
98195 + profile = next_profile(root, profile);
98196 +
98197 + return profile;
98198 +}
98199 +
98200 +/**
98201 + * p_next - read the next profile entry
98202 + * @f: seq_file to fill
98203 + * @p: profile previously returned
98204 + * @pos: current position
98205 + *
98206 + * Returns: next profile after @p or NULL if none
98207 + *
98208 + * may acquire/release locks in namespace tree as necessary
98209 + */
98210 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
98211 +{
98212 + struct aa_profile *profile = p;
98213 + struct aa_namespace *root = f->private;
98214 + (*pos)++;
98215 +
98216 + return next_profile(root, profile);
98217 +}
98218 +
98219 +/**
98220 + * p_stop - stop depth first traversal
98221 + * @f: seq_file we are filling
98222 + * @p: the last profile writen
98223 + *
98224 + * Release all locking done by p_start/p_next on namespace tree
98225 + */
98226 +static void p_stop(struct seq_file *f, void *p)
98227 + __releases(root->lock)
98228 +{
98229 + struct aa_profile *profile = p;
98230 + struct aa_namespace *root = f->private, *ns;
98231 +
98232 + if (profile) {
98233 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
98234 + read_unlock(&ns->lock);
98235 + }
98236 + read_unlock(&root->lock);
98237 + aa_put_namespace(root);
98238 +}
98239 +
98240 +/**
98241 + * seq_show_profile - show a profile entry
98242 + * @f: seq_file to file
98243 + * @p: current position (profile) (NOT NULL)
98244 + *
98245 + * Returns: error on failure
98246 + */
98247 +static int seq_show_profile(struct seq_file *f, void *p)
98248 +{
98249 + struct aa_profile *profile = (struct aa_profile *)p;
98250 + struct aa_namespace *root = f->private;
98251 +
98252 + if (profile->ns != root)
98253 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
98254 + seq_printf(f, "%s (%s)\n", profile->base.hname,
98255 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
98256 +
98257 + return 0;
98258 +}
98259 +
98260 +static const struct seq_operations aa_fs_profiles_op = {
98261 + .start = p_start,
98262 + .next = p_next,
98263 + .stop = p_stop,
98264 + .show = seq_show_profile,
98265 +};
98266 +
98267 +static int profiles_open(struct inode *inode, struct file *file)
98268 +{
98269 + return seq_open(file, &aa_fs_profiles_op);
98270 +}
98271 +
98272 +static int profiles_release(struct inode *inode, struct file *file)
98273 +{
98274 + return seq_release(inode, file);
98275 +}
98276 +
98277 +const struct file_operations aa_fs_profiles_fops = {
98278 + .open = profiles_open,
98279 + .read = seq_read,
98280 + .llseek = seq_lseek,
98281 + .release = profiles_release,
98282 +};
98283 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
98284 +
98285 /** Base file system setup **/
98286
98287 static struct aa_fs_entry aa_fs_entry_file[] = {
98288 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
98289 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
98290 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
98291 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
98292 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98293 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
98294 +#endif
98295 AA_FS_DIR("features", aa_fs_entry_features),
98296 { }
98297 };
98298 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
98299 index 2e2a0dd..a0cbc44 100644
98300 --- a/security/apparmor/lsm.c
98301 +++ b/security/apparmor/lsm.c
98302 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
98303 return error;
98304 }
98305
98306 -static struct security_operations apparmor_ops = {
98307 +static struct security_operations apparmor_ops __read_only = {
98308 .name = "apparmor",
98309
98310 .ptrace_access_check = apparmor_ptrace_access_check,
98311 diff --git a/security/commoncap.c b/security/commoncap.c
98312 index c44b6fe..932df30 100644
98313 --- a/security/commoncap.c
98314 +++ b/security/commoncap.c
98315 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
98316 return 0;
98317 }
98318
98319 +/* returns:
98320 + 1 for suid privilege
98321 + 2 for sgid privilege
98322 + 3 for fscap privilege
98323 +*/
98324 +int is_privileged_binary(const struct dentry *dentry)
98325 +{
98326 + struct cpu_vfs_cap_data capdata;
98327 + struct inode *inode = dentry->d_inode;
98328 +
98329 + if (!inode || S_ISDIR(inode->i_mode))
98330 + return 0;
98331 +
98332 + if (inode->i_mode & S_ISUID)
98333 + return 1;
98334 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
98335 + return 2;
98336 +
98337 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
98338 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
98339 + return 3;
98340 + }
98341 +
98342 + return 0;
98343 +}
98344 +
98345 /*
98346 * Attempt to get the on-exec apply capability sets for an executable file from
98347 * its xattrs and, if present, apply them to the proposed credentials being
98348 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
98349 const struct cred *cred = current_cred();
98350 kuid_t root_uid = make_kuid(cred->user_ns, 0);
98351
98352 + if (gr_acl_enable_at_secure())
98353 + return 1;
98354 +
98355 if (!uid_eq(cred->uid, root_uid)) {
98356 if (bprm->cap_effective)
98357 return 1;
98358 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
98359 index b3dd616..4bb17f3 100644
98360 --- a/security/integrity/ima/ima.h
98361 +++ b/security/integrity/ima/ima.h
98362 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
98363 extern spinlock_t ima_queue_lock;
98364
98365 struct ima_h_table {
98366 - atomic_long_t len; /* number of stored measurements in the list */
98367 - atomic_long_t violations;
98368 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
98369 + atomic_long_unchecked_t violations;
98370 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
98371 };
98372 extern struct ima_h_table ima_htable;
98373 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
98374 index 1c03e8f1..398a941 100644
98375 --- a/security/integrity/ima/ima_api.c
98376 +++ b/security/integrity/ima/ima_api.c
98377 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
98378 int result;
98379
98380 /* can overflow, only indicator */
98381 - atomic_long_inc(&ima_htable.violations);
98382 + atomic_long_inc_unchecked(&ima_htable.violations);
98383
98384 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
98385 if (!entry) {
98386 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
98387 index 38477c9..87a60c7 100644
98388 --- a/security/integrity/ima/ima_fs.c
98389 +++ b/security/integrity/ima/ima_fs.c
98390 @@ -28,12 +28,12 @@
98391 static int valid_policy = 1;
98392 #define TMPBUFLEN 12
98393 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
98394 - loff_t *ppos, atomic_long_t *val)
98395 + loff_t *ppos, atomic_long_unchecked_t *val)
98396 {
98397 char tmpbuf[TMPBUFLEN];
98398 ssize_t len;
98399
98400 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
98401 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
98402 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
98403 }
98404
98405 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
98406 index ff63fe0..809cd96 100644
98407 --- a/security/integrity/ima/ima_queue.c
98408 +++ b/security/integrity/ima/ima_queue.c
98409 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
98410 INIT_LIST_HEAD(&qe->later);
98411 list_add_tail_rcu(&qe->later, &ima_measurements);
98412
98413 - atomic_long_inc(&ima_htable.len);
98414 + atomic_long_inc_unchecked(&ima_htable.len);
98415 key = ima_hash_key(entry->digest);
98416 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
98417 return 0;
98418 diff --git a/security/keys/compat.c b/security/keys/compat.c
98419 index d65fa7f..cbfe366 100644
98420 --- a/security/keys/compat.c
98421 +++ b/security/keys/compat.c
98422 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
98423 if (ret == 0)
98424 goto no_payload_free;
98425
98426 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98427 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98428 err:
98429 if (iov != iovstack)
98430 kfree(iov);
98431 diff --git a/security/keys/internal.h b/security/keys/internal.h
98432 index d4f1468..cc52f92 100644
98433 --- a/security/keys/internal.h
98434 +++ b/security/keys/internal.h
98435 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
98436 extern long keyctl_invalidate_key(key_serial_t);
98437
98438 extern long keyctl_instantiate_key_common(key_serial_t,
98439 - const struct iovec *,
98440 + const struct iovec __user *,
98441 unsigned, size_t, key_serial_t);
98442
98443 /*
98444 diff --git a/security/keys/key.c b/security/keys/key.c
98445 index 8fb7c7b..ba3610d 100644
98446 --- a/security/keys/key.c
98447 +++ b/security/keys/key.c
98448 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
98449
98450 atomic_set(&key->usage, 1);
98451 init_rwsem(&key->sem);
98452 - lockdep_set_class(&key->sem, &type->lock_class);
98453 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
98454 key->type = type;
98455 key->user = user;
98456 key->quotalen = quotalen;
98457 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
98458 struct key_type *p;
98459 int ret;
98460
98461 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
98462 + pax_open_kernel();
98463 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
98464 + pax_close_kernel();
98465
98466 ret = -EEXIST;
98467 down_write(&key_types_sem);
98468 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
98469 }
98470
98471 /* store the type */
98472 - list_add(&ktype->link, &key_types_list);
98473 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
98474
98475 pr_notice("Key type %s registered\n", ktype->name);
98476 ret = 0;
98477 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
98478 void unregister_key_type(struct key_type *ktype)
98479 {
98480 down_write(&key_types_sem);
98481 - list_del_init(&ktype->link);
98482 + pax_list_del_init((struct list_head *)&ktype->link);
98483 downgrade_write(&key_types_sem);
98484 key_gc_keytype(ktype);
98485 pr_notice("Key type %s unregistered\n", ktype->name);
98486 @@ -1084,10 +1086,10 @@ void __init key_init(void)
98487 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
98488
98489 /* add the special key types */
98490 - list_add_tail(&key_type_keyring.link, &key_types_list);
98491 - list_add_tail(&key_type_dead.link, &key_types_list);
98492 - list_add_tail(&key_type_user.link, &key_types_list);
98493 - list_add_tail(&key_type_logon.link, &key_types_list);
98494 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
98495 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
98496 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
98497 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
98498
98499 /* record the root user tracking */
98500 rb_link_node(&root_key_user.node,
98501 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
98502 index 33cfd27..842fc5a 100644
98503 --- a/security/keys/keyctl.c
98504 +++ b/security/keys/keyctl.c
98505 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
98506 /*
98507 * Copy the iovec data from userspace
98508 */
98509 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98510 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
98511 unsigned ioc)
98512 {
98513 for (; ioc > 0; ioc--) {
98514 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98515 * If successful, 0 will be returned.
98516 */
98517 long keyctl_instantiate_key_common(key_serial_t id,
98518 - const struct iovec *payload_iov,
98519 + const struct iovec __user *payload_iov,
98520 unsigned ioc,
98521 size_t plen,
98522 key_serial_t ringid)
98523 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
98524 [0].iov_len = plen
98525 };
98526
98527 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
98528 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
98529 }
98530
98531 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
98532 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
98533 if (ret == 0)
98534 goto no_payload_free;
98535
98536 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98537 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98538 err:
98539 if (iov != iovstack)
98540 kfree(iov);
98541 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
98542 index 6ece7f2..ecdb55c 100644
98543 --- a/security/keys/keyring.c
98544 +++ b/security/keys/keyring.c
98545 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
98546 ret = -EFAULT;
98547
98548 for (loop = 0; loop < klist->nkeys; loop++) {
98549 + key_serial_t serial;
98550 key = rcu_deref_link_locked(klist, loop,
98551 keyring);
98552 + serial = key->serial;
98553
98554 tmp = sizeof(key_serial_t);
98555 if (tmp > buflen)
98556 tmp = buflen;
98557
98558 - if (copy_to_user(buffer,
98559 - &key->serial,
98560 - tmp) != 0)
98561 + if (copy_to_user(buffer, &serial, tmp))
98562 goto error;
98563
98564 buflen -= tmp;
98565 diff --git a/security/min_addr.c b/security/min_addr.c
98566 index f728728..6457a0c 100644
98567 --- a/security/min_addr.c
98568 +++ b/security/min_addr.c
98569 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
98570 */
98571 static void update_mmap_min_addr(void)
98572 {
98573 +#ifndef SPARC
98574 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
98575 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
98576 mmap_min_addr = dac_mmap_min_addr;
98577 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
98578 #else
98579 mmap_min_addr = dac_mmap_min_addr;
98580 #endif
98581 +#endif
98582 }
98583
98584 /*
98585 diff --git a/security/security.c b/security/security.c
98586 index 94b35ae..f4e7751 100644
98587 --- a/security/security.c
98588 +++ b/security/security.c
98589 @@ -33,8 +33,8 @@
98590 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
98591 CONFIG_DEFAULT_SECURITY;
98592
98593 -static struct security_operations *security_ops;
98594 -static struct security_operations default_security_ops = {
98595 +struct security_operations *security_ops __read_only;
98596 +struct security_operations default_security_ops __read_only = {
98597 .name = "default",
98598 };
98599
98600 @@ -73,11 +73,6 @@ int __init security_init(void)
98601 return 0;
98602 }
98603
98604 -void reset_security_ops(void)
98605 -{
98606 - security_ops = &default_security_ops;
98607 -}
98608 -
98609 /* Save user chosen LSM */
98610 static int __init choose_lsm(char *str)
98611 {
98612 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
98613 index dad36a6..7e5ffbf 100644
98614 --- a/security/selinux/avc.c
98615 +++ b/security/selinux/avc.c
98616 @@ -59,7 +59,7 @@ struct avc_node {
98617 struct avc_cache {
98618 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
98619 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
98620 - atomic_t lru_hint; /* LRU hint for reclaim scan */
98621 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
98622 atomic_t active_nodes;
98623 u32 latest_notif; /* latest revocation notification */
98624 };
98625 @@ -167,7 +167,7 @@ void __init avc_init(void)
98626 spin_lock_init(&avc_cache.slots_lock[i]);
98627 }
98628 atomic_set(&avc_cache.active_nodes, 0);
98629 - atomic_set(&avc_cache.lru_hint, 0);
98630 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
98631
98632 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
98633 0, SLAB_PANIC, NULL);
98634 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
98635 spinlock_t *lock;
98636
98637 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
98638 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98639 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98640 head = &avc_cache.slots[hvalue];
98641 lock = &avc_cache.slots_lock[hvalue];
98642
98643 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
98644 index c956390..1899f06 100644
98645 --- a/security/selinux/hooks.c
98646 +++ b/security/selinux/hooks.c
98647 @@ -97,8 +97,6 @@
98648
98649 #define NUM_SEL_MNT_OPTS 5
98650
98651 -extern struct security_operations *security_ops;
98652 -
98653 /* SECMARK reference count */
98654 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
98655
98656 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
98657
98658 #endif
98659
98660 -static struct security_operations selinux_ops = {
98661 +static struct security_operations selinux_ops __read_only = {
98662 .name = "selinux",
98663
98664 .ptrace_access_check = selinux_ptrace_access_check,
98665 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
98666 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
98667 static int selinux_disabled;
98668
98669 +extern struct security_operations *security_ops;
98670 +extern struct security_operations default_security_ops;
98671 +
98672 int selinux_disable(void)
98673 {
98674 if (ss_initialized) {
98675 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
98676 selinux_disabled = 1;
98677 selinux_enabled = 0;
98678
98679 - reset_security_ops();
98680 + pax_open_kernel();
98681 + security_ops = &default_security_ops;
98682 + pax_close_kernel();
98683
98684 /* Try to destroy the avc node cache */
98685 avc_disable();
98686 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
98687 index 65f67cb..3f141ef 100644
98688 --- a/security/selinux/include/xfrm.h
98689 +++ b/security/selinux/include/xfrm.h
98690 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
98691
98692 static inline void selinux_xfrm_notify_policyload(void)
98693 {
98694 - atomic_inc(&flow_cache_genid);
98695 + atomic_inc_unchecked(&flow_cache_genid);
98696 rt_genid_bump(&init_net);
98697 }
98698 #else
98699 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
98700 index eefbd10..9f10ddb 100644
98701 --- a/security/smack/smack_lsm.c
98702 +++ b/security/smack/smack_lsm.c
98703 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
98704 return 0;
98705 }
98706
98707 -struct security_operations smack_ops = {
98708 +struct security_operations smack_ops __read_only = {
98709 .name = "smack",
98710
98711 .ptrace_access_check = smack_ptrace_access_check,
98712 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
98713 index 390c646..f2f8db3 100644
98714 --- a/security/tomoyo/mount.c
98715 +++ b/security/tomoyo/mount.c
98716 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
98717 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
98718 need_dev = -1; /* dev_name is a directory */
98719 } else {
98720 + if (!capable(CAP_SYS_ADMIN)) {
98721 + error = -EPERM;
98722 + goto out;
98723 + }
98724 fstype = get_fs_type(type);
98725 if (!fstype) {
98726 error = -ENODEV;
98727 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
98728 index f0b756e..b129202 100644
98729 --- a/security/tomoyo/tomoyo.c
98730 +++ b/security/tomoyo/tomoyo.c
98731 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
98732 * tomoyo_security_ops is a "struct security_operations" which is used for
98733 * registering TOMOYO.
98734 */
98735 -static struct security_operations tomoyo_security_ops = {
98736 +static struct security_operations tomoyo_security_ops __read_only = {
98737 .name = "tomoyo",
98738 .cred_alloc_blank = tomoyo_cred_alloc_blank,
98739 .cred_prepare = tomoyo_cred_prepare,
98740 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
98741 index 20ef514..4182bed 100644
98742 --- a/security/yama/Kconfig
98743 +++ b/security/yama/Kconfig
98744 @@ -1,6 +1,6 @@
98745 config SECURITY_YAMA
98746 bool "Yama support"
98747 - depends on SECURITY
98748 + depends on SECURITY && !GRKERNSEC
98749 select SECURITYFS
98750 select SECURITY_PATH
98751 default n
98752 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
98753 index 13c88fbc..f8c115e 100644
98754 --- a/security/yama/yama_lsm.c
98755 +++ b/security/yama/yama_lsm.c
98756 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
98757 }
98758
98759 #ifndef CONFIG_SECURITY_YAMA_STACKED
98760 -static struct security_operations yama_ops = {
98761 +static struct security_operations yama_ops __read_only = {
98762 .name = "yama",
98763
98764 .ptrace_access_check = yama_ptrace_access_check,
98765 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
98766 #endif
98767
98768 #ifdef CONFIG_SYSCTL
98769 +static int zero __read_only;
98770 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
98771 +
98772 static int yama_dointvec_minmax(struct ctl_table *table, int write,
98773 void __user *buffer, size_t *lenp, loff_t *ppos)
98774 {
98775 - int rc;
98776 + ctl_table_no_const yama_table;
98777
98778 if (write && !capable(CAP_SYS_PTRACE))
98779 return -EPERM;
98780
98781 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
98782 - if (rc)
98783 - return rc;
98784 -
98785 + yama_table = *table;
98786 /* Lock the max value if it ever gets set. */
98787 - if (write && *(int *)table->data == *(int *)table->extra2)
98788 - table->extra1 = table->extra2;
98789 -
98790 - return rc;
98791 + if (ptrace_scope == max_scope)
98792 + yama_table.extra1 = &max_scope;
98793 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
98794 }
98795
98796 -static int zero;
98797 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
98798 -
98799 struct ctl_path yama_sysctl_path[] = {
98800 { .procname = "kernel", },
98801 { .procname = "yama", },
98802 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
98803 index 4cedc69..e59d8a3 100644
98804 --- a/sound/aoa/codecs/onyx.c
98805 +++ b/sound/aoa/codecs/onyx.c
98806 @@ -54,7 +54,7 @@ struct onyx {
98807 spdif_locked:1,
98808 analog_locked:1,
98809 original_mute:2;
98810 - int open_count;
98811 + local_t open_count;
98812 struct codec_info *codec_info;
98813
98814 /* mutex serializes concurrent access to the device
98815 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
98816 struct onyx *onyx = cii->codec_data;
98817
98818 mutex_lock(&onyx->mutex);
98819 - onyx->open_count++;
98820 + local_inc(&onyx->open_count);
98821 mutex_unlock(&onyx->mutex);
98822
98823 return 0;
98824 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
98825 struct onyx *onyx = cii->codec_data;
98826
98827 mutex_lock(&onyx->mutex);
98828 - onyx->open_count--;
98829 - if (!onyx->open_count)
98830 + if (local_dec_and_test(&onyx->open_count))
98831 onyx->spdif_locked = onyx->analog_locked = 0;
98832 mutex_unlock(&onyx->mutex);
98833
98834 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
98835 index ffd2025..df062c9 100644
98836 --- a/sound/aoa/codecs/onyx.h
98837 +++ b/sound/aoa/codecs/onyx.h
98838 @@ -11,6 +11,7 @@
98839 #include <linux/i2c.h>
98840 #include <asm/pmac_low_i2c.h>
98841 #include <asm/prom.h>
98842 +#include <asm/local.h>
98843
98844 /* PCM3052 register definitions */
98845
98846 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
98847 index 4c1cc51..16040040 100644
98848 --- a/sound/core/oss/pcm_oss.c
98849 +++ b/sound/core/oss/pcm_oss.c
98850 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
98851 if (in_kernel) {
98852 mm_segment_t fs;
98853 fs = snd_enter_user();
98854 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
98855 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
98856 snd_leave_user(fs);
98857 } else {
98858 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
98859 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
98860 }
98861 if (ret != -EPIPE && ret != -ESTRPIPE)
98862 break;
98863 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
98864 if (in_kernel) {
98865 mm_segment_t fs;
98866 fs = snd_enter_user();
98867 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
98868 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
98869 snd_leave_user(fs);
98870 } else {
98871 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
98872 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
98873 }
98874 if (ret == -EPIPE) {
98875 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
98876 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
98877 struct snd_pcm_plugin_channel *channels;
98878 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
98879 if (!in_kernel) {
98880 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
98881 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
98882 return -EFAULT;
98883 buf = runtime->oss.buffer;
98884 }
98885 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
98886 }
98887 } else {
98888 tmp = snd_pcm_oss_write2(substream,
98889 - (const char __force *)buf,
98890 + (const char __force_kernel *)buf,
98891 runtime->oss.period_bytes, 0);
98892 if (tmp <= 0)
98893 goto err;
98894 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
98895 struct snd_pcm_runtime *runtime = substream->runtime;
98896 snd_pcm_sframes_t frames, frames1;
98897 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
98898 - char __user *final_dst = (char __force __user *)buf;
98899 + char __user *final_dst = (char __force_user *)buf;
98900 if (runtime->oss.plugin_first) {
98901 struct snd_pcm_plugin_channel *channels;
98902 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
98903 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
98904 xfer += tmp;
98905 runtime->oss.buffer_used -= tmp;
98906 } else {
98907 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
98908 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
98909 runtime->oss.period_bytes, 0);
98910 if (tmp <= 0)
98911 goto err;
98912 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
98913 size1);
98914 size1 /= runtime->channels; /* frames */
98915 fs = snd_enter_user();
98916 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
98917 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
98918 snd_leave_user(fs);
98919 }
98920 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
98921 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
98922 index af49721..e85058e 100644
98923 --- a/sound/core/pcm_compat.c
98924 +++ b/sound/core/pcm_compat.c
98925 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
98926 int err;
98927
98928 fs = snd_enter_user();
98929 - err = snd_pcm_delay(substream, &delay);
98930 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
98931 snd_leave_user(fs);
98932 if (err < 0)
98933 return err;
98934 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
98935 index a68d4c6..72af3cf 100644
98936 --- a/sound/core/pcm_native.c
98937 +++ b/sound/core/pcm_native.c
98938 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
98939 switch (substream->stream) {
98940 case SNDRV_PCM_STREAM_PLAYBACK:
98941 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
98942 - (void __user *)arg);
98943 + (void __force_user *)arg);
98944 break;
98945 case SNDRV_PCM_STREAM_CAPTURE:
98946 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
98947 - (void __user *)arg);
98948 + (void __force_user *)arg);
98949 break;
98950 default:
98951 result = -EINVAL;
98952 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
98953 index 040c60e..989a19a 100644
98954 --- a/sound/core/seq/seq_device.c
98955 +++ b/sound/core/seq/seq_device.c
98956 @@ -64,7 +64,7 @@ struct ops_list {
98957 int argsize; /* argument size */
98958
98959 /* operators */
98960 - struct snd_seq_dev_ops ops;
98961 + struct snd_seq_dev_ops *ops;
98962
98963 /* registered devices */
98964 struct list_head dev_list; /* list of devices */
98965 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
98966
98967 mutex_lock(&ops->reg_mutex);
98968 /* copy driver operators */
98969 - ops->ops = *entry;
98970 + ops->ops = entry;
98971 ops->driver |= DRIVER_LOADED;
98972 ops->argsize = argsize;
98973
98974 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
98975 dev->name, ops->id, ops->argsize, dev->argsize);
98976 return -EINVAL;
98977 }
98978 - if (ops->ops.init_device(dev) >= 0) {
98979 + if (ops->ops->init_device(dev) >= 0) {
98980 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
98981 ops->num_init_devices++;
98982 } else {
98983 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
98984 dev->name, ops->id, ops->argsize, dev->argsize);
98985 return -EINVAL;
98986 }
98987 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
98988 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
98989 dev->status = SNDRV_SEQ_DEVICE_FREE;
98990 dev->driver_data = NULL;
98991 ops->num_init_devices--;
98992 diff --git a/sound/core/sound.c b/sound/core/sound.c
98993 index f002bd9..c462985 100644
98994 --- a/sound/core/sound.c
98995 +++ b/sound/core/sound.c
98996 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
98997 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
98998 default: return;
98999 }
99000 - request_module(str);
99001 + request_module("%s", str);
99002 }
99003
99004 #endif /* modular kernel */
99005 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99006 index 4e0dd22..7a1f32c 100644
99007 --- a/sound/drivers/mts64.c
99008 +++ b/sound/drivers/mts64.c
99009 @@ -29,6 +29,7 @@
99010 #include <sound/initval.h>
99011 #include <sound/rawmidi.h>
99012 #include <sound/control.h>
99013 +#include <asm/local.h>
99014
99015 #define CARD_NAME "Miditerminal 4140"
99016 #define DRIVER_NAME "MTS64"
99017 @@ -67,7 +68,7 @@ struct mts64 {
99018 struct pardevice *pardev;
99019 int pardev_claimed;
99020
99021 - int open_count;
99022 + local_t open_count;
99023 int current_midi_output_port;
99024 int current_midi_input_port;
99025 u8 mode[MTS64_NUM_INPUT_PORTS];
99026 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99027 {
99028 struct mts64 *mts = substream->rmidi->private_data;
99029
99030 - if (mts->open_count == 0) {
99031 + if (local_read(&mts->open_count) == 0) {
99032 /* We don't need a spinlock here, because this is just called
99033 if the device has not been opened before.
99034 So there aren't any IRQs from the device */
99035 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99036
99037 msleep(50);
99038 }
99039 - ++(mts->open_count);
99040 + local_inc(&mts->open_count);
99041
99042 return 0;
99043 }
99044 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99045 struct mts64 *mts = substream->rmidi->private_data;
99046 unsigned long flags;
99047
99048 - --(mts->open_count);
99049 - if (mts->open_count == 0) {
99050 + if (local_dec_return(&mts->open_count) == 0) {
99051 /* We need the spinlock_irqsave here because we can still
99052 have IRQs at this point */
99053 spin_lock_irqsave(&mts->lock, flags);
99054 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99055
99056 msleep(500);
99057
99058 - } else if (mts->open_count < 0)
99059 - mts->open_count = 0;
99060 + } else if (local_read(&mts->open_count) < 0)
99061 + local_set(&mts->open_count, 0);
99062
99063 return 0;
99064 }
99065 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99066 index b953fb4..1999c01 100644
99067 --- a/sound/drivers/opl4/opl4_lib.c
99068 +++ b/sound/drivers/opl4/opl4_lib.c
99069 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99070 MODULE_DESCRIPTION("OPL4 driver");
99071 MODULE_LICENSE("GPL");
99072
99073 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99074 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99075 {
99076 int timeout = 10;
99077 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99078 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99079 index 991018d..8984740 100644
99080 --- a/sound/drivers/portman2x4.c
99081 +++ b/sound/drivers/portman2x4.c
99082 @@ -48,6 +48,7 @@
99083 #include <sound/initval.h>
99084 #include <sound/rawmidi.h>
99085 #include <sound/control.h>
99086 +#include <asm/local.h>
99087
99088 #define CARD_NAME "Portman 2x4"
99089 #define DRIVER_NAME "portman"
99090 @@ -85,7 +86,7 @@ struct portman {
99091 struct pardevice *pardev;
99092 int pardev_claimed;
99093
99094 - int open_count;
99095 + local_t open_count;
99096 int mode[PORTMAN_NUM_INPUT_PORTS];
99097 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99098 };
99099 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99100 index ea995af..f1bfa37 100644
99101 --- a/sound/firewire/amdtp.c
99102 +++ b/sound/firewire/amdtp.c
99103 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99104 ptr = s->pcm_buffer_pointer + data_blocks;
99105 if (ptr >= pcm->runtime->buffer_size)
99106 ptr -= pcm->runtime->buffer_size;
99107 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99108 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99109
99110 s->pcm_period_pointer += data_blocks;
99111 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99112 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99113 */
99114 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99115 {
99116 - ACCESS_ONCE(s->source_node_id_field) =
99117 + ACCESS_ONCE_RW(s->source_node_id_field) =
99118 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99119 }
99120 EXPORT_SYMBOL(amdtp_out_stream_update);
99121 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99122 index f6103d6..4843fbf 100644
99123 --- a/sound/firewire/amdtp.h
99124 +++ b/sound/firewire/amdtp.h
99125 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99126 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99127 struct snd_pcm_substream *pcm)
99128 {
99129 - ACCESS_ONCE(s->pcm) = pcm;
99130 + ACCESS_ONCE_RW(s->pcm) = pcm;
99131 }
99132
99133 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99134 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99135 index 58a5afe..af5bd64 100644
99136 --- a/sound/firewire/isight.c
99137 +++ b/sound/firewire/isight.c
99138 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99139 ptr += count;
99140 if (ptr >= runtime->buffer_size)
99141 ptr -= runtime->buffer_size;
99142 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99143 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99144
99145 isight->period_counter += count;
99146 if (isight->period_counter >= runtime->period_size) {
99147 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99148 if (err < 0)
99149 return err;
99150
99151 - ACCESS_ONCE(isight->pcm_active) = true;
99152 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99153
99154 return 0;
99155 }
99156 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99157 {
99158 struct isight *isight = substream->private_data;
99159
99160 - ACCESS_ONCE(isight->pcm_active) = false;
99161 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99162
99163 mutex_lock(&isight->mutex);
99164 isight_stop_streaming(isight);
99165 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99166
99167 switch (cmd) {
99168 case SNDRV_PCM_TRIGGER_START:
99169 - ACCESS_ONCE(isight->pcm_running) = true;
99170 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99171 break;
99172 case SNDRV_PCM_TRIGGER_STOP:
99173 - ACCESS_ONCE(isight->pcm_running) = false;
99174 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99175 break;
99176 default:
99177 return -EINVAL;
99178 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99179 index 505fc81..62e569e 100644
99180 --- a/sound/firewire/scs1x.c
99181 +++ b/sound/firewire/scs1x.c
99182 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99183 {
99184 struct scs *scs = stream->rmidi->private_data;
99185
99186 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99187 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99188 if (up) {
99189 scs->output_idle = false;
99190 tasklet_schedule(&scs->tasklet);
99191 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99192 {
99193 struct scs *scs = stream->rmidi->private_data;
99194
99195 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99196 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99197 }
99198
99199 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99200 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99201
99202 snd_card_disconnect(scs->card);
99203
99204 - ACCESS_ONCE(scs->output) = NULL;
99205 - ACCESS_ONCE(scs->input) = NULL;
99206 + ACCESS_ONCE_RW(scs->output) = NULL;
99207 + ACCESS_ONCE_RW(scs->input) = NULL;
99208
99209 wait_event(scs->idle_wait, scs->output_idle);
99210
99211 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99212 index 048439a..3be9f6f 100644
99213 --- a/sound/oss/sb_audio.c
99214 +++ b/sound/oss/sb_audio.c
99215 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
99216 buf16 = (signed short *)(localbuf + localoffs);
99217 while (c)
99218 {
99219 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99220 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99221 if (copy_from_user(lbuf8,
99222 userbuf+useroffs + p,
99223 locallen))
99224 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
99225 index 7d8803a..559f8d0 100644
99226 --- a/sound/oss/swarm_cs4297a.c
99227 +++ b/sound/oss/swarm_cs4297a.c
99228 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
99229 {
99230 struct cs4297a_state *s;
99231 u32 pwr, id;
99232 - mm_segment_t fs;
99233 int rval;
99234 #ifndef CONFIG_BCM_CS4297A_CSWARM
99235 u64 cfg;
99236 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
99237 if (!rval) {
99238 char *sb1250_duart_present;
99239
99240 +#if 0
99241 + mm_segment_t fs;
99242 fs = get_fs();
99243 set_fs(KERNEL_DS);
99244 -#if 0
99245 val = SOUND_MASK_LINE;
99246 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
99247 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
99248 val = initvol[i].vol;
99249 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
99250 }
99251 + set_fs(fs);
99252 // cs4297a_write_ac97(s, 0x18, 0x0808);
99253 #else
99254 // cs4297a_write_ac97(s, 0x5e, 0x180);
99255 cs4297a_write_ac97(s, 0x02, 0x0808);
99256 cs4297a_write_ac97(s, 0x18, 0x0808);
99257 #endif
99258 - set_fs(fs);
99259
99260 list_add(&s->list, &cs4297a_devs);
99261
99262 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
99263 index 8a005f0..4fe3059 100644
99264 --- a/sound/pci/hda/hda_codec.c
99265 +++ b/sound/pci/hda/hda_codec.c
99266 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
99267 mutex_unlock(&preset_mutex);
99268
99269 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
99270 - char name[32];
99271 if (!mod_requested)
99272 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
99273 - codec->vendor_id);
99274 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
99275 else
99276 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
99277 - (codec->vendor_id >> 16) & 0xffff);
99278 - request_module(name);
99279 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
99280 mod_requested++;
99281 goto again;
99282 }
99283 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
99284 index 4631a23..001ae57 100644
99285 --- a/sound/pci/ymfpci/ymfpci.h
99286 +++ b/sound/pci/ymfpci/ymfpci.h
99287 @@ -358,7 +358,7 @@ struct snd_ymfpci {
99288 spinlock_t reg_lock;
99289 spinlock_t voice_lock;
99290 wait_queue_head_t interrupt_sleep;
99291 - atomic_t interrupt_sleep_count;
99292 + atomic_unchecked_t interrupt_sleep_count;
99293 struct snd_info_entry *proc_entry;
99294 const struct firmware *dsp_microcode;
99295 const struct firmware *controller_microcode;
99296 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
99297 index d591c15..8cb8f94 100644
99298 --- a/sound/pci/ymfpci/ymfpci_main.c
99299 +++ b/sound/pci/ymfpci/ymfpci_main.c
99300 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
99301 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
99302 break;
99303 }
99304 - if (atomic_read(&chip->interrupt_sleep_count)) {
99305 - atomic_set(&chip->interrupt_sleep_count, 0);
99306 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99307 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99308 wake_up(&chip->interrupt_sleep);
99309 }
99310 __end:
99311 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
99312 continue;
99313 init_waitqueue_entry(&wait, current);
99314 add_wait_queue(&chip->interrupt_sleep, &wait);
99315 - atomic_inc(&chip->interrupt_sleep_count);
99316 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
99317 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
99318 remove_wait_queue(&chip->interrupt_sleep, &wait);
99319 }
99320 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
99321 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
99322 spin_unlock(&chip->reg_lock);
99323
99324 - if (atomic_read(&chip->interrupt_sleep_count)) {
99325 - atomic_set(&chip->interrupt_sleep_count, 0);
99326 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99327 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99328 wake_up(&chip->interrupt_sleep);
99329 }
99330 }
99331 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
99332 spin_lock_init(&chip->reg_lock);
99333 spin_lock_init(&chip->voice_lock);
99334 init_waitqueue_head(&chip->interrupt_sleep);
99335 - atomic_set(&chip->interrupt_sleep_count, 0);
99336 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99337 chip->card = card;
99338 chip->pci = pci;
99339 chip->irq = -1;
99340 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
99341 index 2f2d837..3e3f1f6 100644
99342 --- a/sound/soc/fsl/fsl_ssi.c
99343 +++ b/sound/soc/fsl/fsl_ssi.c
99344 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
99345 {
99346 struct fsl_ssi_private *ssi_private;
99347 int ret = 0;
99348 - struct device_attribute *dev_attr = NULL;
99349 + device_attribute_no_const *dev_attr = NULL;
99350 struct device_node *np = pdev->dev.of_node;
99351 const char *p, *sprop;
99352 const uint32_t *iprop;
99353 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
99354 new file mode 100644
99355 index 0000000..50f2f2f
99356 --- /dev/null
99357 +++ b/tools/gcc/.gitignore
99358 @@ -0,0 +1 @@
99359 +size_overflow_hash.h
99360 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
99361 new file mode 100644
99362 index 0000000..144dbee
99363 --- /dev/null
99364 +++ b/tools/gcc/Makefile
99365 @@ -0,0 +1,45 @@
99366 +#CC := gcc
99367 +#PLUGIN_SOURCE_FILES := pax_plugin.c
99368 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
99369 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
99370 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
99371 +
99372 +ifeq ($(PLUGINCC),$(HOSTCC))
99373 +HOSTLIBS := hostlibs
99374 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
99375 +else
99376 +HOSTLIBS := hostcxxlibs
99377 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
99378 +endif
99379 +
99380 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
99381 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
99382 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
99383 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
99384 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
99385 +$(HOSTLIBS)-y += colorize_plugin.so
99386 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
99387 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
99388 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
99389 +
99390 +always := $($(HOSTLIBS)-y)
99391 +
99392 +constify_plugin-objs := constify_plugin.o
99393 +stackleak_plugin-objs := stackleak_plugin.o
99394 +kallocstat_plugin-objs := kallocstat_plugin.o
99395 +kernexec_plugin-objs := kernexec_plugin.o
99396 +checker_plugin-objs := checker_plugin.o
99397 +colorize_plugin-objs := colorize_plugin.o
99398 +size_overflow_plugin-objs := size_overflow_plugin.o
99399 +latent_entropy_plugin-objs := latent_entropy_plugin.o
99400 +structleak_plugin-objs := structleak_plugin.o
99401 +
99402 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
99403 +
99404 +quiet_cmd_build_size_overflow_hash = GENHASH $@
99405 + cmd_build_size_overflow_hash = \
99406 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
99407 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
99408 + $(call if_changed,build_size_overflow_hash)
99409 +
99410 +targets += size_overflow_hash.h
99411 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
99412 new file mode 100644
99413 index 0000000..22f03c0
99414 --- /dev/null
99415 +++ b/tools/gcc/checker_plugin.c
99416 @@ -0,0 +1,172 @@
99417 +/*
99418 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
99419 + * Licensed under the GPL v2
99420 + *
99421 + * Note: the choice of the license means that the compilation process is
99422 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99423 + * but for the kernel it doesn't matter since it doesn't link against
99424 + * any of the gcc libraries
99425 + *
99426 + * gcc plugin to implement various sparse (source code checker) features
99427 + *
99428 + * TODO:
99429 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
99430 + *
99431 + * BUGS:
99432 + * - none known
99433 + */
99434 +#include "gcc-plugin.h"
99435 +#include "config.h"
99436 +#include "system.h"
99437 +#include "coretypes.h"
99438 +#include "tree.h"
99439 +#include "tree-pass.h"
99440 +#include "flags.h"
99441 +#include "intl.h"
99442 +#include "toplev.h"
99443 +#include "plugin.h"
99444 +//#include "expr.h" where are you...
99445 +#include "diagnostic.h"
99446 +#include "plugin-version.h"
99447 +#include "tm.h"
99448 +#include "function.h"
99449 +#include "basic-block.h"
99450 +#include "gimple.h"
99451 +#include "rtl.h"
99452 +#include "emit-rtl.h"
99453 +#include "tree-flow.h"
99454 +#include "target.h"
99455 +
99456 +extern void c_register_addr_space (const char *str, addr_space_t as);
99457 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
99458 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
99459 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
99460 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
99461 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
99462 +
99463 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99464 +extern rtx emit_move_insn(rtx x, rtx y);
99465 +
99466 +int plugin_is_GPL_compatible;
99467 +
99468 +static struct plugin_info checker_plugin_info = {
99469 + .version = "201111150100",
99470 + .help = NULL,
99471 +};
99472 +
99473 +#define ADDR_SPACE_KERNEL 0
99474 +#define ADDR_SPACE_FORCE_KERNEL 1
99475 +#define ADDR_SPACE_USER 2
99476 +#define ADDR_SPACE_FORCE_USER 3
99477 +#define ADDR_SPACE_IOMEM 0
99478 +#define ADDR_SPACE_FORCE_IOMEM 0
99479 +#define ADDR_SPACE_PERCPU 0
99480 +#define ADDR_SPACE_FORCE_PERCPU 0
99481 +#define ADDR_SPACE_RCU 0
99482 +#define ADDR_SPACE_FORCE_RCU 0
99483 +
99484 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
99485 +{
99486 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
99487 +}
99488 +
99489 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
99490 +{
99491 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
99492 +}
99493 +
99494 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
99495 +{
99496 + return default_addr_space_valid_pointer_mode(mode, as);
99497 +}
99498 +
99499 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
99500 +{
99501 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
99502 +}
99503 +
99504 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
99505 +{
99506 + return default_addr_space_legitimize_address(x, oldx, mode, as);
99507 +}
99508 +
99509 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
99510 +{
99511 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
99512 + return true;
99513 +
99514 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
99515 + return true;
99516 +
99517 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
99518 + return true;
99519 +
99520 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
99521 + return true;
99522 +
99523 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
99524 + return true;
99525 +
99526 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
99527 + return true;
99528 +
99529 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
99530 + return true;
99531 +
99532 + return subset == superset;
99533 +}
99534 +
99535 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
99536 +{
99537 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
99538 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
99539 +
99540 + return op;
99541 +}
99542 +
99543 +static void register_checker_address_spaces(void *event_data, void *data)
99544 +{
99545 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
99546 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
99547 + c_register_addr_space("__user", ADDR_SPACE_USER);
99548 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
99549 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
99550 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
99551 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
99552 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
99553 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
99554 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
99555 +
99556 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
99557 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
99558 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
99559 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
99560 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
99561 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
99562 + targetm.addr_space.convert = checker_addr_space_convert;
99563 +}
99564 +
99565 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99566 +{
99567 + const char * const plugin_name = plugin_info->base_name;
99568 + const int argc = plugin_info->argc;
99569 + const struct plugin_argument * const argv = plugin_info->argv;
99570 + int i;
99571 +
99572 + if (!plugin_default_version_check(version, &gcc_version)) {
99573 + error(G_("incompatible gcc/plugin versions"));
99574 + return 1;
99575 + }
99576 +
99577 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
99578 +
99579 + for (i = 0; i < argc; ++i)
99580 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99581 +
99582 + if (TARGET_64BIT == 0)
99583 + return 0;
99584 +
99585 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
99586 +
99587 + return 0;
99588 +}
99589 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
99590 new file mode 100644
99591 index 0000000..414fe5e
99592 --- /dev/null
99593 +++ b/tools/gcc/colorize_plugin.c
99594 @@ -0,0 +1,151 @@
99595 +/*
99596 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
99597 + * Licensed under the GPL v2
99598 + *
99599 + * Note: the choice of the license means that the compilation process is
99600 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99601 + * but for the kernel it doesn't matter since it doesn't link against
99602 + * any of the gcc libraries
99603 + *
99604 + * gcc plugin to colorize diagnostic output
99605 + *
99606 + */
99607 +
99608 +#include "gcc-plugin.h"
99609 +#include "config.h"
99610 +#include "system.h"
99611 +#include "coretypes.h"
99612 +#include "tree.h"
99613 +#include "tree-pass.h"
99614 +#include "flags.h"
99615 +#include "intl.h"
99616 +#include "toplev.h"
99617 +#include "plugin.h"
99618 +#include "diagnostic.h"
99619 +#include "plugin-version.h"
99620 +#include "tm.h"
99621 +
99622 +int plugin_is_GPL_compatible;
99623 +
99624 +static struct plugin_info colorize_plugin_info = {
99625 + .version = "201302112000",
99626 + .help = NULL,
99627 +};
99628 +
99629 +#define GREEN "\033[32m\033[2m"
99630 +#define LIGHTGREEN "\033[32m\033[1m"
99631 +#define YELLOW "\033[33m\033[2m"
99632 +#define LIGHTYELLOW "\033[33m\033[1m"
99633 +#define RED "\033[31m\033[2m"
99634 +#define LIGHTRED "\033[31m\033[1m"
99635 +#define BLUE "\033[34m\033[2m"
99636 +#define LIGHTBLUE "\033[34m\033[1m"
99637 +#define BRIGHT "\033[m\033[1m"
99638 +#define NORMAL "\033[m"
99639 +
99640 +static diagnostic_starter_fn old_starter;
99641 +static diagnostic_finalizer_fn old_finalizer;
99642 +
99643 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99644 +{
99645 + const char *color;
99646 + char *newprefix;
99647 +
99648 + switch (diagnostic->kind) {
99649 + case DK_NOTE:
99650 + color = LIGHTBLUE;
99651 + break;
99652 +
99653 + case DK_PEDWARN:
99654 + case DK_WARNING:
99655 + color = LIGHTYELLOW;
99656 + break;
99657 +
99658 + case DK_ERROR:
99659 + case DK_FATAL:
99660 + case DK_ICE:
99661 + case DK_PERMERROR:
99662 + case DK_SORRY:
99663 + color = LIGHTRED;
99664 + break;
99665 +
99666 + default:
99667 + color = NORMAL;
99668 + }
99669 +
99670 + old_starter(context, diagnostic);
99671 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
99672 + return;
99673 + pp_destroy_prefix(context->printer);
99674 + pp_set_prefix(context->printer, newprefix);
99675 +}
99676 +
99677 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99678 +{
99679 + old_finalizer(context, diagnostic);
99680 +}
99681 +
99682 +static void colorize_arm(void)
99683 +{
99684 + old_starter = diagnostic_starter(global_dc);
99685 + old_finalizer = diagnostic_finalizer(global_dc);
99686 +
99687 + diagnostic_starter(global_dc) = start_colorize;
99688 + diagnostic_finalizer(global_dc) = finalize_colorize;
99689 +}
99690 +
99691 +static unsigned int execute_colorize_rearm(void)
99692 +{
99693 + if (diagnostic_starter(global_dc) == start_colorize)
99694 + return 0;
99695 +
99696 + colorize_arm();
99697 + return 0;
99698 +}
99699 +
99700 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
99701 + .pass = {
99702 + .type = SIMPLE_IPA_PASS,
99703 + .name = "colorize_rearm",
99704 +#if BUILDING_GCC_VERSION >= 4008
99705 + .optinfo_flags = OPTGROUP_NONE,
99706 +#endif
99707 + .gate = NULL,
99708 + .execute = execute_colorize_rearm,
99709 + .sub = NULL,
99710 + .next = NULL,
99711 + .static_pass_number = 0,
99712 + .tv_id = TV_NONE,
99713 + .properties_required = 0,
99714 + .properties_provided = 0,
99715 + .properties_destroyed = 0,
99716 + .todo_flags_start = 0,
99717 + .todo_flags_finish = 0
99718 + }
99719 +};
99720 +
99721 +static void colorize_start_unit(void *gcc_data, void *user_data)
99722 +{
99723 + colorize_arm();
99724 +}
99725 +
99726 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99727 +{
99728 + const char * const plugin_name = plugin_info->base_name;
99729 + struct register_pass_info colorize_rearm_pass_info = {
99730 + .pass = &pass_ipa_colorize_rearm.pass,
99731 + .reference_pass_name = "*free_lang_data",
99732 + .ref_pass_instance_number = 1,
99733 + .pos_op = PASS_POS_INSERT_AFTER
99734 + };
99735 +
99736 + if (!plugin_default_version_check(version, &gcc_version)) {
99737 + error(G_("incompatible gcc/plugin versions"));
99738 + return 1;
99739 + }
99740 +
99741 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
99742 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
99743 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
99744 + return 0;
99745 +}
99746 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
99747 new file mode 100644
99748 index 0000000..c17312d
99749 --- /dev/null
99750 +++ b/tools/gcc/constify_plugin.c
99751 @@ -0,0 +1,560 @@
99752 +/*
99753 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
99754 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
99755 + * Licensed under the GPL v2, or (at your option) v3
99756 + *
99757 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
99758 + *
99759 + * Homepage:
99760 + * http://www.grsecurity.net/~ephox/const_plugin/
99761 + *
99762 + * Usage:
99763 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
99764 + * $ gcc -fplugin=constify_plugin.so test.c -O2
99765 + */
99766 +
99767 +#include "gcc-plugin.h"
99768 +#include "config.h"
99769 +#include "system.h"
99770 +#include "coretypes.h"
99771 +#include "tree.h"
99772 +#include "tree-pass.h"
99773 +#include "flags.h"
99774 +#include "intl.h"
99775 +#include "toplev.h"
99776 +#include "plugin.h"
99777 +#include "diagnostic.h"
99778 +#include "plugin-version.h"
99779 +#include "tm.h"
99780 +#include "function.h"
99781 +#include "basic-block.h"
99782 +#include "gimple.h"
99783 +#include "rtl.h"
99784 +#include "emit-rtl.h"
99785 +#include "tree-flow.h"
99786 +#include "target.h"
99787 +#include "langhooks.h"
99788 +
99789 +// should come from c-tree.h if only it were installed for gcc 4.5...
99790 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
99791 +
99792 +// unused type flag in all versions 4.5-4.8
99793 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
99794 +
99795 +int plugin_is_GPL_compatible;
99796 +
99797 +static struct plugin_info const_plugin_info = {
99798 + .version = "201305231310",
99799 + .help = "no-constify\tturn off constification\n",
99800 +};
99801 +
99802 +typedef struct {
99803 + bool has_fptr_field;
99804 + bool has_writable_field;
99805 + bool has_do_const_field;
99806 + bool has_no_const_field;
99807 +} constify_info;
99808 +
99809 +static const_tree get_field_type(const_tree field)
99810 +{
99811 + return strip_array_types(TREE_TYPE(field));
99812 +}
99813 +
99814 +static bool is_fptr(const_tree field)
99815 +{
99816 + const_tree ptr = get_field_type(field);
99817 +
99818 + if (TREE_CODE(ptr) != POINTER_TYPE)
99819 + return false;
99820 +
99821 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
99822 +}
99823 +
99824 +/*
99825 + * determine whether the given structure type meets the requirements for automatic constification,
99826 + * including the constification attributes on nested structure types
99827 + */
99828 +static void constifiable(const_tree node, constify_info *cinfo)
99829 +{
99830 + const_tree field;
99831 +
99832 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
99833 +
99834 + // e.g., pointer to structure fields while still constructing the structure type
99835 + if (TYPE_FIELDS(node) == NULL_TREE)
99836 + return;
99837 +
99838 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
99839 + const_tree type = get_field_type(field);
99840 + enum tree_code code = TREE_CODE(type);
99841 +
99842 + if (node == type)
99843 + continue;
99844 +
99845 + if (is_fptr(field))
99846 + cinfo->has_fptr_field = true;
99847 + else if (!TREE_READONLY(field))
99848 + cinfo->has_writable_field = true;
99849 +
99850 + if (code == RECORD_TYPE || code == UNION_TYPE) {
99851 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99852 + cinfo->has_do_const_field = true;
99853 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
99854 + cinfo->has_no_const_field = true;
99855 + else
99856 + constifiable(type, cinfo);
99857 + }
99858 + }
99859 +}
99860 +
99861 +static bool constified(const_tree node)
99862 +{
99863 + constify_info cinfo = {
99864 + .has_fptr_field = false,
99865 + .has_writable_field = false,
99866 + .has_do_const_field = false,
99867 + .has_no_const_field = false
99868 + };
99869 +
99870 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
99871 +
99872 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
99873 + gcc_assert(!TYPE_READONLY(node));
99874 + return false;
99875 + }
99876 +
99877 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
99878 + gcc_assert(TYPE_READONLY(node));
99879 + return true;
99880 + }
99881 +
99882 + constifiable(node, &cinfo);
99883 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
99884 + return false;
99885 +
99886 + return TYPE_READONLY(node);
99887 +}
99888 +
99889 +static void deconstify_tree(tree node);
99890 +
99891 +static void deconstify_type(tree type)
99892 +{
99893 + tree field;
99894 +
99895 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
99896 +
99897 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
99898 + const_tree fieldtype = get_field_type(field);
99899 +
99900 + // special case handling of simple ptr-to-same-array-type members
99901 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
99902 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
99903 +
99904 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
99905 + continue;
99906 + if (TREE_TYPE(TREE_TYPE(field)) == type)
99907 + continue;
99908 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
99909 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
99910 + TREE_TYPE(TREE_TYPE(field)) = type;
99911 + }
99912 + continue;
99913 + }
99914 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
99915 + continue;
99916 + if (!constified(fieldtype))
99917 + continue;
99918 +
99919 + deconstify_tree(field);
99920 + TREE_READONLY(field) = 0;
99921 + }
99922 + TYPE_READONLY(type) = 0;
99923 + C_TYPE_FIELDS_READONLY(type) = 0;
99924 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99925 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
99926 +}
99927 +
99928 +static void deconstify_tree(tree node)
99929 +{
99930 + tree old_type, new_type, field;
99931 +
99932 + old_type = TREE_TYPE(node);
99933 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
99934 + node = TREE_TYPE(node) = copy_node(old_type);
99935 + old_type = TREE_TYPE(old_type);
99936 + }
99937 +
99938 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
99939 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
99940 +
99941 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
99942 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
99943 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
99944 + DECL_FIELD_CONTEXT(field) = new_type;
99945 +
99946 + deconstify_type(new_type);
99947 +
99948 + TREE_TYPE(node) = new_type;
99949 +}
99950 +
99951 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
99952 +{
99953 + tree type;
99954 + constify_info cinfo = {
99955 + .has_fptr_field = false,
99956 + .has_writable_field = false,
99957 + .has_do_const_field = false,
99958 + .has_no_const_field = false
99959 + };
99960 +
99961 + *no_add_attrs = true;
99962 + if (TREE_CODE(*node) == FUNCTION_DECL) {
99963 + error("%qE attribute does not apply to functions", name);
99964 + return NULL_TREE;
99965 + }
99966 +
99967 + if (TREE_CODE(*node) == PARM_DECL) {
99968 + error("%qE attribute does not apply to function parameters", name);
99969 + return NULL_TREE;
99970 + }
99971 +
99972 + if (TREE_CODE(*node) == VAR_DECL) {
99973 + error("%qE attribute does not apply to variables", name);
99974 + return NULL_TREE;
99975 + }
99976 +
99977 + if (TYPE_P(*node)) {
99978 + *no_add_attrs = false;
99979 + type = *node;
99980 + } else {
99981 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
99982 + type = TREE_TYPE(*node);
99983 + }
99984 +
99985 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
99986 + error("%qE attribute applies to struct and union types only", name);
99987 + return NULL_TREE;
99988 + }
99989 +
99990 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
99991 + error("%qE attribute is already applied to the type", name);
99992 + return NULL_TREE;
99993 + }
99994 +
99995 + if (TYPE_P(*node)) {
99996 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99997 + error("%qE attribute is incompatible with 'do_const'", name);
99998 + return NULL_TREE;
99999 + }
100000 +
100001 + constifiable(type, &cinfo);
100002 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100003 + deconstify_tree(*node);
100004 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100005 + return NULL_TREE;
100006 + }
100007 +
100008 + error("%qE attribute used on type that is not constified", name);
100009 + return NULL_TREE;
100010 +}
100011 +
100012 +static void constify_type(tree type)
100013 +{
100014 + TYPE_READONLY(type) = 1;
100015 + C_TYPE_FIELDS_READONLY(type) = 1;
100016 + TYPE_CONSTIFY_VISITED(type) = 1;
100017 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100018 +}
100019 +
100020 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100021 +{
100022 + *no_add_attrs = true;
100023 + if (!TYPE_P(*node)) {
100024 + error("%qE attribute applies to types only", name);
100025 + return NULL_TREE;
100026 + }
100027 +
100028 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100029 + error("%qE attribute applies to struct and union types only", name);
100030 + return NULL_TREE;
100031 + }
100032 +
100033 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100034 + error("%qE attribute is already applied to the type", name);
100035 + return NULL_TREE;
100036 + }
100037 +
100038 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100039 + error("%qE attribute is incompatible with 'no_const'", name);
100040 + return NULL_TREE;
100041 + }
100042 +
100043 + *no_add_attrs = false;
100044 + return NULL_TREE;
100045 +}
100046 +
100047 +static struct attribute_spec no_const_attr = {
100048 + .name = "no_const",
100049 + .min_length = 0,
100050 + .max_length = 0,
100051 + .decl_required = false,
100052 + .type_required = false,
100053 + .function_type_required = false,
100054 + .handler = handle_no_const_attribute,
100055 +#if BUILDING_GCC_VERSION >= 4007
100056 + .affects_type_identity = true
100057 +#endif
100058 +};
100059 +
100060 +static struct attribute_spec do_const_attr = {
100061 + .name = "do_const",
100062 + .min_length = 0,
100063 + .max_length = 0,
100064 + .decl_required = false,
100065 + .type_required = false,
100066 + .function_type_required = false,
100067 + .handler = handle_do_const_attribute,
100068 +#if BUILDING_GCC_VERSION >= 4007
100069 + .affects_type_identity = true
100070 +#endif
100071 +};
100072 +
100073 +static void register_attributes(void *event_data, void *data)
100074 +{
100075 + register_attribute(&no_const_attr);
100076 + register_attribute(&do_const_attr);
100077 +}
100078 +
100079 +static void finish_type(void *event_data, void *data)
100080 +{
100081 + tree type = (tree)event_data;
100082 + constify_info cinfo = {
100083 + .has_fptr_field = false,
100084 + .has_writable_field = false,
100085 + .has_do_const_field = false,
100086 + .has_no_const_field = false
100087 + };
100088 +
100089 + if (type == NULL_TREE || type == error_mark_node)
100090 + return;
100091 +
100092 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100093 + return;
100094 +
100095 + constifiable(type, &cinfo);
100096 +
100097 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100098 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100099 + return;
100100 + if (cinfo.has_writable_field)
100101 + return;
100102 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100103 + return;
100104 + }
100105 +
100106 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100107 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100108 + deconstify_type(type);
100109 + TYPE_CONSTIFY_VISITED(type) = 1;
100110 + } else
100111 + error("'no_const' attribute used on type that is not constified");
100112 + return;
100113 + }
100114 +
100115 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100116 + constify_type(type);
100117 + return;
100118 + }
100119 +
100120 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100121 + constify_type(type);
100122 + return;
100123 + }
100124 +
100125 + deconstify_type(type);
100126 + TYPE_CONSTIFY_VISITED(type) = 1;
100127 +}
100128 +
100129 +static void check_global_variables(void)
100130 +{
100131 + struct varpool_node *node;
100132 +
100133 +#if BUILDING_GCC_VERSION <= 4007
100134 + for (node = varpool_nodes; node; node = node->next) {
100135 + tree var = node->decl;
100136 +#else
100137 + FOR_EACH_VARIABLE(node) {
100138 + tree var = node->symbol.decl;
100139 +#endif
100140 + tree type = TREE_TYPE(var);
100141 +
100142 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100143 + continue;
100144 +
100145 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100146 + continue;
100147 +
100148 + if (!TYPE_CONSTIFY_VISITED(type))
100149 + continue;
100150 +
100151 + if (DECL_EXTERNAL(var))
100152 + continue;
100153 +
100154 + if (DECL_INITIAL(var))
100155 + continue;
100156 +
100157 + // this works around a gcc bug/feature where uninitialized globals
100158 + // are moved into the .bss section regardless of any constification
100159 + DECL_INITIAL(var) = build_constructor(type, NULL);
100160 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100161 + }
100162 +}
100163 +
100164 +static unsigned int check_local_variables(void)
100165 +{
100166 + unsigned int ret = 0;
100167 + tree var;
100168 +
100169 +#if BUILDING_GCC_VERSION == 4005
100170 + tree vars;
100171 +#else
100172 + unsigned int i;
100173 +#endif
100174 +
100175 +#if BUILDING_GCC_VERSION == 4005
100176 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100177 + var = TREE_VALUE(vars);
100178 +#else
100179 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100180 +#endif
100181 + tree type = TREE_TYPE(var);
100182 +
100183 + gcc_assert(DECL_P(var));
100184 + if (is_global_var(var))
100185 + continue;
100186 +
100187 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100188 + continue;
100189 +
100190 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100191 + continue;
100192 +
100193 + if (!TYPE_CONSTIFY_VISITED(type))
100194 + continue;
100195 +
100196 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
100197 + ret = 1;
100198 + }
100199 + return ret;
100200 +}
100201 +
100202 +static unsigned int check_variables(void)
100203 +{
100204 + check_global_variables();
100205 + return check_local_variables();
100206 +}
100207 +
100208 + unsigned int ret = 0;
100209 +static struct gimple_opt_pass pass_local_variable = {
100210 + {
100211 + .type = GIMPLE_PASS,
100212 + .name = "check_variables",
100213 +#if BUILDING_GCC_VERSION >= 4008
100214 + .optinfo_flags = OPTGROUP_NONE,
100215 +#endif
100216 + .gate = NULL,
100217 + .execute = check_variables,
100218 + .sub = NULL,
100219 + .next = NULL,
100220 + .static_pass_number = 0,
100221 + .tv_id = TV_NONE,
100222 + .properties_required = 0,
100223 + .properties_provided = 0,
100224 + .properties_destroyed = 0,
100225 + .todo_flags_start = 0,
100226 + .todo_flags_finish = 0
100227 + }
100228 +};
100229 +
100230 +static struct {
100231 + const char *name;
100232 + const char *asm_op;
100233 +} sections[] = {
100234 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
100235 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
100236 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
100237 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
100238 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
100239 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
100240 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
100241 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
100242 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
100243 +};
100244 +
100245 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
100246 +
100247 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
100248 +{
100249 + size_t i;
100250 +
100251 + for (i = 0; i < ARRAY_SIZE(sections); i++)
100252 + if (!strcmp(sections[i].name, name))
100253 + return 0;
100254 + return old_section_type_flags(decl, name, reloc);
100255 +}
100256 +
100257 +static void constify_start_unit(void *gcc_data, void *user_data)
100258 +{
100259 +// size_t i;
100260 +
100261 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
100262 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
100263 +// sections[i].section = get_section(sections[i].name, 0, NULL);
100264 +
100265 + old_section_type_flags = targetm.section_type_flags;
100266 + targetm.section_type_flags = constify_section_type_flags;
100267 +}
100268 +
100269 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100270 +{
100271 + const char * const plugin_name = plugin_info->base_name;
100272 + const int argc = plugin_info->argc;
100273 + const struct plugin_argument * const argv = plugin_info->argv;
100274 + int i;
100275 + bool constify = true;
100276 +
100277 + struct register_pass_info local_variable_pass_info = {
100278 + .pass = &pass_local_variable.pass,
100279 + .reference_pass_name = "ssa",
100280 + .ref_pass_instance_number = 1,
100281 + .pos_op = PASS_POS_INSERT_BEFORE
100282 + };
100283 +
100284 + if (!plugin_default_version_check(version, &gcc_version)) {
100285 + error(G_("incompatible gcc/plugin versions"));
100286 + return 1;
100287 + }
100288 +
100289 + for (i = 0; i < argc; ++i) {
100290 + if (!(strcmp(argv[i].key, "no-constify"))) {
100291 + constify = false;
100292 + continue;
100293 + }
100294 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100295 + }
100296 +
100297 + if (strcmp(lang_hooks.name, "GNU C")) {
100298 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
100299 + constify = false;
100300 + }
100301 +
100302 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
100303 + if (constify) {
100304 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
100305 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
100306 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
100307 + }
100308 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
100309 +
100310 + return 0;
100311 +}
100312 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
100313 new file mode 100644
100314 index 0000000..e518932
100315 --- /dev/null
100316 +++ b/tools/gcc/generate_size_overflow_hash.sh
100317 @@ -0,0 +1,94 @@
100318 +#!/bin/bash
100319 +
100320 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
100321 +
100322 +header1="size_overflow_hash.h"
100323 +database="size_overflow_hash.data"
100324 +n=65536
100325 +
100326 +usage() {
100327 +cat <<EOF
100328 +usage: $0 options
100329 +OPTIONS:
100330 + -h|--help help
100331 + -o header file
100332 + -d database file
100333 + -n hash array size
100334 +EOF
100335 + return 0
100336 +}
100337 +
100338 +while true
100339 +do
100340 + case "$1" in
100341 + -h|--help) usage && exit 0;;
100342 + -n) n=$2; shift 2;;
100343 + -o) header1="$2"; shift 2;;
100344 + -d) database="$2"; shift 2;;
100345 + --) shift 1; break ;;
100346 + *) break ;;
100347 + esac
100348 +done
100349 +
100350 +create_defines() {
100351 + for i in `seq 0 31`
100352 + do
100353 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
100354 + done
100355 + echo >> "$header1"
100356 +}
100357 +
100358 +create_structs() {
100359 + rm -f "$header1"
100360 +
100361 + create_defines
100362 +
100363 + cat "$database" | while read data
100364 + do
100365 + data_array=($data)
100366 + struct_hash_name="${data_array[0]}"
100367 + funcn="${data_array[1]}"
100368 + params="${data_array[2]}"
100369 + next="${data_array[4]}"
100370 +
100371 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
100372 +
100373 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
100374 + echo -en "\t.param\t= " >> "$header1"
100375 + line=
100376 + for param_num in ${params//-/ };
100377 + do
100378 + line="${line}PARAM"$param_num"|"
100379 + done
100380 +
100381 + echo -e "${line%?},\n};\n" >> "$header1"
100382 + done
100383 +}
100384 +
100385 +create_headers() {
100386 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
100387 +}
100388 +
100389 +create_array_elements() {
100390 + index=0
100391 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
100392 + do
100393 + data_array=($data)
100394 + i="${data_array[3]}"
100395 + hash="${data_array[0]}"
100396 + while [[ $index -lt $i ]]
100397 + do
100398 + echo -e "\t["$index"]\t= NULL," >> "$header1"
100399 + index=$(($index + 1))
100400 + done
100401 + index=$(($index + 1))
100402 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
100403 + done
100404 + echo '};' >> $header1
100405 +}
100406 +
100407 +create_structs
100408 +create_headers
100409 +create_array_elements
100410 +
100411 +exit 0
100412 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
100413 new file mode 100644
100414 index 0000000..568b360
100415 --- /dev/null
100416 +++ b/tools/gcc/kallocstat_plugin.c
100417 @@ -0,0 +1,170 @@
100418 +/*
100419 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100420 + * Licensed under the GPL v2
100421 + *
100422 + * Note: the choice of the license means that the compilation process is
100423 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100424 + * but for the kernel it doesn't matter since it doesn't link against
100425 + * any of the gcc libraries
100426 + *
100427 + * gcc plugin to find the distribution of k*alloc sizes
100428 + *
100429 + * TODO:
100430 + *
100431 + * BUGS:
100432 + * - none known
100433 + */
100434 +#include "gcc-plugin.h"
100435 +#include "config.h"
100436 +#include "system.h"
100437 +#include "coretypes.h"
100438 +#include "tree.h"
100439 +#include "tree-pass.h"
100440 +#include "flags.h"
100441 +#include "intl.h"
100442 +#include "toplev.h"
100443 +#include "plugin.h"
100444 +//#include "expr.h" where are you...
100445 +#include "diagnostic.h"
100446 +#include "plugin-version.h"
100447 +#include "tm.h"
100448 +#include "function.h"
100449 +#include "basic-block.h"
100450 +#include "gimple.h"
100451 +#include "rtl.h"
100452 +#include "emit-rtl.h"
100453 +
100454 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100455 +
100456 +int plugin_is_GPL_compatible;
100457 +
100458 +static const char * const kalloc_functions[] = {
100459 + "__kmalloc",
100460 + "kmalloc",
100461 + "kmalloc_large",
100462 + "kmalloc_node",
100463 + "kmalloc_order",
100464 + "kmalloc_order_trace",
100465 + "kmalloc_slab",
100466 + "kzalloc",
100467 + "kzalloc_node",
100468 +};
100469 +
100470 +static struct plugin_info kallocstat_plugin_info = {
100471 + .version = "201302112000",
100472 +};
100473 +
100474 +static unsigned int execute_kallocstat(void);
100475 +
100476 +static struct gimple_opt_pass kallocstat_pass = {
100477 + .pass = {
100478 + .type = GIMPLE_PASS,
100479 + .name = "kallocstat",
100480 +#if BUILDING_GCC_VERSION >= 4008
100481 + .optinfo_flags = OPTGROUP_NONE,
100482 +#endif
100483 + .gate = NULL,
100484 + .execute = execute_kallocstat,
100485 + .sub = NULL,
100486 + .next = NULL,
100487 + .static_pass_number = 0,
100488 + .tv_id = TV_NONE,
100489 + .properties_required = 0,
100490 + .properties_provided = 0,
100491 + .properties_destroyed = 0,
100492 + .todo_flags_start = 0,
100493 + .todo_flags_finish = 0
100494 + }
100495 +};
100496 +
100497 +static bool is_kalloc(const char *fnname)
100498 +{
100499 + size_t i;
100500 +
100501 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
100502 + if (!strcmp(fnname, kalloc_functions[i]))
100503 + return true;
100504 + return false;
100505 +}
100506 +
100507 +static unsigned int execute_kallocstat(void)
100508 +{
100509 + basic_block bb;
100510 +
100511 + // 1. loop through BBs and GIMPLE statements
100512 + FOR_EACH_BB(bb) {
100513 + gimple_stmt_iterator gsi;
100514 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100515 + // gimple match:
100516 + tree fndecl, size;
100517 + gimple call_stmt;
100518 + const char *fnname;
100519 +
100520 + // is it a call
100521 + call_stmt = gsi_stmt(gsi);
100522 + if (!is_gimple_call(call_stmt))
100523 + continue;
100524 + fndecl = gimple_call_fndecl(call_stmt);
100525 + if (fndecl == NULL_TREE)
100526 + continue;
100527 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
100528 + continue;
100529 +
100530 + // is it a call to k*alloc
100531 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
100532 + if (!is_kalloc(fnname))
100533 + continue;
100534 +
100535 + // is the size arg the result of a simple const assignment
100536 + size = gimple_call_arg(call_stmt, 0);
100537 + while (true) {
100538 + gimple def_stmt;
100539 + expanded_location xloc;
100540 + size_t size_val;
100541 +
100542 + if (TREE_CODE(size) != SSA_NAME)
100543 + break;
100544 + def_stmt = SSA_NAME_DEF_STMT(size);
100545 + if (!def_stmt || !is_gimple_assign(def_stmt))
100546 + break;
100547 + if (gimple_num_ops(def_stmt) != 2)
100548 + break;
100549 + size = gimple_assign_rhs1(def_stmt);
100550 + if (!TREE_CONSTANT(size))
100551 + continue;
100552 + xloc = expand_location(gimple_location(def_stmt));
100553 + if (!xloc.file)
100554 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
100555 + size_val = TREE_INT_CST_LOW(size);
100556 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
100557 + break;
100558 + }
100559 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
100560 +//debug_tree(gimple_call_fn(call_stmt));
100561 +//print_node(stderr, "pax", fndecl, 4);
100562 + }
100563 + }
100564 +
100565 + return 0;
100566 +}
100567 +
100568 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100569 +{
100570 + const char * const plugin_name = plugin_info->base_name;
100571 + struct register_pass_info kallocstat_pass_info = {
100572 + .pass = &kallocstat_pass.pass,
100573 + .reference_pass_name = "ssa",
100574 + .ref_pass_instance_number = 1,
100575 + .pos_op = PASS_POS_INSERT_AFTER
100576 + };
100577 +
100578 + if (!plugin_default_version_check(version, &gcc_version)) {
100579 + error(G_("incompatible gcc/plugin versions"));
100580 + return 1;
100581 + }
100582 +
100583 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
100584 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
100585 +
100586 + return 0;
100587 +}
100588 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
100589 new file mode 100644
100590 index 0000000..698da67
100591 --- /dev/null
100592 +++ b/tools/gcc/kernexec_plugin.c
100593 @@ -0,0 +1,471 @@
100594 +/*
100595 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100596 + * Licensed under the GPL v2
100597 + *
100598 + * Note: the choice of the license means that the compilation process is
100599 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100600 + * but for the kernel it doesn't matter since it doesn't link against
100601 + * any of the gcc libraries
100602 + *
100603 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
100604 + *
100605 + * TODO:
100606 + *
100607 + * BUGS:
100608 + * - none known
100609 + */
100610 +#include "gcc-plugin.h"
100611 +#include "config.h"
100612 +#include "system.h"
100613 +#include "coretypes.h"
100614 +#include "tree.h"
100615 +#include "tree-pass.h"
100616 +#include "flags.h"
100617 +#include "intl.h"
100618 +#include "toplev.h"
100619 +#include "plugin.h"
100620 +//#include "expr.h" where are you...
100621 +#include "diagnostic.h"
100622 +#include "plugin-version.h"
100623 +#include "tm.h"
100624 +#include "function.h"
100625 +#include "basic-block.h"
100626 +#include "gimple.h"
100627 +#include "rtl.h"
100628 +#include "emit-rtl.h"
100629 +#include "tree-flow.h"
100630 +
100631 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100632 +extern rtx emit_move_insn(rtx x, rtx y);
100633 +
100634 +#if BUILDING_GCC_VERSION <= 4006
100635 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
100636 +#endif
100637 +
100638 +#if BUILDING_GCC_VERSION >= 4008
100639 +#define TODO_dump_func 0
100640 +#endif
100641 +
100642 +int plugin_is_GPL_compatible;
100643 +
100644 +static struct plugin_info kernexec_plugin_info = {
100645 + .version = "201308230150",
100646 + .help = "method=[bts|or]\tinstrumentation method\n"
100647 +};
100648 +
100649 +static unsigned int execute_kernexec_reload(void);
100650 +static unsigned int execute_kernexec_fptr(void);
100651 +static unsigned int execute_kernexec_retaddr(void);
100652 +static bool kernexec_cmodel_check(void);
100653 +
100654 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
100655 +static void (*kernexec_instrument_retaddr)(rtx);
100656 +
100657 +static struct gimple_opt_pass kernexec_reload_pass = {
100658 + .pass = {
100659 + .type = GIMPLE_PASS,
100660 + .name = "kernexec_reload",
100661 +#if BUILDING_GCC_VERSION >= 4008
100662 + .optinfo_flags = OPTGROUP_NONE,
100663 +#endif
100664 + .gate = kernexec_cmodel_check,
100665 + .execute = execute_kernexec_reload,
100666 + .sub = NULL,
100667 + .next = NULL,
100668 + .static_pass_number = 0,
100669 + .tv_id = TV_NONE,
100670 + .properties_required = 0,
100671 + .properties_provided = 0,
100672 + .properties_destroyed = 0,
100673 + .todo_flags_start = 0,
100674 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100675 + }
100676 +};
100677 +
100678 +static struct gimple_opt_pass kernexec_fptr_pass = {
100679 + .pass = {
100680 + .type = GIMPLE_PASS,
100681 + .name = "kernexec_fptr",
100682 +#if BUILDING_GCC_VERSION >= 4008
100683 + .optinfo_flags = OPTGROUP_NONE,
100684 +#endif
100685 + .gate = kernexec_cmodel_check,
100686 + .execute = execute_kernexec_fptr,
100687 + .sub = NULL,
100688 + .next = NULL,
100689 + .static_pass_number = 0,
100690 + .tv_id = TV_NONE,
100691 + .properties_required = 0,
100692 + .properties_provided = 0,
100693 + .properties_destroyed = 0,
100694 + .todo_flags_start = 0,
100695 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100696 + }
100697 +};
100698 +
100699 +static struct rtl_opt_pass kernexec_retaddr_pass = {
100700 + .pass = {
100701 + .type = RTL_PASS,
100702 + .name = "kernexec_retaddr",
100703 +#if BUILDING_GCC_VERSION >= 4008
100704 + .optinfo_flags = OPTGROUP_NONE,
100705 +#endif
100706 + .gate = kernexec_cmodel_check,
100707 + .execute = execute_kernexec_retaddr,
100708 + .sub = NULL,
100709 + .next = NULL,
100710 + .static_pass_number = 0,
100711 + .tv_id = TV_NONE,
100712 + .properties_required = 0,
100713 + .properties_provided = 0,
100714 + .properties_destroyed = 0,
100715 + .todo_flags_start = 0,
100716 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
100717 + }
100718 +};
100719 +
100720 +static bool kernexec_cmodel_check(void)
100721 +{
100722 + tree section;
100723 +
100724 + if (ix86_cmodel != CM_KERNEL)
100725 + return false;
100726 +
100727 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
100728 + if (!section || !TREE_VALUE(section))
100729 + return true;
100730 +
100731 + section = TREE_VALUE(TREE_VALUE(section));
100732 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
100733 + return true;
100734 +
100735 + return false;
100736 +}
100737 +
100738 +/*
100739 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
100740 + */
100741 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
100742 +{
100743 + gimple asm_movabs_stmt;
100744 +
100745 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
100746 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
100747 + gimple_asm_set_volatile(asm_movabs_stmt, true);
100748 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
100749 + update_stmt(asm_movabs_stmt);
100750 +}
100751 +
100752 +/*
100753 + * find all asm() stmts that clobber r10 and add a reload of r10
100754 + */
100755 +static unsigned int execute_kernexec_reload(void)
100756 +{
100757 + basic_block bb;
100758 +
100759 + // 1. loop through BBs and GIMPLE statements
100760 + FOR_EACH_BB(bb) {
100761 + gimple_stmt_iterator gsi;
100762 +
100763 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100764 + // gimple match: __asm__ ("" : : : "r10");
100765 + gimple asm_stmt;
100766 + size_t nclobbers;
100767 +
100768 + // is it an asm ...
100769 + asm_stmt = gsi_stmt(gsi);
100770 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
100771 + continue;
100772 +
100773 + // ... clobbering r10
100774 + nclobbers = gimple_asm_nclobbers(asm_stmt);
100775 + while (nclobbers--) {
100776 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
100777 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
100778 + continue;
100779 + kernexec_reload_fptr_mask(&gsi);
100780 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
100781 + break;
100782 + }
100783 + }
100784 + }
100785 +
100786 + return 0;
100787 +}
100788 +
100789 +/*
100790 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
100791 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
100792 + */
100793 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
100794 +{
100795 + gimple assign_intptr, assign_new_fptr, call_stmt;
100796 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
100797 +
100798 + call_stmt = gsi_stmt(*gsi);
100799 + old_fptr = gimple_call_fn(call_stmt);
100800 +
100801 + // create temporary unsigned long variable used for bitops and cast fptr to it
100802 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
100803 +#if BUILDING_GCC_VERSION <= 4007
100804 + add_referenced_var(intptr);
100805 +#endif
100806 + intptr = make_ssa_name(intptr, NULL);
100807 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
100808 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
100809 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
100810 + update_stmt(assign_intptr);
100811 +
100812 + // apply logical or to temporary unsigned long and bitmask
100813 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
100814 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
100815 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
100816 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
100817 + assign_intptr = gimple_build_assign(intptr, orptr);
100818 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
100819 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
100820 + update_stmt(assign_intptr);
100821 +
100822 + // cast temporary unsigned long back to a temporary fptr variable
100823 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
100824 +#if BUILDING_GCC_VERSION <= 4007
100825 + add_referenced_var(new_fptr);
100826 +#endif
100827 + new_fptr = make_ssa_name(new_fptr, NULL);
100828 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
100829 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
100830 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
100831 + update_stmt(assign_new_fptr);
100832 +
100833 + // replace call stmt fn with the new fptr
100834 + gimple_call_set_fn(call_stmt, new_fptr);
100835 + update_stmt(call_stmt);
100836 +}
100837 +
100838 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
100839 +{
100840 + gimple asm_or_stmt, call_stmt;
100841 + tree old_fptr, new_fptr, input, output;
100842 +#if BUILDING_GCC_VERSION <= 4007
100843 + VEC(tree, gc) *inputs = NULL;
100844 + VEC(tree, gc) *outputs = NULL;
100845 +#else
100846 + vec<tree, va_gc> *inputs = NULL;
100847 + vec<tree, va_gc> *outputs = NULL;
100848 +#endif
100849 +
100850 + call_stmt = gsi_stmt(*gsi);
100851 + old_fptr = gimple_call_fn(call_stmt);
100852 +
100853 + // create temporary fptr variable
100854 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
100855 +#if BUILDING_GCC_VERSION <= 4007
100856 + add_referenced_var(new_fptr);
100857 +#endif
100858 + new_fptr = make_ssa_name(new_fptr, NULL);
100859 +
100860 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
100861 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
100862 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
100863 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
100864 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
100865 +#if BUILDING_GCC_VERSION <= 4007
100866 + VEC_safe_push(tree, gc, inputs, input);
100867 + VEC_safe_push(tree, gc, outputs, output);
100868 +#else
100869 + vec_safe_push(inputs, input);
100870 + vec_safe_push(outputs, output);
100871 +#endif
100872 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
100873 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
100874 + gimple_asm_set_volatile(asm_or_stmt, true);
100875 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
100876 + update_stmt(asm_or_stmt);
100877 +
100878 + // replace call stmt fn with the new fptr
100879 + gimple_call_set_fn(call_stmt, new_fptr);
100880 + update_stmt(call_stmt);
100881 +}
100882 +
100883 +/*
100884 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
100885 + */
100886 +static unsigned int execute_kernexec_fptr(void)
100887 +{
100888 + basic_block bb;
100889 +
100890 + // 1. loop through BBs and GIMPLE statements
100891 + FOR_EACH_BB(bb) {
100892 + gimple_stmt_iterator gsi;
100893 +
100894 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100895 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
100896 + tree fn;
100897 + gimple call_stmt;
100898 +
100899 + // is it a call ...
100900 + call_stmt = gsi_stmt(gsi);
100901 + if (!is_gimple_call(call_stmt))
100902 + continue;
100903 + fn = gimple_call_fn(call_stmt);
100904 + if (TREE_CODE(fn) == ADDR_EXPR)
100905 + continue;
100906 + if (TREE_CODE(fn) != SSA_NAME)
100907 + gcc_unreachable();
100908 +
100909 + // ... through a function pointer
100910 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
100911 + fn = SSA_NAME_VAR(fn);
100912 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
100913 + debug_tree(fn);
100914 + gcc_unreachable();
100915 + }
100916 + }
100917 + fn = TREE_TYPE(fn);
100918 + if (TREE_CODE(fn) != POINTER_TYPE)
100919 + continue;
100920 + fn = TREE_TYPE(fn);
100921 + if (TREE_CODE(fn) != FUNCTION_TYPE)
100922 + continue;
100923 +
100924 + kernexec_instrument_fptr(&gsi);
100925 +
100926 +//debug_tree(gimple_call_fn(call_stmt));
100927 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
100928 + }
100929 + }
100930 +
100931 + return 0;
100932 +}
100933 +
100934 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
100935 +static void kernexec_instrument_retaddr_bts(rtx insn)
100936 +{
100937 + rtx btsq;
100938 + rtvec argvec, constraintvec, labelvec;
100939 + int line;
100940 +
100941 + // create asm volatile("btsq $63,(%%rsp)":::)
100942 + argvec = rtvec_alloc(0);
100943 + constraintvec = rtvec_alloc(0);
100944 + labelvec = rtvec_alloc(0);
100945 + line = expand_location(RTL_LOCATION(insn)).line;
100946 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
100947 + MEM_VOLATILE_P(btsq) = 1;
100948 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
100949 + emit_insn_before(btsq, insn);
100950 +}
100951 +
100952 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
100953 +static void kernexec_instrument_retaddr_or(rtx insn)
100954 +{
100955 + rtx orq;
100956 + rtvec argvec, constraintvec, labelvec;
100957 + int line;
100958 +
100959 + // create asm volatile("orq %%r10,(%%rsp)":::)
100960 + argvec = rtvec_alloc(0);
100961 + constraintvec = rtvec_alloc(0);
100962 + labelvec = rtvec_alloc(0);
100963 + line = expand_location(RTL_LOCATION(insn)).line;
100964 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
100965 + MEM_VOLATILE_P(orq) = 1;
100966 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
100967 + emit_insn_before(orq, insn);
100968 +}
100969 +
100970 +/*
100971 + * find all asm level function returns and forcibly set the highest bit of the return address
100972 + */
100973 +static unsigned int execute_kernexec_retaddr(void)
100974 +{
100975 + rtx insn;
100976 +
100977 + // 1. find function returns
100978 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
100979 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
100980 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
100981 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
100982 + rtx body;
100983 +
100984 + // is it a retn
100985 + if (!JUMP_P(insn))
100986 + continue;
100987 + body = PATTERN(insn);
100988 + if (GET_CODE(body) == PARALLEL)
100989 + body = XVECEXP(body, 0, 0);
100990 + if (!ANY_RETURN_P(body))
100991 + continue;
100992 + kernexec_instrument_retaddr(insn);
100993 + }
100994 +
100995 +// print_simple_rtl(stderr, get_insns());
100996 +// print_rtl(stderr, get_insns());
100997 +
100998 + return 0;
100999 +}
101000 +
101001 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101002 +{
101003 + const char * const plugin_name = plugin_info->base_name;
101004 + const int argc = plugin_info->argc;
101005 + const struct plugin_argument * const argv = plugin_info->argv;
101006 + int i;
101007 + struct register_pass_info kernexec_reload_pass_info = {
101008 + .pass = &kernexec_reload_pass.pass,
101009 + .reference_pass_name = "ssa",
101010 + .ref_pass_instance_number = 1,
101011 + .pos_op = PASS_POS_INSERT_AFTER
101012 + };
101013 + struct register_pass_info kernexec_fptr_pass_info = {
101014 + .pass = &kernexec_fptr_pass.pass,
101015 + .reference_pass_name = "ssa",
101016 + .ref_pass_instance_number = 1,
101017 + .pos_op = PASS_POS_INSERT_AFTER
101018 + };
101019 + struct register_pass_info kernexec_retaddr_pass_info = {
101020 + .pass = &kernexec_retaddr_pass.pass,
101021 + .reference_pass_name = "pro_and_epilogue",
101022 + .ref_pass_instance_number = 1,
101023 + .pos_op = PASS_POS_INSERT_AFTER
101024 + };
101025 +
101026 + if (!plugin_default_version_check(version, &gcc_version)) {
101027 + error(G_("incompatible gcc/plugin versions"));
101028 + return 1;
101029 + }
101030 +
101031 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101032 +
101033 + if (TARGET_64BIT == 0)
101034 + return 0;
101035 +
101036 + for (i = 0; i < argc; ++i) {
101037 + if (!strcmp(argv[i].key, "method")) {
101038 + if (!argv[i].value) {
101039 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101040 + continue;
101041 + }
101042 + if (!strcmp(argv[i].value, "bts")) {
101043 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101044 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101045 + } else if (!strcmp(argv[i].value, "or")) {
101046 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101047 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101048 + fix_register("r10", 1, 1);
101049 + } else
101050 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101051 + continue;
101052 + }
101053 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101054 + }
101055 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101056 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101057 +
101058 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101059 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101060 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101061 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101062 +
101063 + return 0;
101064 +}
101065 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101066 new file mode 100644
101067 index 0000000..2ef6fd9
101068 --- /dev/null
101069 +++ b/tools/gcc/latent_entropy_plugin.c
101070 @@ -0,0 +1,321 @@
101071 +/*
101072 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101073 + * Licensed under the GPL v2
101074 + *
101075 + * Note: the choice of the license means that the compilation process is
101076 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101077 + * but for the kernel it doesn't matter since it doesn't link against
101078 + * any of the gcc libraries
101079 + *
101080 + * gcc plugin to help generate a little bit of entropy from program state,
101081 + * used during boot in the kernel
101082 + *
101083 + * TODO:
101084 + * - add ipa pass to identify not explicitly marked candidate functions
101085 + * - mix in more program state (function arguments/return values, loop variables, etc)
101086 + * - more instrumentation control via attribute parameters
101087 + *
101088 + * BUGS:
101089 + * - LTO needs -flto-partition=none for now
101090 + */
101091 +#include "gcc-plugin.h"
101092 +#include "config.h"
101093 +#include "system.h"
101094 +#include "coretypes.h"
101095 +#include "tree.h"
101096 +#include "tree-pass.h"
101097 +#include "flags.h"
101098 +#include "intl.h"
101099 +#include "toplev.h"
101100 +#include "plugin.h"
101101 +//#include "expr.h" where are you...
101102 +#include "diagnostic.h"
101103 +#include "plugin-version.h"
101104 +#include "tm.h"
101105 +#include "function.h"
101106 +#include "basic-block.h"
101107 +#include "gimple.h"
101108 +#include "rtl.h"
101109 +#include "emit-rtl.h"
101110 +#include "tree-flow.h"
101111 +#include "langhooks.h"
101112 +
101113 +#if BUILDING_GCC_VERSION >= 4008
101114 +#define TODO_dump_func 0
101115 +#endif
101116 +
101117 +int plugin_is_GPL_compatible;
101118 +
101119 +static tree latent_entropy_decl;
101120 +
101121 +static struct plugin_info latent_entropy_plugin_info = {
101122 + .version = "201308230230",
101123 + .help = NULL
101124 +};
101125 +
101126 +static unsigned int execute_latent_entropy(void);
101127 +static bool gate_latent_entropy(void);
101128 +
101129 +static struct gimple_opt_pass latent_entropy_pass = {
101130 + .pass = {
101131 + .type = GIMPLE_PASS,
101132 + .name = "latent_entropy",
101133 +#if BUILDING_GCC_VERSION >= 4008
101134 + .optinfo_flags = OPTGROUP_NONE,
101135 +#endif
101136 + .gate = gate_latent_entropy,
101137 + .execute = execute_latent_entropy,
101138 + .sub = NULL,
101139 + .next = NULL,
101140 + .static_pass_number = 0,
101141 + .tv_id = TV_NONE,
101142 + .properties_required = PROP_gimple_leh | PROP_cfg,
101143 + .properties_provided = 0,
101144 + .properties_destroyed = 0,
101145 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101146 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101147 + }
101148 +};
101149 +
101150 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101151 +{
101152 + if (TREE_CODE(*node) != FUNCTION_DECL) {
101153 + *no_add_attrs = true;
101154 + error("%qE attribute only applies to functions", name);
101155 + }
101156 + return NULL_TREE;
101157 +}
101158 +
101159 +static struct attribute_spec latent_entropy_attr = {
101160 + .name = "latent_entropy",
101161 + .min_length = 0,
101162 + .max_length = 0,
101163 + .decl_required = true,
101164 + .type_required = false,
101165 + .function_type_required = false,
101166 + .handler = handle_latent_entropy_attribute,
101167 +#if BUILDING_GCC_VERSION >= 4007
101168 + .affects_type_identity = false
101169 +#endif
101170 +};
101171 +
101172 +static void register_attributes(void *event_data, void *data)
101173 +{
101174 + register_attribute(&latent_entropy_attr);
101175 +}
101176 +
101177 +static bool gate_latent_entropy(void)
101178 +{
101179 + tree latent_entropy_attr;
101180 +
101181 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
101182 + return latent_entropy_attr != NULL_TREE;
101183 +}
101184 +
101185 +static unsigned HOST_WIDE_INT seed;
101186 +static unsigned HOST_WIDE_INT get_random_const(void)
101187 +{
101188 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101189 + return seed;
101190 +}
101191 +
101192 +static enum tree_code get_op(tree *rhs)
101193 +{
101194 + static enum tree_code op;
101195 + unsigned HOST_WIDE_INT random_const;
101196 +
101197 + random_const = get_random_const();
101198 +
101199 + switch (op) {
101200 + case BIT_XOR_EXPR:
101201 + op = PLUS_EXPR;
101202 + break;
101203 +
101204 + case PLUS_EXPR:
101205 + if (rhs) {
101206 + op = LROTATE_EXPR;
101207 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
101208 + break;
101209 + }
101210 +
101211 + case LROTATE_EXPR:
101212 + default:
101213 + op = BIT_XOR_EXPR;
101214 + break;
101215 + }
101216 + if (rhs)
101217 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
101218 + return op;
101219 +}
101220 +
101221 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
101222 +{
101223 + gimple_stmt_iterator gsi;
101224 + gimple assign;
101225 + tree addxorrol, rhs;
101226 + enum tree_code op;
101227 +
101228 + op = get_op(&rhs);
101229 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
101230 + assign = gimple_build_assign(local_entropy, addxorrol);
101231 + gsi = gsi_after_labels(bb);
101232 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101233 + update_stmt(assign);
101234 +//debug_bb(bb);
101235 +}
101236 +
101237 +static void perturb_latent_entropy(basic_block bb, tree rhs)
101238 +{
101239 + gimple_stmt_iterator gsi;
101240 + gimple assign;
101241 + tree addxorrol, temp;
101242 +
101243 + // 1. create temporary copy of latent_entropy
101244 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
101245 +#if BUILDING_GCC_VERSION <= 4007
101246 + add_referenced_var(temp);
101247 +#endif
101248 +
101249 + // 2. read...
101250 + temp = make_ssa_name(temp, NULL);
101251 + assign = gimple_build_assign(temp, latent_entropy_decl);
101252 + SSA_NAME_DEF_STMT(temp) = assign;
101253 +#if BUILDING_GCC_VERSION <= 4007
101254 + add_referenced_var(latent_entropy_decl);
101255 +#endif
101256 + gsi = gsi_after_labels(bb);
101257 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101258 + update_stmt(assign);
101259 +
101260 + // 3. ...modify...
101261 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
101262 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
101263 + assign = gimple_build_assign(temp, addxorrol);
101264 + SSA_NAME_DEF_STMT(temp) = assign;
101265 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101266 + update_stmt(assign);
101267 +
101268 + // 4. ...write latent_entropy
101269 + assign = gimple_build_assign(latent_entropy_decl, temp);
101270 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101271 + update_stmt(assign);
101272 +}
101273 +
101274 +static unsigned int execute_latent_entropy(void)
101275 +{
101276 + basic_block bb;
101277 + gimple assign;
101278 + gimple_stmt_iterator gsi;
101279 + tree local_entropy;
101280 +
101281 + if (!latent_entropy_decl) {
101282 + struct varpool_node *node;
101283 +
101284 +#if BUILDING_GCC_VERSION <= 4007
101285 + for (node = varpool_nodes; node; node = node->next) {
101286 + tree var = node->decl;
101287 +#else
101288 + FOR_EACH_VARIABLE(node) {
101289 + tree var = node->symbol.decl;
101290 +#endif
101291 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
101292 + continue;
101293 + latent_entropy_decl = var;
101294 +// debug_tree(var);
101295 + break;
101296 + }
101297 + if (!latent_entropy_decl) {
101298 +// debug_tree(current_function_decl);
101299 + return 0;
101300 + }
101301 + }
101302 +
101303 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
101304 +
101305 + // 1. create local entropy variable
101306 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
101307 +#if BUILDING_GCC_VERSION <= 4007
101308 + add_referenced_var(local_entropy);
101309 + mark_sym_for_renaming(local_entropy);
101310 +#endif
101311 +
101312 + // 2. initialize local entropy variable
101313 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101314 + if (dom_info_available_p(CDI_DOMINATORS))
101315 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
101316 + gsi = gsi_start_bb(bb);
101317 +
101318 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
101319 +// gimple_set_location(assign, loc);
101320 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101321 + update_stmt(assign);
101322 +//debug_bb(bb);
101323 + bb = bb->next_bb;
101324 +
101325 + // 3. instrument each BB with an operation on the local entropy variable
101326 + while (bb != EXIT_BLOCK_PTR) {
101327 + perturb_local_entropy(bb, local_entropy);
101328 +//debug_bb(bb);
101329 + bb = bb->next_bb;
101330 + };
101331 +
101332 + // 4. mix local entropy into the global entropy variable
101333 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
101334 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
101335 + return 0;
101336 +}
101337 +
101338 +static void start_unit_callback(void *gcc_data, void *user_data)
101339 +{
101340 + tree latent_entropy_type;
101341 +
101342 +#if BUILDING_GCC_VERSION >= 4007
101343 + seed = get_random_seed(false);
101344 +#else
101345 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
101346 + seed *= seed;
101347 +#endif
101348 +
101349 + if (in_lto_p)
101350 + return;
101351 +
101352 + // extern volatile u64 latent_entropy
101353 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
101354 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
101355 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
101356 +
101357 + TREE_STATIC(latent_entropy_decl) = 1;
101358 + TREE_PUBLIC(latent_entropy_decl) = 1;
101359 + TREE_USED(latent_entropy_decl) = 1;
101360 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
101361 + DECL_EXTERNAL(latent_entropy_decl) = 1;
101362 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
101363 + DECL_INITIAL(latent_entropy_decl) = NULL;
101364 + lang_hooks.decls.pushdecl(latent_entropy_decl);
101365 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
101366 +// varpool_finalize_decl(latent_entropy_decl);
101367 +// varpool_mark_needed_node(latent_entropy_decl);
101368 +}
101369 +
101370 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101371 +{
101372 + const char * const plugin_name = plugin_info->base_name;
101373 + struct register_pass_info latent_entropy_pass_info = {
101374 + .pass = &latent_entropy_pass.pass,
101375 + .reference_pass_name = "optimized",
101376 + .ref_pass_instance_number = 1,
101377 + .pos_op = PASS_POS_INSERT_BEFORE
101378 + };
101379 +
101380 + if (!plugin_default_version_check(version, &gcc_version)) {
101381 + error(G_("incompatible gcc/plugin versions"));
101382 + return 1;
101383 + }
101384 +
101385 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
101386 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101387 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
101388 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101389 +
101390 + return 0;
101391 +}
101392 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
101393 new file mode 100644
101394 index 0000000..b04803b
101395 --- /dev/null
101396 +++ b/tools/gcc/size_overflow_hash.data
101397 @@ -0,0 +1,6350 @@
101398 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
101399 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
101400 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
101401 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
101402 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
101403 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
101404 +padzero_55 padzero 1 55 &sel_read_policyvers_55
101405 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
101406 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
101407 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
101408 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
101409 +load_msg_95 load_msg 2 95 NULL
101410 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
101411 +init_q_132 init_q 4 132 NULL
101412 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
101413 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
101414 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
101415 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
101416 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
101417 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
101418 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
101419 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
101420 +br_port_info_size_268 br_port_info_size 0 268 NULL
101421 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
101422 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
101423 +SYSC_connect_304 SYSC_connect 3 304 NULL
101424 +syslog_print_307 syslog_print 2 307 NULL
101425 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
101426 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
101427 +next_node_allowed_318 next_node_allowed 1 318 NULL
101428 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
101429 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
101430 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
101431 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
101432 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
101433 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
101434 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
101435 +pidlist_resize_496 pidlist_resize 2 496 NULL
101436 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
101437 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
101438 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
101439 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
101440 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
101441 +dle_count_543 dle_count 0 543 NULL
101442 +devres_alloc_551 devres_alloc 2 551 NULL
101443 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
101444 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
101445 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
101446 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
101447 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
101448 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
101449 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
101450 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
101451 +isp1760_register_628 isp1760_register 1-2 628 NULL
101452 +clone_split_bio_633 clone_split_bio 6 633 NULL
101453 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
101454 +remap_to_cache_640 remap_to_cache 3 640 NULL
101455 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
101456 +unlink_queued_645 unlink_queued 3-4 645 NULL
101457 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
101458 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
101459 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
101460 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
101461 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
101462 +disk_max_parts_719 disk_max_parts 0 719 NULL
101463 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
101464 +dvb_video_write_754 dvb_video_write 3 754 NULL
101465 +if_writecmd_815 if_writecmd 2 815 NULL
101466 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
101467 +read_fifo_826 read_fifo 3 826 NULL
101468 +um_idi_read_850 um_idi_read 3 850 NULL
101469 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
101470 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
101471 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
101472 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
101473 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
101474 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
101475 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
101476 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
101477 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
101478 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
101479 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
101480 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
101481 +_do_truncate_1019 _do_truncate 2 1019 NULL
101482 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
101483 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
101484 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
101485 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
101486 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
101487 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
101488 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
101489 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
101490 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
101491 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
101492 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
101493 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
101494 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
101495 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
101496 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
101497 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
101498 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
101499 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
101500 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
101501 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
101502 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
101503 +nested_get_page_1252 nested_get_page 2 1252 NULL
101504 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
101505 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
101506 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
101507 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
101508 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
101509 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
101510 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
101511 +ffs_1322 ffs 0 1322 NULL
101512 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
101513 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
101514 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
101515 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
101516 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
101517 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
101518 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
101519 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
101520 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
101521 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
101522 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
101523 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
101524 +zone_page_state_1393 zone_page_state 0 1393 NULL
101525 +file_read_actor_1401 file_read_actor 4 1401 NULL
101526 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
101527 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
101528 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
101529 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
101530 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
101531 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
101532 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
101533 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
101534 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
101535 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
101536 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
101537 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
101538 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
101539 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
101540 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
101541 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
101542 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
101543 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
101544 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
101545 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
101546 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
101547 +rmap_add_1677 rmap_add 3 1677 NULL
101548 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
101549 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
101550 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
101551 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
101552 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
101553 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
101554 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
101555 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
101556 +cosa_write_1774 cosa_write 3 1774 NULL
101557 +update_macheader_1775 update_macheader 7 1775 NULL
101558 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
101559 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
101560 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
101561 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
101562 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
101563 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
101564 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
101565 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
101566 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
101567 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
101568 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
101569 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
101570 +read_swap_header_1957 read_swap_header 0 1957 NULL
101571 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
101572 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
101573 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
101574 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
101575 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
101576 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
101577 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
101578 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
101579 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
101580 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
101581 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
101582 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
101583 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
101584 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
101585 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
101586 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
101587 +audit_expand_2098 audit_expand 2 2098 NULL
101588 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
101589 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
101590 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
101591 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
101592 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
101593 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
101594 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
101595 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
101596 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
101597 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
101598 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
101599 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
101600 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
101601 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
101602 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
101603 +vhci_write_2224 vhci_write 3 2224 NULL
101604 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
101605 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
101606 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
101607 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
101608 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
101609 +do_update_counters_2259 do_update_counters 4 2259 NULL
101610 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
101611 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
101612 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
101613 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
101614 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
101615 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
101616 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
101617 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
101618 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
101619 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
101620 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
101621 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
101622 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
101623 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
101624 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
101625 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
101626 +raid1_size_2419 raid1_size 0-2 2419 NULL
101627 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
101628 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
101629 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
101630 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
101631 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
101632 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
101633 +update_pmkid_2481 update_pmkid 4 2481 NULL
101634 +wiphy_new_2482 wiphy_new 2 2482 NULL
101635 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
101636 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
101637 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
101638 +dm_write_2513 dm_write 3 2513 NULL
101639 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
101640 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
101641 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
101642 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
101643 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
101644 +slot_bytes_2609 slot_bytes 0 2609 NULL
101645 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
101646 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
101647 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
101648 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
101649 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
101650 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
101651 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
101652 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
101653 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
101654 +__next_cpu_2782 __next_cpu 1 2782 NULL
101655 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
101656 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
101657 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
101658 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
101659 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
101660 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
101661 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
101662 +mq_map_2871 mq_map 2 2871 NULL
101663 +nla_padlen_2883 nla_padlen 1 2883 NULL
101664 +cmm_write_2896 cmm_write 3 2896 NULL
101665 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
101666 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
101667 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
101668 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
101669 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
101670 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
101671 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
101672 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
101673 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
101674 +depth_write_3021 depth_write 3 3021 NULL
101675 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
101676 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
101677 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
101678 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
101679 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
101680 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
101681 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
101682 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
101683 +free_coherent_3082 free_coherent 4-2 3082 NULL
101684 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
101685 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
101686 +rb_alloc_3102 rb_alloc 1 3102 NULL
101687 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
101688 +print_time_3132 print_time 0 3132 NULL
101689 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
101690 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
101691 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
101692 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
101693 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
101694 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
101695 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
101696 +alloc_context_3194 alloc_context 1 3194 NULL
101697 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
101698 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
101699 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
101700 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
101701 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
101702 +key_key_read_3241 key_key_read 3 3241 NULL
101703 +number_3243 number 0 3243 NULL
101704 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
101705 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
101706 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
101707 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
101708 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
101709 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
101710 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
101711 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
101712 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
101713 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
101714 +scnprintf_3360 scnprintf 0-2 3360 NULL
101715 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
101716 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
101717 +send_stream_3397 send_stream 4 3397 NULL
101718 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
101719 +msix_map_region_3411 msix_map_region 3 3411 NULL
101720 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
101721 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
101722 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
101723 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
101724 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
101725 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
101726 +map_single_3449 map_single 0-2 3449 NULL
101727 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
101728 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
101729 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
101730 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
101731 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
101732 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
101733 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
101734 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
101735 +SyS_readv_3539 SyS_readv 3 3539 NULL
101736 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
101737 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
101738 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
101739 +evtchn_read_3569 evtchn_read 3 3569 NULL
101740 +vc_resize_3585 vc_resize 2-3 3585 NULL
101741 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
101742 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
101743 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
101744 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
101745 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
101746 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
101747 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
101748 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
101749 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
101750 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
101751 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
101752 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
101753 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
101754 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
101755 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
101756 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
101757 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
101758 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
101759 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
101760 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
101761 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
101762 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
101763 +get_fd_set_3866 get_fd_set 1 3866 NULL
101764 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
101765 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
101766 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
101767 +nvram_write_3894 nvram_write 3 3894 NULL
101768 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
101769 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
101770 +vcs_write_3910 vcs_write 3 3910 NULL
101771 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
101772 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
101773 +do_add_counters_3992 do_add_counters 3 3992 NULL
101774 +userspace_status_4004 userspace_status 4 4004 NULL
101775 +mei_write_4005 mei_write 3 4005 NULL nohasharray
101776 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
101777 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
101778 +mm_populate_4016 mm_populate 1 4016 NULL
101779 +blk_end_request_4024 blk_end_request 3 4024 NULL
101780 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
101781 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
101782 +read_file_queues_4078 read_file_queues 3 4078 NULL
101783 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
101784 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
101785 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
101786 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
101787 +tm6000_read_4151 tm6000_read 3 4151 NULL
101788 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
101789 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
101790 +get_alua_req_4166 get_alua_req 3 4166 NULL
101791 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
101792 +read_file_bool_4180 read_file_bool 3 4180 NULL
101793 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
101794 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
101795 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
101796 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
101797 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
101798 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
101799 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
101800 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
101801 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
101802 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
101803 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
101804 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
101805 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
101806 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
101807 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
101808 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
101809 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
101810 +memparse_4444 memparse 0 4444 NULL
101811 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
101812 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
101813 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
101814 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
101815 +set_link_security_4502 set_link_security 4 4502 NULL
101816 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
101817 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
101818 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
101819 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
101820 +tty_register_device_4544 tty_register_device 2 4544 NULL
101821 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
101822 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
101823 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
101824 +bch_alloc_4593 bch_alloc 1 4593 NULL
101825 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
101826 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
101827 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
101828 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
101829 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
101830 +kone_receive_4690 kone_receive 4 4690 NULL
101831 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
101832 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
101833 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
101834 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
101835 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
101836 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
101837 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
101838 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
101839 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
101840 +create_subvol_4791 create_subvol 4 4791 NULL
101841 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
101842 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
101843 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
101844 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
101845 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
101846 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
101847 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
101848 +sys_ipc_4889 sys_ipc 3 4889 NULL
101849 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
101850 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
101851 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
101852 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
101853 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
101854 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
101855 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
101856 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
101857 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
101858 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
101859 +do_mincore_5018 do_mincore 0-1 5018 NULL
101860 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
101861 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
101862 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
101863 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
101864 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
101865 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
101866 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
101867 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
101868 +sound_write_5102 sound_write 3 5102 NULL
101869 +clear_dirty_5105 clear_dirty 3 5105 NULL
101870 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
101871 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
101872 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
101873 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
101874 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
101875 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
101876 +skb_network_header_5203 skb_network_header 0 5203 NULL
101877 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
101878 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
101879 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
101880 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
101881 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
101882 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
101883 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
101884 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
101885 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
101886 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
101887 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
101888 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
101889 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
101890 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
101891 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
101892 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
101893 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
101894 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
101895 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
101896 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
101897 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
101898 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
101899 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
101900 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
101901 +tty_write_5494 tty_write 3 5494 NULL
101902 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
101903 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
101904 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
101905 +spidev_message_5518 spidev_message 3 5518 NULL
101906 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
101907 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
101908 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
101909 +le_readq_5557 le_readq 0 5557 NULL
101910 +inw_5558 inw 0 5558 NULL
101911 +fir16_create_5574 fir16_create 3 5574 NULL
101912 +bioset_create_5580 bioset_create 1 5580 NULL
101913 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
101914 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
101915 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
101916 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
101917 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
101918 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
101919 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
101920 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
101921 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
101922 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
101923 +get_arg_5694 get_arg 3 5694 NULL
101924 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
101925 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
101926 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
101927 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
101928 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
101929 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
101930 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
101931 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
101932 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
101933 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
101934 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
101935 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
101936 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
101937 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
101938 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
101939 +setup_req_5848 setup_req 3 5848 NULL
101940 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
101941 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
101942 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
101943 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
101944 +port_show_regs_5904 port_show_regs 3 5904 NULL
101945 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
101946 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
101947 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
101948 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
101949 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
101950 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
101951 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
101952 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
101953 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
101954 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
101955 +native_pte_val_5978 native_pte_val 0 5978 NULL
101956 +SyS_semop_5980 SyS_semop 3 5980 NULL
101957 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
101958 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
101959 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
101960 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
101961 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
101962 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
101963 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
101964 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
101965 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
101966 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
101967 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
101968 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
101969 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
101970 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
101971 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
101972 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
101973 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
101974 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
101975 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
101976 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
101977 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
101978 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
101979 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
101980 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
101981 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
101982 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
101983 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
101984 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
101985 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
101986 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
101987 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
101988 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
101989 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
101990 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
101991 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
101992 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
101993 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
101994 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
101995 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
101996 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
101997 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
101998 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
101999 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102000 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102001 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102002 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102003 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102004 +mei_read_6507 mei_read 3 6507 NULL
102005 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102006 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102007 +wdm_read_6549 wdm_read 3 6549 NULL
102008 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102009 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102010 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102011 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102012 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102013 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102014 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102015 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102016 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102017 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102018 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102019 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102020 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102021 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102022 +mpeg_read_6708 mpeg_read 3 6708 NULL
102023 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102024 +video_proc_write_6724 video_proc_write 3 6724 NULL
102025 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102026 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102027 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102028 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102029 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102030 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102031 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102032 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102033 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102034 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102035 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102036 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102037 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102038 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102039 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102040 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102041 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102042 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102043 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102044 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102045 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102046 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102047 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102048 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102049 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102050 +request_key_async_6990 request_key_async 4 6990 NULL
102051 +tpl_write_6998 tpl_write 3 6998 NULL
102052 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102053 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102054 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102055 +wimax_msg_7030 wimax_msg 4 7030 NULL
102056 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102057 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102058 +event_enable_read_7074 event_enable_read 3 7074 NULL
102059 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102060 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102061 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102062 +check_header_7108 check_header 0 7108 NULL
102063 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102064 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102065 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102066 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102067 +get_param_h_7247 get_param_h 0 7247 NULL
102068 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102069 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102070 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102071 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102072 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102073 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102074 +mgmt_control_7349 mgmt_control 3 7349 NULL
102075 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102076 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102077 +hweight_long_7388 hweight_long 0-1 7388 NULL
102078 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102079 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102080 +readb_7401 readb 0 7401 NULL
102081 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102082 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102083 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102084 +numa_emulation_7466 numa_emulation 2 7466 NULL
102085 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102086 +garp_request_join_7471 garp_request_join 4 7471 NULL
102087 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102088 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102089 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102090 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102091 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102092 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102093 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102094 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102095 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102096 +groups_alloc_7614 groups_alloc 1 7614 NULL
102097 +sg_virt_7616 sg_virt 0 7616 NULL
102098 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102099 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102100 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
102101 +dev_write_7708 dev_write 3 7708 NULL
102102 +unmap_region_7709 unmap_region 1 7709 NULL
102103 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
102104 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
102105 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
102106 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
102107 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
102108 +ioread32be_7773 ioread32be 0 7773 NULL
102109 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
102110 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
102111 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
102112 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
102113 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
102114 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
102115 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
102116 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
102117 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
102118 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
102119 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
102120 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
102121 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
102122 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
102123 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
102124 +sys_mbind_7990 sys_mbind 5 7990 NULL
102125 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
102126 +vcs_read_8017 vcs_read 3 8017 NULL
102127 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
102128 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
102129 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
102130 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
102131 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
102132 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
102133 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
102134 +venus_lookup_8121 venus_lookup 4 8121 NULL
102135 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
102136 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
102137 +ore_truncate_8181 ore_truncate 3 8181 NULL
102138 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
102139 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
102140 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
102141 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
102142 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
102143 +play_iframe_8219 play_iframe 3 8219 NULL
102144 +create_log_8225 create_log 2 8225 NULL nohasharray
102145 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
102146 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
102147 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
102148 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
102149 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
102150 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
102151 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
102152 +init_cdev_8274 init_cdev 1 8274 NULL
102153 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
102154 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
102155 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
102156 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
102157 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
102158 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
102159 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
102160 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
102161 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
102162 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
102163 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
102164 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
102165 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
102166 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
102167 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
102168 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
102169 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
102170 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
102171 +dev_config_8506 dev_config 3 8506 NULL
102172 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
102173 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
102174 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
102175 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
102176 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
102177 +user_on_off_8552 user_on_off 2 8552 NULL
102178 +profile_remove_8556 profile_remove 3 8556 NULL
102179 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
102180 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
102181 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
102182 +tower_write_8580 tower_write 3 8580 NULL
102183 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
102184 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
102185 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
102186 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
102187 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
102188 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
102189 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
102190 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
102191 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
102192 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
102193 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
102194 +arcfb_write_8702 arcfb_write 3 8702 NULL
102195 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
102196 +init_header_8703 init_header 0 8703 &i_size_read_8703
102197 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
102198 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
102199 +f_dupfd_8730 f_dupfd 1 8730 NULL
102200 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
102201 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
102202 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
102203 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
102204 +sys_prctl_8766 sys_prctl 4 8766 NULL
102205 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
102206 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
102207 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
102208 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
102209 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
102210 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
102211 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
102212 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
102213 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
102214 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
102215 +clear_bitset_8840 clear_bitset 2 8840 NULL
102216 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
102217 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
102218 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
102219 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
102220 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
102221 +layout_commit_8926 layout_commit 3 8926 NULL
102222 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
102223 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
102224 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
102225 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
102226 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
102227 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
102228 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
102229 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
102230 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
102231 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
102232 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
102233 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
102234 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
102235 +nla_put_9042 nla_put 3 9042 NULL
102236 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
102237 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
102238 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
102239 +string_9080 string 0 9080 NULL
102240 +create_queues_9088 create_queues 2-3 9088 NULL
102241 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
102242 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
102243 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
102244 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
102245 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
102246 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
102247 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
102248 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
102249 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
102250 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
102251 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
102252 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
102253 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
102254 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
102255 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
102256 +get_pfn_9207 get_pfn 1 9207 NULL
102257 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
102258 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
102259 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
102260 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
102261 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
102262 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
102263 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
102264 +flakey_status_9274 flakey_status 5 9274 NULL
102265 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
102266 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
102267 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
102268 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
102269 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
102270 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
102271 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
102272 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
102273 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
102274 +read_9397 read 3 9397 NULL
102275 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
102276 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
102277 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
102278 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
102279 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
102280 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
102281 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
102282 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
102283 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
102284 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
102285 +lp_write_9511 lp_write 3 9511 NULL
102286 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
102287 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
102288 +read_file_dma_9530 read_file_dma 3 9530 NULL
102289 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
102290 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
102291 +fw_node_create_9559 fw_node_create 2 9559 NULL
102292 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
102293 +kobj_map_9566 kobj_map 2-3 9566 NULL
102294 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
102295 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
102296 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
102297 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
102298 +do_sync_9604 do_sync 1 9604 NULL
102299 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
102300 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
102301 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
102302 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
102303 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
102304 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
102305 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
102306 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
102307 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
102308 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
102309 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
102310 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
102311 +is_hole_9694 is_hole 2 9694 NULL nohasharray
102312 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
102313 +fnb_9703 fnb 2-3 9703 NULL
102314 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
102315 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
102316 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
102317 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
102318 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
102319 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
102320 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
102321 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
102322 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
102323 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
102324 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
102325 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
102326 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
102327 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
102328 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
102329 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
102330 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
102331 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
102332 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
102333 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
102334 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
102335 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
102336 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
102337 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
102338 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
102339 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
102340 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
102341 +read_file_misc_9948 read_file_misc 3 9948 NULL
102342 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
102343 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
102344 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
102345 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
102346 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
102347 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
102348 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
102349 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
102350 +handle_request_10024 handle_request 9 10024 NULL
102351 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
102352 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
102353 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
102354 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
102355 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
102356 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
102357 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
102358 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
102359 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
102360 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
102361 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
102362 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
102363 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
102364 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
102365 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
102366 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
102367 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
102368 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
102369 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
102370 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
102371 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
102372 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
102373 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
102374 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
102375 +read_emulate_10310 read_emulate 2-4 10310 NULL
102376 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
102377 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
102378 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
102379 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
102380 +get_dump_page_10338 get_dump_page 1 10338 NULL
102381 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
102382 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
102383 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
102384 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
102385 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
102386 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
102387 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
102388 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
102389 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
102390 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
102391 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
102392 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
102393 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
102394 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
102395 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
102396 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
102397 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
102398 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
102399 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
102400 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
102401 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
102402 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
102403 +otp_read_10594 otp_read 2-4-5 10594 NULL
102404 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
102405 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
102406 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
102407 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
102408 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
102409 +parport_write_10669 parport_write 0 10669 NULL
102410 +inl_10708 inl 0 10708 NULL nohasharray
102411 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
102412 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
102413 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
102414 +spi_sync_10731 spi_sync 0 10731 NULL
102415 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
102416 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
102417 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
102418 +sys_syslog_10746 sys_syslog 3 10746 NULL
102419 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
102420 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
102421 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
102422 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
102423 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
102424 +sys_bind_10799 sys_bind 3 10799 NULL
102425 +compat_put_int_10828 compat_put_int 1 10828 NULL
102426 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
102427 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
102428 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
102429 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
102430 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
102431 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
102432 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
102433 +get_scq_10897 get_scq 2 10897 NULL
102434 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
102435 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
102436 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
102437 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
102438 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
102439 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
102440 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
102441 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
102442 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
102443 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
102444 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
102445 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
102446 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
102447 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
102448 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
102449 +count_argc_11083 count_argc 0 11083 NULL
102450 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
102451 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
102452 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
102453 +page_offset_11120 page_offset 0 11120 NULL
102454 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
102455 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
102456 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
102457 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
102458 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
102459 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
102460 +__swab16p_11220 __swab16p 0 11220 NULL
102461 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
102462 +mmap_region_11247 mmap_region 0-2 11247 NULL
102463 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
102464 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
102465 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
102466 +cru_detect_11272 cru_detect 1 11272 NULL
102467 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
102468 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
102469 +construct_key_11329 construct_key 3 11329 NULL nohasharray
102470 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
102471 +next_segment_11330 next_segment 0-2-1 11330 NULL
102472 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
102473 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
102474 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
102475 +sel_write_create_11353 sel_write_create 3 11353 NULL
102476 +handle_unit_11355 handle_unit 0-1 11355 NULL
102477 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
102478 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
102479 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
102480 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
102481 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
102482 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
102483 +str_to_user_11411 str_to_user 2 11411 NULL
102484 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
102485 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
102486 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
102487 +trace_options_read_11419 trace_options_read 3 11419 NULL
102488 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
102489 +prepare_image_11424 prepare_image 0 11424 NULL
102490 +vring_size_11426 vring_size 0-1-2 11426 NULL
102491 +bttv_read_11432 bttv_read 3 11432 NULL
102492 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
102493 +swp_offset_11475 swp_offset 0 11475 NULL
102494 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
102495 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
102496 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
102497 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
102498 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
102499 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
102500 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
102501 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
102502 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
102503 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
102504 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
102505 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
102506 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
102507 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
102508 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
102509 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
102510 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
102511 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
102512 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
102513 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
102514 +split_11691 split 2 11691 NULL
102515 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
102516 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
102517 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
102518 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
102519 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
102520 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
102521 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
102522 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
102523 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
102524 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
102525 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
102526 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
102527 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
102528 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
102529 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
102530 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
102531 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
102532 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
102533 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
102534 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
102535 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
102536 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
102537 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
102538 +atmel_read16_11981 atmel_read16 0 11981 NULL
102539 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
102540 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
102541 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
102542 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
102543 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
102544 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
102545 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
102546 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
102547 +set_powered_12129 set_powered 4 12129 NULL
102548 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
102549 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
102550 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
102551 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
102552 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
102553 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
102554 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
102555 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
102556 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
102557 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
102558 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
102559 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
102560 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
102561 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
102562 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
102563 +scaled_div_12201 scaled_div 1-2 12201 NULL
102564 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
102565 +receive_copy_12216 receive_copy 3 12216 NULL
102566 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
102567 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
102568 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
102569 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
102570 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
102571 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
102572 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
102573 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
102574 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
102575 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
102576 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
102577 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
102578 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
102579 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
102580 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
102581 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
102582 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
102583 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
102584 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
102585 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
102586 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
102587 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
102588 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
102589 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
102590 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
102591 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
102592 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
102593 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
102594 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
102595 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
102596 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
102597 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
102598 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
102599 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
102600 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
102601 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
102602 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
102603 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
102604 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
102605 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
102606 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
102607 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
102608 +wb_create_12651 wb_create 1 12651 NULL
102609 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
102610 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
102611 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
102612 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
102613 +ivtv_write_12721 ivtv_write 3 12721 NULL
102614 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
102615 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
102616 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
102617 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
102618 +listxattr_12769 listxattr 3 12769 NULL
102619 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
102620 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
102621 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
102622 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
102623 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
102624 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
102625 +readq_12825 readq 0 12825 NULL
102626 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
102627 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
102628 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
102629 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
102630 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
102631 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
102632 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
102633 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
102634 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
102635 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
102636 +bm_status_write_12964 bm_status_write 3 12964 NULL
102637 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
102638 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
102639 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
102640 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
102641 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
102642 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
102643 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
102644 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
102645 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
102646 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
102647 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
102648 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
102649 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
102650 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
102651 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
102652 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
102653 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
102654 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
102655 +blk_update_request_13146 blk_update_request 3 13146 NULL
102656 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
102657 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
102658 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
102659 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
102660 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
102661 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
102662 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
102663 +comedi_read_13199 comedi_read 3 13199 NULL
102664 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
102665 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
102666 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
102667 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
102668 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
102669 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
102670 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
102671 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
102672 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
102673 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
102674 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
102675 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
102676 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
102677 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
102678 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
102679 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
102680 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
102681 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
102682 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
102683 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
102684 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
102685 +cache_ctr_13364 cache_ctr 2 13364 NULL
102686 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
102687 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
102688 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
102689 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
102690 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
102691 +sky2_receive_13407 sky2_receive 2 13407 NULL
102692 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
102693 +keyring_read_13438 keyring_read 3 13438 NULL
102694 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
102695 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
102696 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
102697 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
102698 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
102699 +core_status_13515 core_status 4 13515 NULL
102700 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
102701 +bm_init_13529 bm_init 2 13529 NULL
102702 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
102703 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
102704 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
102705 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
102706 +sys_madvise_13569 sys_madvise 1 13569 NULL
102707 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
102708 +cache_write_13589 cache_write 3 13589 NULL
102709 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
102710 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
102711 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
102712 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
102713 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
102714 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
102715 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
102716 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
102717 +packet_snd_13634 packet_snd 3 13634 NULL
102718 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
102719 +cache_downcall_13666 cache_downcall 3 13666 NULL
102720 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
102721 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
102722 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
102723 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
102724 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
102725 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
102726 +random_read_13815 random_read 3 13815 NULL
102727 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
102728 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
102729 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
102730 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
102731 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
102732 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
102733 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
102734 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
102735 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
102736 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
102737 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
102738 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
102739 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
102740 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
102741 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
102742 +com90xx_found_13974 com90xx_found 3 13974 NULL
102743 +qcam_read_13977 qcam_read 3 13977 NULL
102744 +dsp_read_13980 dsp_read 2 13980 NULL
102745 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
102746 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
102747 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
102748 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
102749 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
102750 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
102751 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
102752 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
102753 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
102754 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
102755 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
102756 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
102757 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
102758 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
102759 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
102760 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
102761 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
102762 +em_canid_change_14150 em_canid_change 3 14150 NULL
102763 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
102764 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
102765 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
102766 +alloc_async_14208 alloc_async 1 14208 NULL
102767 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
102768 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
102769 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
102770 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
102771 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
102772 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
102773 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
102774 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
102775 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
102776 +rr_status_14293 rr_status 5 14293 NULL
102777 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
102778 +oo_objects_14319 oo_objects 0 14319 NULL
102779 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
102780 +scsi2int_14358 scsi2int 0 14358 NULL
102781 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
102782 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
102783 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
102784 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
102785 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
102786 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
102787 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
102788 +block_size_14443 block_size 0 14443 NULL
102789 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
102790 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
102791 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
102792 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
102793 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
102794 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
102795 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
102796 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
102797 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
102798 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
102799 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
102800 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
102801 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
102802 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
102803 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
102804 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
102805 +dbJoin_14644 dbJoin 0 14644 NULL
102806 +profile_replace_14652 profile_replace 3 14652 NULL
102807 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
102808 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
102809 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
102810 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
102811 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
102812 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
102813 +get_bio_block_14714 get_bio_block 0 14714 NULL
102814 +vfd_write_14717 vfd_write 3 14717 NULL
102815 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
102816 +raid1_resize_14740 raid1_resize 2 14740 NULL
102817 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
102818 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
102819 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
102820 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
102821 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
102822 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
102823 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
102824 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
102825 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
102826 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
102827 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
102828 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
102829 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
102830 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
102831 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
102832 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
102833 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
102834 +unifi_read_14899 unifi_read 3 14899 NULL
102835 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
102836 +krealloc_14908 krealloc 2 14908 NULL
102837 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
102838 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
102839 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
102840 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
102841 +queue_cnt_14951 queue_cnt 0 14951 NULL
102842 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
102843 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
102844 +setkey_14987 setkey 3 14987 NULL nohasharray
102845 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
102846 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
102847 +vmap_15025 vmap 2 15025 NULL
102848 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
102849 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
102850 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
102851 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
102852 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
102853 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
102854 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
102855 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
102856 +start_port_15124 start_port 0 15124 NULL
102857 +memchr_15126 memchr 0 15126 NULL
102858 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
102859 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
102860 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
102861 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
102862 +reserve_resources_15194 reserve_resources 3 15194 NULL
102863 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
102864 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
102865 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
102866 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
102867 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
102868 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
102869 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
102870 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
102871 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
102872 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
102873 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
102874 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
102875 +ioread16_15342 ioread16 0 15342 NULL
102876 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
102877 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
102878 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
102879 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
102880 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
102881 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
102882 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
102883 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
102884 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
102885 +get_modalias_15406 get_modalias 2 15406 NULL
102886 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
102887 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
102888 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
102889 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
102890 +memweight_15450 memweight 2 15450 NULL
102891 +vmalloc_15464 vmalloc 1 15464 NULL
102892 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
102893 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
102894 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
102895 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
102896 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
102897 +persistent_status_15574 persistent_status 4 15574 NULL
102898 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
102899 +vme_user_write_15587 vme_user_write 3 15587 NULL
102900 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
102901 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
102902 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
102903 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
102904 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
102905 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
102906 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
102907 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
102908 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
102909 +fs_path_add_15648 fs_path_add 3 15648 NULL
102910 +xsd_read_15653 xsd_read 3 15653 NULL
102911 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
102912 +unix_bind_15668 unix_bind 3 15668 NULL
102913 +dm_read_15674 dm_read 3 15674 NULL
102914 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
102915 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
102916 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
102917 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
102918 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
102919 +do_test_15766 do_test 1 15766 NULL
102920 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
102921 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
102922 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
102923 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
102924 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
102925 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
102926 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
102927 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
102928 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
102929 +table_size_15851 table_size 0-1-2 15851 NULL
102930 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
102931 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
102932 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
102933 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
102934 +native_read_msr_15905 native_read_msr 0 15905 NULL
102935 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
102936 +power_read_15939 power_read 3 15939 NULL
102937 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
102938 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
102939 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
102940 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
102941 +frame_alloc_15981 frame_alloc 4 15981 NULL
102942 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
102943 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
102944 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
102945 +got_frame_16028 got_frame 2 16028 NULL
102946 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
102947 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
102948 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
102949 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
102950 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
102951 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
102952 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
102953 +fsm_init_16134 fsm_init 2 16134 NULL
102954 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
102955 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
102956 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
102957 +mapping_level_16188 mapping_level 2 16188 NULL
102958 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
102959 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
102960 +create_table_16213 create_table 2 16213 NULL
102961 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
102962 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
102963 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
102964 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
102965 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
102966 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
102967 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
102968 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
102969 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
102970 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
102971 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
102972 +account_16283 account 0-2-4 16283 NULL nohasharray
102973 +mirror_status_16283 mirror_status 5 16283 &account_16283
102974 +retry_instruction_16285 retry_instruction 2 16285 NULL
102975 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
102976 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
102977 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
102978 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
102979 +wb_map_16301 wb_map 2 16301 NULL
102980 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
102981 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
102982 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
102983 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
102984 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
102985 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
102986 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
102987 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
102988 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
102989 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
102990 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
102991 +raid10_resize_16537 raid10_resize 2 16537 NULL
102992 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
102993 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
102994 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
102995 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
102996 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
102997 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
102998 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
102999 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103000 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103001 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103002 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103003 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103004 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103005 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103006 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103007 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103008 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103009 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103010 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103011 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103012 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103013 +st_write_16874 st_write 3 16874 NULL
103014 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103015 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103016 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103017 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103018 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103019 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103020 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103021 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103022 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103023 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103024 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103025 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103026 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103027 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103028 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103029 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103030 +mac_address_string_17091 mac_address_string 0 17091 NULL
103031 +entry_length_17093 entry_length 0 17093 NULL
103032 +sys_preadv_17100 sys_preadv 3 17100 NULL
103033 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103034 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103035 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103036 +sep_read_17161 sep_read 3 17161 NULL
103037 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103038 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103039 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103040 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103041 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103042 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103043 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103044 +to_oblock_17254 to_oblock 0-1 17254 NULL
103045 +unpack_value_17259 unpack_value 1 17259 NULL
103046 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103047 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103048 +alloc_ep_17269 alloc_ep 1 17269 NULL
103049 +pg_read_17276 pg_read 3 17276 NULL
103050 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103051 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103052 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103053 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103054 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103055 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103056 +skb_pad_17302 skb_pad 2 17302 NULL
103057 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103058 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103059 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103060 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103061 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103062 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103063 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103064 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103065 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103066 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103067 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103068 +compat_cmd_17465 compat_cmd 2 17465 NULL
103069 +probe_bios_17467 probe_bios 1 17467 NULL
103070 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103071 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103072 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103073 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103074 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103075 +copy_from_user_17559 copy_from_user 3 17559 NULL
103076 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103077 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103078 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103079 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103080 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103081 +osst_execute_17607 osst_execute 7-6 17607 NULL
103082 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103083 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103084 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103085 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103086 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103087 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103088 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103089 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103090 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103091 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103092 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103093 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103094 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103095 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103096 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103097 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103098 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103099 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103100 +perf_clock_17787 perf_clock 0 17787 NULL
103101 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
103102 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
103103 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
103104 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
103105 +count_leafs_17842 count_leafs 0 17842 NULL
103106 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
103107 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
103108 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
103109 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
103110 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
103111 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
103112 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
103113 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
103114 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
103115 +recover_head_17904 recover_head 3 17904 NULL
103116 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
103117 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
103118 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
103119 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
103120 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
103121 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
103122 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
103123 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
103124 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
103125 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
103126 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
103127 +fill_read_18019 fill_read 0 18019 NULL
103128 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
103129 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
103130 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
103131 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
103132 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
103133 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
103134 +packet_came_18072 packet_came 3 18072 NULL
103135 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
103136 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
103137 +get_vm_area_18080 get_vm_area 1 18080 NULL
103138 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
103139 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
103140 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
103141 +svc_getnl_18120 svc_getnl 0 18120 NULL
103142 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
103143 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
103144 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
103145 +_has_tag_18169 _has_tag 2 18169 NULL
103146 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
103147 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
103148 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
103149 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
103150 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
103151 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
103152 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
103153 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
103154 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
103155 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
103156 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
103157 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
103158 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
103159 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
103160 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
103161 +um_idi_write_18293 um_idi_write 3 18293 NULL
103162 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
103163 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
103164 +vga_r_18310 vga_r 0 18310 NULL
103165 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
103166 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
103167 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
103168 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
103169 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
103170 +ep_io_18367 ep_io 0 18367 NULL
103171 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
103172 +ci_role_write_18388 ci_role_write 3 18388 NULL
103173 +__video_register_device_18399 __video_register_device 3 18399 NULL
103174 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
103175 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
103176 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
103177 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
103178 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
103179 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
103180 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
103181 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
103182 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
103183 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
103184 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
103185 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
103186 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
103187 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
103188 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
103189 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
103190 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
103191 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
103192 +debug_output_18575 debug_output 3 18575 NULL
103193 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
103194 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
103195 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
103196 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
103197 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
103198 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
103199 +from_buffer_18625 from_buffer 3 18625 NULL
103200 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
103201 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
103202 +unmap_page_18665 unmap_page 2-3 18665 NULL
103203 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
103204 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
103205 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
103206 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
103207 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
103208 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
103209 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
103210 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
103211 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
103212 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
103213 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
103214 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
103215 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
103216 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
103217 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
103218 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
103219 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
103220 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
103221 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
103222 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
103223 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
103224 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
103225 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
103226 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
103227 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
103228 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
103229 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
103230 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
103231 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
103232 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
103233 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
103234 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
103235 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
103236 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
103237 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
103238 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
103239 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
103240 +huge_page_size_19008 huge_page_size 0 19008 NULL
103241 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
103242 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
103243 +revalidate_19043 revalidate 2 19043 NULL
103244 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
103245 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
103246 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
103247 +msix_map_region_19072 msix_map_region 2 19072 NULL
103248 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
103249 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
103250 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
103251 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
103252 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
103253 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
103254 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
103255 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
103256 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
103257 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
103258 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
103259 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
103260 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
103261 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
103262 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
103263 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
103264 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
103265 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
103266 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
103267 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
103268 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
103269 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
103270 +qc_capture_19298 qc_capture 3 19298 NULL
103271 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
103272 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
103273 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
103274 +debug_read_19322 debug_read 3 19322 NULL
103275 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
103276 +closure_sub_19359 closure_sub 2 19359 NULL
103277 +read_zero_19366 read_zero 3 19366 NULL
103278 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
103279 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
103280 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
103281 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
103282 +__phys_addr_19434 __phys_addr 0 19434 NULL
103283 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
103284 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
103285 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
103286 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
103287 +sky2_read16_19475 sky2_read16 0 19475 NULL
103288 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
103289 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
103290 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
103291 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
103292 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
103293 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
103294 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
103295 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
103296 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
103297 +nfsd_read_19568 nfsd_read 5 19568 NULL
103298 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
103299 +bm_status_read_19583 bm_status_read 3 19583 NULL
103300 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
103301 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
103302 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
103303 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
103304 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
103305 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
103306 +bio_detain_19690 bio_detain 2 19690 NULL
103307 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
103308 +read_reg_19723 read_reg 0 19723 NULL
103309 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
103310 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
103311 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
103312 +p9_client_read_19750 p9_client_read 5 19750 NULL
103313 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
103314 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
103315 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
103316 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
103317 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
103318 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
103319 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
103320 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
103321 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
103322 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
103323 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
103324 +__nla_put_19857 __nla_put 3 19857 NULL
103325 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
103326 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
103327 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
103328 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
103329 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
103330 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
103331 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
103332 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
103333 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
103334 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
103335 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
103336 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
103337 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
103338 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
103339 +team_options_register_20091 team_options_register 3 20091 NULL
103340 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
103341 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
103342 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
103343 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
103344 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
103345 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
103346 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
103347 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
103348 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
103349 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
103350 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
103351 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
103352 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
103353 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
103354 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
103355 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
103356 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
103357 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
103358 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
103359 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
103360 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
103361 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
103362 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
103363 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
103364 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
103365 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
103366 +read_buf_20469 read_buf 2 20469 NULL
103367 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
103368 +fast_user_write_20494 fast_user_write 5 20494 NULL
103369 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
103370 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
103371 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
103372 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
103373 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
103374 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
103375 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
103376 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
103377 +venus_create_20555 venus_create 4 20555 NULL
103378 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
103379 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
103380 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
103381 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
103382 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
103383 +lirc_write_20604 lirc_write 3 20604 NULL
103384 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
103385 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
103386 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
103387 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
103388 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
103389 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
103390 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
103391 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
103392 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
103393 +cpumask_size_20683 cpumask_size 0 20683 NULL
103394 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
103395 +gru_vtop_20689 gru_vtop 2 20689 NULL
103396 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
103397 +__maestro_read_20700 __maestro_read 0 20700 NULL
103398 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
103399 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
103400 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
103401 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
103402 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
103403 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
103404 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
103405 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
103406 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
103407 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
103408 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
103409 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
103410 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
103411 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
103412 +sys_sendto_20809 sys_sendto 6 20809 NULL
103413 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
103414 +strndup_user_20819 strndup_user 2 20819 NULL
103415 +calc_layout_20829 calc_layout 3 20829 NULL
103416 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
103417 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
103418 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
103419 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
103420 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
103421 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
103422 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
103423 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
103424 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
103425 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
103426 +htable_bits_20933 htable_bits 0 20933 NULL
103427 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
103428 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
103429 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
103430 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
103431 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
103432 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
103433 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
103434 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
103435 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
103436 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
103437 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
103438 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
103439 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
103440 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
103441 +multipath_status_21094 multipath_status 5 21094 NULL
103442 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
103443 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
103444 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
103445 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
103446 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
103447 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
103448 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
103449 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
103450 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
103451 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
103452 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
103453 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
103454 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
103455 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
103456 +input_ff_create_21240 input_ff_create 2 21240 NULL
103457 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
103458 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
103459 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
103460 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
103461 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
103462 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
103463 +add_res_range_21310 add_res_range 4 21310 NULL
103464 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
103465 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
103466 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
103467 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
103468 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
103469 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
103470 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
103471 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
103472 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
103473 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
103474 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
103475 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
103476 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
103477 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
103478 +concat_writev_21451 concat_writev 3 21451 NULL
103479 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
103480 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
103481 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
103482 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
103483 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
103484 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
103485 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
103486 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
103487 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
103488 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
103489 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
103490 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
103491 +validate_nnode_21638 validate_nnode 0 21638 NULL
103492 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
103493 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
103494 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
103495 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
103496 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
103497 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
103498 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
103499 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
103500 +vm_brk_21739 vm_brk 1 21739 NULL
103501 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
103502 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
103503 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
103504 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
103505 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
103506 +min_odd_21802 min_odd 0 21802 NULL
103507 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
103508 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
103509 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
103510 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
103511 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
103512 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
103513 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
103514 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
103515 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
103516 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
103517 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
103518 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
103519 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
103520 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
103521 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
103522 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
103523 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
103524 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
103525 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
103526 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
103527 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
103528 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
103529 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
103530 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
103531 +write_opcode_22082 write_opcode 2 22082 NULL
103532 +mem_rw_22085 mem_rw 3 22085 NULL
103533 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
103534 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
103535 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
103536 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
103537 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
103538 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
103539 +compat_insn_22142 compat_insn 2 22142 NULL
103540 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
103541 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
103542 +fls_22210 fls 0 22210 NULL
103543 +mem_write_22232 mem_write 3 22232 NULL
103544 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
103545 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
103546 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
103547 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
103548 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
103549 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
103550 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
103551 +extend_brk_22301 extend_brk 0 22301 NULL
103552 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
103553 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
103554 +get_segment_base_22324 get_segment_base 0 22324 NULL
103555 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
103556 +atomic_read_22342 atomic_read 0 22342 NULL
103557 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
103558 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
103559 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
103560 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
103561 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
103562 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
103563 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
103564 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
103565 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
103566 +zoran_write_22404 zoran_write 3 22404 NULL
103567 +queue_reply_22416 queue_reply 3 22416 NULL
103568 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
103569 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
103570 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
103571 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
103572 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
103573 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
103574 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
103575 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
103576 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
103577 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
103578 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
103579 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
103580 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
103581 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
103582 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
103583 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
103584 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
103585 +snapshot_read_22601 snapshot_read 3 22601 NULL
103586 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
103587 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
103588 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
103589 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
103590 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
103591 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
103592 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
103593 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
103594 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
103595 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
103596 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
103597 +map_22700 map 2 22700 NULL
103598 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
103599 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
103600 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
103601 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
103602 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
103603 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
103604 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
103605 +print_frame_22769 print_frame 0 22769 NULL
103606 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
103607 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
103608 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
103609 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
103610 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
103611 +create_attr_set_22861 create_attr_set 1 22861 NULL
103612 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
103613 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
103614 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
103615 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
103616 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
103617 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
103618 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
103619 +vme_get_size_22964 vme_get_size 0 22964 NULL
103620 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
103621 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
103622 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
103623 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
103624 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
103625 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
103626 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
103627 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
103628 +st_status_23032 st_status 5 23032 NULL
103629 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
103630 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
103631 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
103632 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
103633 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
103634 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
103635 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
103636 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
103637 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
103638 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
103639 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
103640 +fls_long_23096 fls_long 0 23096 NULL
103641 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
103642 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
103643 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
103644 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
103645 +__clear_user_23118 __clear_user 0 23118 NULL
103646 +dm_write_async_23120 dm_write_async 3 23120 NULL
103647 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
103648 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
103649 +read_file_ani_23161 read_file_ani 3 23161 NULL
103650 +ioremap_23172 ioremap 1-2 23172 NULL
103651 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
103652 +usblp_write_23178 usblp_write 3 23178 NULL
103653 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
103654 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
103655 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
103656 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
103657 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
103658 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
103659 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
103660 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
103661 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
103662 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
103663 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
103664 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
103665 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
103666 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
103667 +doc_probe_23285 doc_probe 1 23285 NULL
103668 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
103669 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
103670 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
103671 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
103672 +page_readlink_23346 page_readlink 3 23346 NULL
103673 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
103674 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
103675 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
103676 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
103677 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
103678 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
103679 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
103680 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
103681 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
103682 +event_filter_read_23494 event_filter_read 3 23494 NULL
103683 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
103684 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
103685 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
103686 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
103687 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
103688 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
103689 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
103690 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
103691 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
103692 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
103693 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
103694 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
103695 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
103696 +sInW_23663 sInW 0 23663 NULL
103697 +SyS_connect_23669 SyS_connect 3 23669 NULL
103698 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
103699 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
103700 +cx18_read_23699 cx18_read 3 23699 NULL
103701 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
103702 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
103703 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
103704 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
103705 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
103706 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
103707 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
103708 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
103709 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
103710 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
103711 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
103712 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
103713 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
103714 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
103715 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
103716 +p54_init_common_23850 p54_init_common 1 23850 NULL
103717 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
103718 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
103719 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
103720 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
103721 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
103722 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
103723 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
103724 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
103725 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
103726 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
103727 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
103728 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
103729 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
103730 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
103731 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
103732 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
103733 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
103734 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
103735 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
103736 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
103737 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
103738 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
103739 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
103740 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
103741 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
103742 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
103743 +mpu401_read_24126 mpu401_read 3 24126 NULL
103744 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
103745 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
103746 +set_discard_24162 set_discard 2 24162 NULL
103747 +adu_read_24177 adu_read 3 24177 NULL
103748 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
103749 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
103750 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
103751 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
103752 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
103753 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
103754 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
103755 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
103756 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
103757 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
103758 +thin_status_24278 thin_status 5 24278 NULL
103759 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
103760 +msg_size_24288 msg_size 0 24288 NULL
103761 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
103762 +map_page_24298 map_page 3-4 24298 NULL
103763 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
103764 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
103765 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
103766 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
103767 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
103768 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
103769 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
103770 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
103771 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
103772 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
103773 +igetword_24373 igetword 0 24373 NULL
103774 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
103775 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
103776 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
103777 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
103778 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
103779 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
103780 +smk_user_access_24440 smk_user_access 3 24440 NULL
103781 +page_address_24444 page_address 0 24444 NULL
103782 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
103783 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
103784 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
103785 +pd_video_read_24510 pd_video_read 3 24510 NULL
103786 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
103787 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
103788 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
103789 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
103790 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
103791 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
103792 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
103793 +count_preds_24600 count_preds 0 24600 NULL
103794 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
103795 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
103796 +context_alloc_24645 context_alloc 3 24645 NULL
103797 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
103798 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
103799 +read_fs_24717 read_fs 0 24717 NULL
103800 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
103801 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
103802 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
103803 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
103804 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
103805 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
103806 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
103807 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
103808 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
103809 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
103810 +cache_read_24790 cache_read 3 24790 NULL
103811 +unpack_str_24798 unpack_str 0 24798 NULL
103812 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
103813 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
103814 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
103815 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
103816 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
103817 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
103818 +setup_buffering_24872 setup_buffering 3 24872 NULL
103819 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
103820 +queues_read_24877 queues_read 3 24877 NULL nohasharray
103821 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
103822 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
103823 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
103824 +next_token_24929 next_token 0 24929 NULL
103825 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
103826 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
103827 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
103828 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
103829 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
103830 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
103831 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
103832 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
103833 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
103834 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
103835 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
103836 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
103837 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
103838 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
103839 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
103840 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
103841 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
103842 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
103843 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
103844 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
103845 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
103846 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
103847 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
103848 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
103849 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
103850 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
103851 +stripe_status_25259 stripe_status 5 25259 NULL
103852 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
103853 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
103854 +vfs_writev_25278 vfs_writev 3 25278 NULL
103855 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
103856 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
103857 +help_25316 help 5 25316 NULL nohasharray
103858 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
103859 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
103860 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
103861 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
103862 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
103863 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
103864 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
103865 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
103866 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
103867 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
103868 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
103869 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
103870 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
103871 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
103872 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
103873 +sb_permission_25523 sb_permission 0 25523 NULL
103874 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
103875 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
103876 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
103877 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
103878 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
103879 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
103880 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
103881 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
103882 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
103883 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
103884 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
103885 +__direct_map_25647 __direct_map 5-6 25647 NULL
103886 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
103887 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
103888 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
103889 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
103890 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
103891 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
103892 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
103893 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
103894 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
103895 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
103896 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
103897 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
103898 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
103899 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
103900 +sg_read_25799 sg_read 3 25799 NULL
103901 +system_enable_read_25815 system_enable_read 3 25815 NULL
103902 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
103903 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
103904 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
103905 +parport_read_25855 parport_read 0 25855 NULL
103906 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
103907 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
103908 +key_attr_size_25865 key_attr_size 0 25865 NULL
103909 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
103910 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
103911 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
103912 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
103913 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
103914 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
103915 +rcname_read_25919 rcname_read 3 25919 NULL
103916 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
103917 +key_flags_read_25931 key_flags_read 3 25931 NULL
103918 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
103919 +flush_25957 flush 2 25957 NULL
103920 +video_register_device_25971 video_register_device 3 25971 NULL
103921 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
103922 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
103923 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
103924 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
103925 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
103926 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
103927 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
103928 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
103929 +tun_do_read_26047 tun_do_read 5 26047 NULL
103930 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
103931 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
103932 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
103933 +skb_cow_26138 skb_cow 2 26138 NULL
103934 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
103935 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
103936 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
103937 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
103938 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
103939 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
103940 +disk_devt_26180 disk_devt 0 26180 NULL
103941 +get_registers_26187 get_registers 3 26187 NULL
103942 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
103943 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
103944 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
103945 +mce_write_26201 mce_write 3 26201 NULL
103946 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
103947 +bio_split_26235 bio_split 2 26235 NULL
103948 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
103949 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
103950 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
103951 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
103952 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
103953 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
103954 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
103955 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
103956 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
103957 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
103958 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
103959 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
103960 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
103961 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
103962 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
103963 +read_vmcore_26501 read_vmcore 3 26501 NULL
103964 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
103965 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
103966 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
103967 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
103968 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
103969 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
103970 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
103971 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
103972 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
103973 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
103974 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
103975 +pack_value_26625 pack_value 1 26625 NULL
103976 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
103977 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
103978 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
103979 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
103980 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
103981 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
103982 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
103983 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
103984 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
103985 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
103986 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
103987 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
103988 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
103989 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
103990 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
103991 +smk_write_load_26829 smk_write_load 3 26829 NULL
103992 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
103993 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
103994 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
103995 +scnprint_id_26842 scnprint_id 3 26842 NULL
103996 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
103997 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
103998 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
103999 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104000 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104001 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104002 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104003 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104004 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104005 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104006 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104007 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104008 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104009 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104010 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104011 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104012 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104013 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104014 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104015 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104016 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104017 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104018 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104019 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104020 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104021 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104022 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104023 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104024 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104025 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104026 +pms_capture_27142 pms_capture 4 27142 NULL
104027 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104028 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104029 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104030 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104031 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104032 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104033 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104034 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104035 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104036 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104037 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104038 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104039 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104040 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104041 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104042 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104043 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104044 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104045 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104046 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104047 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104048 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104049 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104050 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104051 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104052 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104053 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104054 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104055 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104056 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104057 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104058 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104059 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104060 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104061 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104062 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104063 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104064 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104065 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104066 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104067 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104068 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104069 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104070 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104071 +qword_get_27670 qword_get 0 27670 NULL
104072 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104073 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104074 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104075 +evm_write_key_27715 evm_write_key 3 27715 NULL
104076 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104077 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104078 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104079 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104080 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104081 +kcalloc_27770 kcalloc 1-2 27770 NULL
104082 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104083 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104084 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104085 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104086 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104087 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104088 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104089 +read_profile_27859 read_profile 3 27859 NULL
104090 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104091 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104092 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104093 +gluebi_write_27905 gluebi_write 3 27905 NULL
104094 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104095 +bm_find_next_27929 bm_find_next 2 27929 NULL
104096 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104097 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104098 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104099 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104100 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
104101 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
104102 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
104103 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
104104 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
104105 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
104106 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
104107 +pool_status_28055 pool_status 5 28055 NULL
104108 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
104109 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
104110 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
104111 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
104112 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
104113 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
104114 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
104115 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
104116 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
104117 +video_read_28148 video_read 3 28148 NULL
104118 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
104119 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
104120 +vread_28173 vread 0 28173 NULL
104121 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
104122 +d_path_28198 d_path 0 28198 NULL
104123 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
104124 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
104125 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
104126 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
104127 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
104128 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
104129 +usemap_size_28281 usemap_size 0 28281 NULL
104130 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
104131 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
104132 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
104133 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
104134 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
104135 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
104136 +snapshot_write_28351 snapshot_write 3 28351 NULL
104137 +sys_writev_28384 sys_writev 3 28384 NULL
104138 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
104139 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
104140 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
104141 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
104142 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
104143 +__split_large_page_28429 __split_large_page 2 28429 NULL
104144 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
104145 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
104146 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
104147 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
104148 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
104149 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
104150 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
104151 +max_response_pages_28492 max_response_pages 0 28492 NULL
104152 +clear_discard_28494 clear_discard 2 28494 NULL
104153 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
104154 +__next_node_28521 __next_node 1 28521 NULL
104155 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
104156 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
104157 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
104158 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
104159 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
104160 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
104161 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
104162 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
104163 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
104164 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
104165 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
104166 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
104167 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
104168 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
104169 +_set_range_28627 _set_range 3 28627 NULL
104170 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
104171 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
104172 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
104173 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
104174 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
104175 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
104176 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
104177 +spi_execute_28736 spi_execute 5 28736 NULL
104178 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
104179 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
104180 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
104181 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
104182 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
104183 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
104184 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
104185 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
104186 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
104187 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
104188 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
104189 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
104190 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
104191 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
104192 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
104193 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
104194 +to_cblock_28899 to_cblock 0-1 28899 NULL
104195 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
104196 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
104197 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
104198 +push_rx_28939 push_rx 3 28939 NULL
104199 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
104200 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
104201 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
104202 +bin_uuid_28999 bin_uuid 3 28999 NULL
104203 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
104204 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
104205 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
104206 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
104207 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
104208 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
104209 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
104210 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
104211 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
104212 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
104213 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
104214 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
104215 +snprintf_29125 snprintf 0 29125 NULL
104216 +iov_shorten_29130 iov_shorten 0 29130 NULL
104217 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
104218 +reshape_ring_29147 reshape_ring 2 29147 NULL
104219 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
104220 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
104221 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
104222 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
104223 +__mm_populate_29204 __mm_populate 1 29204 NULL
104224 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
104225 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
104226 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
104227 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
104228 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
104229 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
104230 +recover_peb_29238 recover_peb 6-7 29238 NULL
104231 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
104232 +block_div_29268 block_div 0-1-2 29268 NULL
104233 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
104234 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
104235 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
104236 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
104237 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
104238 +tun_put_user_29337 tun_put_user 5 29337 NULL
104239 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
104240 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
104241 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
104242 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
104243 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
104244 +mempool_create_29437 mempool_create 1 29437 NULL
104245 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
104246 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
104247 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
104248 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
104249 +do_register_entry_29478 do_register_entry 4 29478 NULL
104250 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
104251 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
104252 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
104253 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
104254 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
104255 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
104256 +set_brk_29551 set_brk 1 29551 NULL nohasharray
104257 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
104258 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
104259 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
104260 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
104261 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
104262 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
104263 +slots_per_page_29601 slots_per_page 0 29601 NULL
104264 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
104265 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
104266 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
104267 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
104268 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
104269 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
104270 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
104271 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
104272 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
104273 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
104274 +probes_write_29711 probes_write 3 29711 NULL
104275 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
104276 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
104277 +std_nic_write_29752 std_nic_write 3 29752 NULL
104278 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
104279 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
104280 +dbAlloc_29794 dbAlloc 0 29794 NULL
104281 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
104282 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
104283 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
104284 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
104285 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
104286 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
104287 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
104288 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
104289 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
104290 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
104291 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
104292 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
104293 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
104294 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
104295 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
104296 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
104297 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
104298 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
104299 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
104300 +drp_wmove_30043 drp_wmove 4 30043 NULL
104301 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
104302 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
104303 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
104304 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
104305 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
104306 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
104307 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
104308 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
104309 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
104310 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
104311 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
104312 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
104313 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
104314 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
104315 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
104316 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
104317 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
104318 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
104319 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
104320 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
104321 +compat_readv_30273 compat_readv 3 30273 NULL
104322 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
104323 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
104324 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
104325 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
104326 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
104327 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
104328 +resource_from_user_30341 resource_from_user 3 30341 NULL
104329 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
104330 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
104331 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
104332 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
104333 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
104334 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
104335 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
104336 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
104337 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
104338 +mq_create_30425 mq_create 1 30425 NULL
104339 +enable_write_30456 enable_write 3 30456 NULL
104340 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
104341 +urandom_read_30462 urandom_read 3 30462 NULL
104342 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
104343 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
104344 +write_head_30481 write_head 4 30481 NULL
104345 +adu_write_30487 adu_write 3 30487 NULL
104346 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
104347 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
104348 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
104349 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
104350 +set_le_30581 set_le 4 30581 NULL
104351 +from_cblock_30582 from_cblock 0-1 30582 NULL
104352 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
104353 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
104354 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
104355 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
104356 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
104357 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
104358 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
104359 +agp_remap_30665 agp_remap 2 30665 NULL
104360 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
104361 +il_free_pages_30692 il_free_pages 2 30692 NULL
104362 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
104363 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
104364 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
104365 +snapshot_status_30744 snapshot_status 5 30744 NULL
104366 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
104367 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
104368 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
104369 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
104370 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
104371 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
104372 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
104373 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
104374 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
104375 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
104376 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
104377 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
104378 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
104379 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
104380 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
104381 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
104382 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
104383 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
104384 +sys_mincore_31079 sys_mincore 1 31079 NULL
104385 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
104386 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
104387 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
104388 +depth_read_31112 depth_read 3 31112 NULL
104389 +ssb_read16_31139 ssb_read16 0 31139 NULL
104390 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
104391 +size_inside_page_31141 size_inside_page 0 31141 NULL
104392 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
104393 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
104394 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
104395 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
104396 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
104397 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
104398 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
104399 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
104400 +__read_reg_31216 __read_reg 0 31216 NULL
104401 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
104402 +cyy_readb_31240 cyy_readb 0 31240 NULL
104403 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
104404 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
104405 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
104406 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
104407 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
104408 +command_file_write_31318 command_file_write 3 31318 NULL
104409 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
104410 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
104411 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
104412 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
104413 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
104414 +inb_31388 inb 0 31388 NULL
104415 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
104416 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
104417 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
104418 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
104419 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
104420 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
104421 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
104422 +do_fcntl_31468 do_fcntl 3 31468 NULL
104423 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
104424 +alg_setkey_31485 alg_setkey 3 31485 NULL
104425 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
104426 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
104427 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
104428 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
104429 +hidraw_write_31536 hidraw_write 3 31536 NULL
104430 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
104431 +usbvision_read_31555 usbvision_read 3 31555 NULL
104432 +normalize_31566 normalize 0-1-2 31566 NULL
104433 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
104434 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
104435 +osst_write_31581 osst_write 3 31581 NULL
104436 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
104437 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
104438 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
104439 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
104440 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
104441 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
104442 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
104443 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
104444 +__lgread_31668 __lgread 4 31668 NULL
104445 +symbol_string_31670 symbol_string 0 31670 NULL
104446 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
104447 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
104448 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
104449 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
104450 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
104451 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
104452 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
104453 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
104454 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
104455 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
104456 +muldiv64_31743 muldiv64 2-3 31743 NULL
104457 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
104458 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
104459 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
104460 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
104461 +get_count_order_31800 get_count_order 0 31800 NULL
104462 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
104463 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
104464 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
104465 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
104466 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
104467 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
104468 +xattr_permission_31907 xattr_permission 0 31907 NULL
104469 +new_dir_31919 new_dir 3 31919 NULL
104470 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
104471 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
104472 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
104473 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
104474 +vb2_write_31948 vb2_write 3 31948 NULL
104475 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
104476 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
104477 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
104478 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
104479 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
104480 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
104481 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
104482 +calc_hmac_32010 calc_hmac 3 32010 NULL
104483 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
104484 +aead_len_32021 aead_len 0 32021 NULL
104485 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
104486 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
104487 +stk_read_32038 stk_read 3 32038 NULL
104488 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
104489 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
104490 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
104491 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
104492 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
104493 +bio_alloc_32095 bio_alloc 2 32095 NULL
104494 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
104495 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
104496 +disk_status_32120 disk_status 4 32120 NULL
104497 +venus_link_32165 venus_link 5 32165 NULL
104498 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
104499 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
104500 +load_header_32183 load_header 0 32183 NULL
104501 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
104502 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
104503 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
104504 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
104505 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
104506 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
104507 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
104508 +hex_string_32310 hex_string 0 32310 NULL
104509 +SyS_select_32319 SyS_select 1 32319 NULL
104510 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
104511 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
104512 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
104513 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
104514 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
104515 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
104516 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
104517 +local_clock_32385 local_clock 0 32385 NULL
104518 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
104519 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
104520 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
104521 +log_text_32428 log_text 0 32428 NULL
104522 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
104523 +hid_input_report_32458 hid_input_report 4 32458 NULL
104524 +cache_status_32462 cache_status 5 32462 NULL
104525 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
104526 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
104527 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
104528 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
104529 +disconnect_32521 disconnect 4 32521 NULL
104530 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
104531 +ilo_read_32531 ilo_read 3 32531 NULL
104532 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
104533 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
104534 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
104535 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
104536 +__first_node_32558 __first_node 0 32558 NULL
104537 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
104538 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
104539 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
104540 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
104541 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
104542 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
104543 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
104544 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
104545 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
104546 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
104547 +kvmalloc_32646 kvmalloc 1 32646 NULL
104548 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
104549 +generic_readlink_32654 generic_readlink 3 32654 NULL
104550 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
104551 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
104552 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
104553 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
104554 +get_arg_page_32746 get_arg_page 2 32746 NULL
104555 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
104556 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
104557 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
104558 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
104559 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
104560 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
104561 +vga_rseq_32848 vga_rseq 0 32848 NULL
104562 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
104563 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
104564 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
104565 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
104566 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
104567 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
104568 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
104569 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
104570 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
104571 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
104572 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
104573 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
104574 +compat_filldir_32999 compat_filldir 3 32999 NULL
104575 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
104576 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
104577 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
104578 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
104579 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
104580 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
104581 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
104582 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
104583 +alloc_tio_33077 alloc_tio 3 33077 NULL
104584 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
104585 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
104586 +write_node_33121 write_node 4 33121 NULL
104587 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
104588 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
104589 +__len_within_target_33132 __len_within_target 0 33132 NULL
104590 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
104591 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
104592 +pp_read_33210 pp_read 3 33210 NULL
104593 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
104594 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
104595 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
104596 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
104597 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
104598 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
104599 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
104600 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
104601 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
104602 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
104603 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
104604 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
104605 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
104606 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
104607 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
104608 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
104609 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
104610 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
104611 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
104612 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
104613 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
104614 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
104615 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
104616 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
104617 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
104618 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
104619 +create_entry_33479 create_entry 2 33479 NULL
104620 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
104621 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
104622 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
104623 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
104624 +res_counter_read_33499 res_counter_read 4 33499 NULL
104625 +fb_read_33506 fb_read 3 33506 NULL
104626 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
104627 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
104628 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
104629 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
104630 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
104631 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
104632 +dup_array_33551 dup_array 3 33551 NULL
104633 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
104634 +count_subheaders_33591 count_subheaders 0 33591 NULL
104635 +scsi_execute_33596 scsi_execute 5 33596 NULL
104636 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
104637 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
104638 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
104639 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
104640 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
104641 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
104642 +inw_p_33668 inw_p 0 33668 NULL
104643 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
104644 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
104645 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
104646 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
104647 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
104648 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
104649 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
104650 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
104651 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
104652 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
104653 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
104654 +Read_hfc_33755 Read_hfc 0 33755 NULL
104655 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
104656 +hashtab_create_33769 hashtab_create 3 33769 NULL
104657 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
104658 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
104659 +find_next_offset_33804 find_next_offset 3 33804 NULL
104660 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
104661 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
104662 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
104663 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
104664 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
104665 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
104666 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
104667 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
104668 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
104669 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
104670 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
104671 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
104672 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
104673 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
104674 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
104675 +ppp_write_34034 ppp_write 3 34034 NULL
104676 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
104677 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
104678 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
104679 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
104680 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
104681 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
104682 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
104683 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
104684 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
104685 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
104686 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
104687 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
104688 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
104689 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
104690 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
104691 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
104692 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
104693 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
104694 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
104695 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
104696 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
104697 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
104698 +__insert_34349 __insert 2-3 34349 NULL
104699 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
104700 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
104701 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
104702 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
104703 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
104704 +ea_read_34378 ea_read 0 34378 NULL
104705 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
104706 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
104707 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
104708 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
104709 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
104710 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
104711 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
104712 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
104713 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
104714 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
104715 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
104716 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
104717 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
104718 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
104719 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
104720 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
104721 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
104722 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
104723 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
104724 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
104725 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
104726 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
104727 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
104728 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
104729 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
104730 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
104731 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
104732 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
104733 +port_print_34704 port_print 3 34704 NULL
104734 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
104735 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
104736 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
104737 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
104738 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
104739 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
104740 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
104741 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
104742 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
104743 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
104744 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
104745 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
104746 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
104747 +msg_print_text_34889 msg_print_text 0 34889 NULL
104748 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
104749 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
104750 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
104751 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
104752 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
104753 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
104754 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
104755 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
104756 +Realloc_34961 Realloc 2 34961 NULL
104757 +mq_lookup_34990 mq_lookup 2 34990 NULL
104758 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
104759 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
104760 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
104761 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
104762 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
104763 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
104764 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
104765 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
104766 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
104767 +store_ifalias_35088 store_ifalias 4 35088 NULL
104768 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
104769 +capi_write_35104 capi_write 3 35104 NULL nohasharray
104770 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
104771 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
104772 +pointer_35138 pointer 0 35138 NULL
104773 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
104774 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
104775 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
104776 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
104777 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
104778 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
104779 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
104780 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
104781 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
104782 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
104783 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
104784 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
104785 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
104786 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
104787 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
104788 +set_fd_set_35249 set_fd_set 1 35249 NULL
104789 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
104790 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
104791 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
104792 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
104793 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
104794 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
104795 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
104796 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
104797 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
104798 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
104799 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
104800 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
104801 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
104802 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
104803 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
104804 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
104805 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
104806 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
104807 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
104808 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
104809 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
104810 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
104811 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
104812 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
104813 +async_setkey_35521 async_setkey 3 35521 NULL
104814 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
104815 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
104816 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
104817 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
104818 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
104819 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
104820 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
104821 +ReadZReg_35604 ReadZReg 0 35604 NULL
104822 +kernel_readv_35617 kernel_readv 3 35617 NULL
104823 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
104824 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
104825 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
104826 +store_debug_level_35652 store_debug_level 3 35652 NULL
104827 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
104828 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
104829 +dm_table_create_35687 dm_table_create 3 35687 NULL
104830 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
104831 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
104832 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
104833 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
104834 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
104835 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
104836 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
104837 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
104838 +fls64_35862 fls64 0 35862 NULL
104839 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
104840 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
104841 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
104842 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
104843 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
104844 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
104845 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
104846 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
104847 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
104848 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
104849 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
104850 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
104851 +acl_alloc_35979 acl_alloc 1 35979 NULL
104852 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
104853 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
104854 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
104855 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
104856 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
104857 +account_shadowed_36048 account_shadowed 2 36048 NULL
104858 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
104859 +write_emulate_36065 write_emulate 2-4 36065 NULL
104860 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
104861 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
104862 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
104863 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
104864 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
104865 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
104866 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
104867 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
104868 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
104869 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
104870 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
104871 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
104872 +twl_set_36154 twl_set 2 36154 NULL
104873 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
104874 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
104875 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
104876 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
104877 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
104878 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
104879 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
104880 +is_dirty_36223 is_dirty 2 36223 NULL
104881 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
104882 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
104883 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
104884 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
104885 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
104886 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
104887 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
104888 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
104889 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
104890 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
104891 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
104892 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
104893 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
104894 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
104895 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
104896 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
104897 +lc_create_36332 lc_create 4 36332 NULL
104898 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
104899 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
104900 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
104901 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
104902 +to_sector_36361 to_sector 0-1 36361 NULL
104903 +tunables_read_36385 tunables_read 3 36385 NULL
104904 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
104905 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
104906 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
104907 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
104908 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
104909 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
104910 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
104911 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
104912 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
104913 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
104914 +get_param_l_36518 get_param_l 0 36518 NULL
104915 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
104916 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
104917 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
104918 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
104919 +get_entry_len_36549 get_entry_len 0 36549 NULL
104920 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
104921 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
104922 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
104923 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
104924 +__erst_read_36579 __erst_read 0 36579 NULL
104925 +put_cmsg_36589 put_cmsg 4 36589 NULL
104926 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
104927 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
104928 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
104929 +format_decode_36638 format_decode 0 36638 NULL
104930 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
104931 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
104932 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
104933 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
104934 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
104935 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
104936 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
104937 +sched_clock_36717 sched_clock 0 36717 NULL
104938 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
104939 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
104940 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
104941 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
104942 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
104943 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
104944 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
104945 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
104946 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
104947 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
104948 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
104949 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
104950 +cm_write_36858 cm_write 3 36858 NULL
104951 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
104952 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
104953 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
104954 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
104955 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
104956 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
104957 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
104958 +build_key_36931 build_key 1 36931 NULL
104959 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
104960 +write_leb_36957 write_leb 5 36957 NULL
104961 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
104962 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
104963 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
104964 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
104965 +setxattr_37006 setxattr 4 37006 NULL
104966 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
104967 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
104968 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
104969 +parse_command_37079 parse_command 2 37079 NULL
104970 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
104971 +tun_get_user_37094 tun_get_user 5 37094 NULL
104972 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
104973 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
104974 +msg_word_37164 msg_word 0 37164 NULL
104975 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
104976 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
104977 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
104978 +__do_replace_37227 __do_replace 5 37227 NULL
104979 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
104980 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
104981 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
104982 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
104983 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
104984 +c101_run_37279 c101_run 2 37279 NULL
104985 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
104986 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
104987 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
104988 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
104989 +send_msg_37323 send_msg 4 37323 NULL
104990 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
104991 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
104992 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
104993 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
104994 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
104995 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
104996 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
104997 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
104998 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
104999 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105000 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105001 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105002 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105003 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105004 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105005 +__remove_37457 __remove 2 37457 NULL
105006 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105007 +get_est_timing_37484 get_est_timing 0 37484 NULL
105008 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105009 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105010 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105011 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105012 +hdr_size_37536 hdr_size 0 37536 NULL
105013 +a2p_37544 a2p 0-1 37544 NULL
105014 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105015 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105016 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105017 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105018 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105019 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105020 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105021 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105022 +check_pt_base_37635 check_pt_base 3 37635 NULL
105023 +alloc_fd_37637 alloc_fd 1 37637 NULL
105024 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105025 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105026 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105027 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105028 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105029 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105030 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105031 +nametbl_header_37698 nametbl_header 2 37698 NULL
105032 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105033 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105034 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105035 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105036 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105037 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105038 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105039 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105040 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105041 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105042 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105043 +deny_write_access_37813 deny_write_access 0 37813 NULL
105044 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105045 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105046 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105047 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105048 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105049 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105050 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105051 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105052 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105053 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105054 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105055 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105056 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105057 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105058 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105059 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105060 +vfs_readv_38011 vfs_readv 3 38011 NULL
105061 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105062 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105063 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105064 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105065 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105066 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105067 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105068 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105069 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105070 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105071 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105072 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105073 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105074 +ep0_read_38095 ep0_read 3 38095 NULL
105075 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105076 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105077 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105078 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105079 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105080 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105081 +cdev_add_38176 cdev_add 2-3 38176 NULL
105082 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105083 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105084 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105085 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105086 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105087 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105088 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105089 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105090 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105091 +from_dblock_38256 from_dblock 0-1 38256 NULL
105092 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105093 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105094 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105095 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105096 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105097 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105098 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105099 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105100 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
105101 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
105102 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
105103 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
105104 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
105105 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
105106 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
105107 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
105108 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
105109 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
105110 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
105111 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
105112 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
105113 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
105114 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
105115 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
105116 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
105117 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
105118 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
105119 +dev_names_read_38509 dev_names_read 3 38509 NULL
105120 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
105121 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
105122 +set_queue_count_38519 set_queue_count 0 38519 NULL
105123 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
105124 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
105125 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
105126 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
105127 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
105128 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
105129 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
105130 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
105131 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
105132 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
105133 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
105134 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
105135 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
105136 +cma_create_area_38642 cma_create_area 2 38642 NULL
105137 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
105138 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
105139 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
105140 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
105141 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
105142 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
105143 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
105144 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
105145 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
105146 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
105147 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
105148 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
105149 +udf_readpages_38761 udf_readpages 4 38761 NULL
105150 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
105151 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
105152 +err_decode_38804 err_decode 2 38804 NULL
105153 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
105154 +sys_select_38827 sys_select 1 38827 NULL
105155 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
105156 +direct_entry_38836 direct_entry 3 38836 NULL
105157 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
105158 +interfaces_38859 interfaces 2 38859 NULL
105159 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
105160 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
105161 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
105162 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
105163 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
105164 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
105165 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
105166 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
105167 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
105168 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
105169 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
105170 +udf_new_block_38999 udf_new_block 4 38999 NULL
105171 +get_nodes_39012 get_nodes 3 39012 NULL
105172 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
105173 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
105174 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
105175 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
105176 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
105177 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
105178 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
105179 +ea_foreach_39133 ea_foreach 0 39133 NULL
105180 +generic_permission_39150 generic_permission 0 39150 NULL
105181 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
105182 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
105183 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
105184 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
105185 +init_list_set_39188 init_list_set 2-3 39188 NULL
105186 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
105187 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
105188 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
105189 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
105190 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
105191 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
105192 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
105193 +drm_order_39244 drm_order 0 39244 NULL
105194 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
105195 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
105196 +__skb_cow_39254 __skb_cow 2 39254 NULL
105197 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
105198 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
105199 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
105200 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
105201 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
105202 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
105203 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
105204 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
105205 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
105206 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
105207 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
105208 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
105209 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
105210 +__send_to_port_39386 __send_to_port 3 39386 NULL
105211 +user_power_read_39414 user_power_read 3 39414 NULL
105212 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
105213 +sys_semop_39457 sys_semop 3 39457 NULL
105214 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
105215 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
105216 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
105217 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
105218 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
105219 +int_proc_write_39542 int_proc_write 3 39542 NULL
105220 +pp_write_39554 pp_write 3 39554 NULL
105221 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
105222 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
105223 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
105224 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
105225 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
105226 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
105227 +ext_depth_39607 ext_depth 0 39607 NULL
105228 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
105229 +sdio_readb_39618 sdio_readb 0 39618 NULL
105230 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
105231 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
105232 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
105233 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
105234 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
105235 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
105236 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
105237 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
105238 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
105239 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
105240 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
105241 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
105242 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
105243 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
105244 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
105245 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
105246 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
105247 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
105248 +pkt_add_39897 pkt_add 3 39897 NULL
105249 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
105250 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
105251 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
105252 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
105253 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
105254 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
105255 +__spi_async_39932 __spi_async 0 39932 NULL
105256 +__get_order_39935 __get_order 0 39935 NULL
105257 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
105258 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
105259 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
105260 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
105261 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
105262 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
105263 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
105264 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
105265 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
105266 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
105267 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
105268 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
105269 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
105270 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
105271 +add_tty_40055 add_tty 1 40055 NULL nohasharray
105272 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
105273 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
105274 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
105275 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
105276 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
105277 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
105278 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
105279 +pt_write_40159 pt_write 3 40159 NULL
105280 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
105281 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
105282 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
105283 +allocate_probes_40204 allocate_probes 1 40204 NULL
105284 +compat_put_long_40214 compat_put_long 1 40214 NULL
105285 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
105286 +osst_read_40237 osst_read 3 40237 NULL
105287 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
105288 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
105289 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
105290 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
105291 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
105292 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
105293 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
105294 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
105295 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
105296 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
105297 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
105298 +mmio_read_40348 mmio_read 4 40348 NULL
105299 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
105300 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
105301 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
105302 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
105303 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
105304 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
105305 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
105306 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
105307 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
105308 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
105309 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
105310 +tty_write_room_40495 tty_write_room 0 40495 NULL
105311 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
105312 +sg_phys_40507 sg_phys 0 40507 NULL
105313 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
105314 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
105315 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
105316 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
105317 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
105318 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
105319 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
105320 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
105321 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
105322 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
105323 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
105324 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
105325 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
105326 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
105327 +fops_read_40672 fops_read 3 40672 NULL
105328 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
105329 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
105330 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
105331 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
105332 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
105333 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
105334 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
105335 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
105336 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
105337 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
105338 +card_send_command_40757 card_send_command 3 40757 NULL
105339 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
105340 +pg_write_40766 pg_write 3 40766 NULL
105341 +show_list_40775 show_list 3 40775 NULL
105342 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
105343 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
105344 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
105345 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
105346 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
105347 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
105348 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
105349 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
105350 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
105351 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
105352 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
105353 +read_file_queue_40895 read_file_queue 3 40895 NULL
105354 +waiters_read_40902 waiters_read 3 40902 NULL
105355 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
105356 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
105357 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
105358 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
105359 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
105360 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
105361 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
105362 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
105363 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
105364 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
105365 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
105366 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
105367 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
105368 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
105369 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
105370 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
105371 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
105372 +dma_attach_41094 dma_attach 5-6 41094 NULL
105373 +provide_user_output_41105 provide_user_output 3 41105 NULL
105374 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
105375 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
105376 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
105377 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
105378 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
105379 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
105380 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
105381 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
105382 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
105383 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
105384 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
105385 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
105386 +erst_read_41260 erst_read 0 41260 NULL
105387 +__fprog_create_41263 __fprog_create 2 41263 NULL
105388 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
105389 +alloc_context_41283 alloc_context 1 41283 NULL
105390 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
105391 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
105392 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
105393 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
105394 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
105395 +kmp_init_41373 kmp_init 2 41373 NULL
105396 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
105397 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
105398 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
105399 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
105400 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
105401 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
105402 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
105403 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
105404 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
105405 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
105406 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
105407 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
105408 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
105409 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
105410 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
105411 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
105412 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
105413 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
105414 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
105415 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
105416 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
105417 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
105418 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
105419 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
105420 +vga_io_r_41609 vga_io_r 0 41609 NULL
105421 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
105422 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
105423 +a2mp_send_41615 a2mp_send 4 41615 NULL
105424 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
105425 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
105426 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
105427 +get_std_timing_41654 get_std_timing 0 41654 NULL
105428 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
105429 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
105430 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
105431 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
105432 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
105433 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
105434 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
105435 +fillonedir_41746 fillonedir 3 41746 NULL
105436 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
105437 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
105438 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
105439 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
105440 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
105441 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
105442 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
105443 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
105444 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
105445 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
105446 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
105447 +get_packet_41914 get_packet 3 41914 NULL
105448 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
105449 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
105450 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
105451 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
105452 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
105453 +read_gssp_41947 read_gssp 3 41947 NULL
105454 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
105455 +portnames_read_41958 portnames_read 3 41958 NULL
105456 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
105457 +dst_mtu_41969 dst_mtu 0 41969 NULL
105458 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
105459 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
105460 +lguest_map_42008 lguest_map 1-2 42008 NULL
105461 +pool_allocate_42012 pool_allocate 3 42012 NULL
105462 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
105463 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
105464 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
105465 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
105466 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
105467 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
105468 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
105469 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
105470 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
105471 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
105472 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
105473 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
105474 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
105475 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
105476 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
105477 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
105478 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
105479 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
105480 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
105481 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
105482 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
105483 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
105484 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
105485 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
105486 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
105487 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
105488 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
105489 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
105490 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
105491 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
105492 +free_cblock_42318 free_cblock 2 42318 NULL
105493 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
105494 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
105495 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
105496 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
105497 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
105498 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
105499 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
105500 +krng_get_random_42420 krng_get_random 3 42420 NULL
105501 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
105502 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
105503 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
105504 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
105505 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
105506 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
105507 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
105508 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
105509 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
105510 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
105511 +bypass_write_42498 bypass_write 3 42498 NULL
105512 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
105513 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
105514 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
105515 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
105516 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
105517 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
105518 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
105519 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
105520 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
105521 +map_state_42602 map_state 1 42602 NULL nohasharray
105522 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
105523 +nd_get_link_42603 nd_get_link 0 42603 NULL
105524 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
105525 +resp_write_42628 resp_write 2 42628 NULL
105526 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
105527 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
105528 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
105529 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
105530 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
105531 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
105532 +vb2_read_42703 vb2_read 3 42703 NULL
105533 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
105534 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
105535 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
105536 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
105537 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
105538 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
105539 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
105540 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
105541 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
105542 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
105543 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
105544 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
105545 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
105546 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
105547 +set_arg_42824 set_arg 3 42824 NULL
105548 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
105549 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
105550 +prandom_u32_42853 prandom_u32 0 42853 NULL
105551 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
105552 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
105553 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
105554 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
105555 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
105556 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
105557 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
105558 +hd_end_request_42904 hd_end_request 2 42904 NULL
105559 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
105560 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
105561 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
105562 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
105563 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
105564 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
105565 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
105566 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
105567 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
105568 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
105569 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
105570 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
105571 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
105572 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
105573 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
105574 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
105575 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
105576 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
105577 +uuid_string_43154 uuid_string 0 43154 NULL
105578 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
105579 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
105580 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
105581 +process_measurement_43190 process_measurement 0 43190 NULL
105582 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
105583 +uio_write_43202 uio_write 3 43202 NULL
105584 +iso_callback_43208 iso_callback 3 43208 NULL
105585 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
105586 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
105587 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
105588 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
105589 +fixup_leb_43256 fixup_leb 3 43256 NULL
105590 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
105591 +evtchn_write_43278 evtchn_write 3 43278 NULL
105592 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
105593 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
105594 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
105595 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
105596 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
105597 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
105598 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
105599 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
105600 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
105601 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
105602 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
105603 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
105604 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
105605 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
105606 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
105607 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
105608 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
105609 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
105610 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
105611 +do_readlink_43518 do_readlink 2 43518 NULL
105612 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
105613 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
105614 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
105615 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
105616 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
105617 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
105618 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
105619 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
105620 +proc_read_43614 proc_read 3 43614 NULL
105621 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
105622 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
105623 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
105624 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
105625 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
105626 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
105627 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
105628 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
105629 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
105630 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
105631 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
105632 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
105633 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
105634 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
105635 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
105636 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
105637 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
105638 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
105639 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
105640 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
105641 +read_flush_43851 read_flush 3 43851 NULL
105642 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
105643 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
105644 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
105645 +SendString_43928 SendString 3 43928 NULL
105646 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
105647 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
105648 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
105649 +nla_reserve_43984 nla_reserve 3 43984 NULL
105650 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
105651 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
105652 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
105653 +emit_flags_44006 emit_flags 4-3 44006 NULL
105654 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
105655 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
105656 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
105657 +load_discard_44083 load_discard 3 44083 NULL
105658 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
105659 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
105660 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
105661 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
105662 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
105663 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
105664 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
105665 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
105666 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
105667 +__set_free_44211 __set_free 2 44211 NULL
105668 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
105669 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
105670 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
105671 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
105672 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
105673 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
105674 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
105675 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
105676 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
105677 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
105678 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
105679 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
105680 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
105681 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
105682 +__is_discarded_44359 __is_discarded 2 44359 NULL
105683 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
105684 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
105685 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
105686 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
105687 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
105688 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
105689 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
105690 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
105691 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
105692 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
105693 +bio_advance_44496 bio_advance 2 44496 NULL
105694 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
105695 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
105696 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
105697 +spidev_write_44510 spidev_write 3 44510 NULL
105698 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
105699 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
105700 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
105701 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
105702 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
105703 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
105704 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
105705 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
105706 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
105707 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
105708 +mpi_resize_44674 mpi_resize 2 44674 NULL
105709 +ts_read_44687 ts_read 3 44687 NULL
105710 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
105711 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
105712 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
105713 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
105714 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
105715 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
105716 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
105717 +set_brk_44749 set_brk 1 44749 NULL
105718 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
105719 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
105720 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
105721 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
105722 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
105723 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
105724 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
105725 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
105726 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
105727 +sisusb_write_44834 sisusb_write 3 44834 NULL
105728 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
105729 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
105730 +cubic_root_44848 cubic_root 1 44848 NULL
105731 +copydesc_user_44855 copydesc_user 3 44855 NULL
105732 +skb_availroom_44883 skb_availroom 0 44883 NULL
105733 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
105734 +do_tty_write_44896 do_tty_write 5 44896 NULL
105735 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
105736 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
105737 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
105738 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
105739 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
105740 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
105741 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
105742 +sel_write_user_45060 sel_write_user 3 45060 NULL
105743 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
105744 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
105745 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
105746 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
105747 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
105748 +usbdev_read_45114 usbdev_read 3 45114 NULL
105749 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
105750 +send_to_tty_45141 send_to_tty 3 45141 NULL
105751 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
105752 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
105753 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
105754 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
105755 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
105756 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
105757 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
105758 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
105759 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
105760 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
105761 +add_child_45201 add_child 4 45201 NULL
105762 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
105763 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
105764 +__dirty_45228 __dirty 2 45228 NULL
105765 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
105766 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
105767 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
105768 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
105769 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
105770 +pte_val_45313 pte_val 0 45313 NULL
105771 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
105772 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
105773 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
105774 +keymap_store_45406 keymap_store 4 45406 NULL
105775 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
105776 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
105777 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
105778 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
105779 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
105780 +__node_remap_45458 __node_remap 4 45458 NULL
105781 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
105782 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
105783 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
105784 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
105785 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
105786 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
105787 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
105788 +copy_macs_45534 copy_macs 4 45534 NULL
105789 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
105790 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
105791 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
105792 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
105793 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
105794 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
105795 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
105796 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
105797 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
105798 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
105799 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
105800 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
105801 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
105802 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
105803 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
105804 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
105805 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
105806 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
105807 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
105808 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
105809 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
105810 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
105811 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
105812 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
105813 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
105814 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
105815 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
105816 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
105817 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
105818 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
105819 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
105820 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
105821 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
105822 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
105823 +isdn_write_45863 isdn_write 3 45863 NULL
105824 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
105825 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
105826 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
105827 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
105828 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
105829 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
105830 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
105831 +alloc_mr_45935 alloc_mr 1 45935 NULL
105832 +split_large_page_45941 split_large_page 2 45941 NULL
105833 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
105834 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
105835 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
105836 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
105837 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
105838 +get_free_entries_46030 get_free_entries 1 46030 NULL
105839 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
105840 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
105841 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
105842 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
105843 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
105844 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
105845 +slhc_toss_46066 slhc_toss 0 46066 NULL
105846 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
105847 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
105848 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
105849 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
105850 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
105851 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
105852 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
105853 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
105854 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
105855 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
105856 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
105857 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
105858 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
105859 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
105860 +add_conn_list_46197 add_conn_list 3 46197 NULL
105861 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
105862 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
105863 +dsp_write_46218 dsp_write 2 46218 NULL
105864 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
105865 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
105866 +ReadReg_46277 ReadReg 0 46277 NULL
105867 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
105868 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
105869 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
105870 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
105871 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
105872 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
105873 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
105874 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
105875 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
105876 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
105877 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
105878 +filldir64_46469 filldir64 3 46469 NULL
105879 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
105880 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
105881 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
105882 +kmsg_read_46514 kmsg_read 3 46514 NULL
105883 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
105884 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
105885 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
105886 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
105887 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
105888 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
105889 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
105890 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
105891 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
105892 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
105893 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
105894 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
105895 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
105896 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
105897 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
105898 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
105899 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
105900 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
105901 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
105902 +prepare_copy_46725 prepare_copy 2 46725 NULL
105903 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
105904 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
105905 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
105906 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
105907 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
105908 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
105909 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
105910 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
105911 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
105912 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
105913 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
105914 +spi_async_46857 spi_async 0 46857 NULL
105915 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
105916 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
105917 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
105918 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
105919 +rvmalloc_46873 rvmalloc 1 46873 NULL
105920 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
105921 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
105922 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
105923 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
105924 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
105925 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
105926 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
105927 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
105928 +fb_write_46924 fb_write 3 46924 NULL
105929 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
105930 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
105931 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
105932 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
105933 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
105934 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
105935 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
105936 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
105937 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
105938 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
105939 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
105940 +__map_single_47020 __map_single 3-4-7 47020 NULL
105941 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
105942 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
105943 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
105944 +fs_path_len_47060 fs_path_len 0 47060 NULL
105945 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
105946 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
105947 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
105948 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
105949 +mousedev_read_47123 mousedev_read 3 47123 NULL
105950 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
105951 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
105952 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
105953 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
105954 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
105955 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
105956 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
105957 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
105958 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
105959 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
105960 +l2headersize_47238 l2headersize 0 47238 NULL
105961 +options_write_47243 options_write 3 47243 NULL
105962 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
105963 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
105964 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
105965 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
105966 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
105967 +vsnprintf_47291 vsnprintf 0 47291 NULL
105968 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
105969 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
105970 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
105971 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
105972 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
105973 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
105974 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
105975 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
105976 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
105977 +nametbl_list_47391 nametbl_list 2 47391 NULL
105978 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
105979 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
105980 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
105981 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
105982 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
105983 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
105984 +vzalloc_47421 vzalloc 1 47421 NULL
105985 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
105986 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
105987 +__load_mapping_47460 __load_mapping 2 47460 NULL
105988 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
105989 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
105990 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
105991 +core_sys_select_47494 core_sys_select 1 47494 NULL
105992 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
105993 +unlink_simple_47506 unlink_simple 3 47506 NULL
105994 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
105995 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
105996 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
105997 +oz_events_read_47535 oz_events_read 3 47535 NULL
105998 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
105999 +read_ldt_47570 read_ldt 2 47570 NULL
106000 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106001 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106002 +pci_iomap_47575 pci_iomap 3 47575 NULL
106003 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106004 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106005 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106006 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106007 +uea_request_47613 uea_request 4 47613 NULL
106008 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106009 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106010 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106011 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106012 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106013 +save_microcode_47717 save_microcode 3 47717 NULL
106014 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106015 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106016 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106017 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106018 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106019 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106020 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106021 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106022 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106023 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106024 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106025 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106026 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106027 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106028 +vhci_read_47878 vhci_read 3 47878 NULL
106029 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106030 +load_mapping_47904 load_mapping 3 47904 NULL
106031 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106032 +comedi_write_47926 comedi_write 3 47926 NULL
106033 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106034 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106035 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106036 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106037 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106038 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106039 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106040 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106041 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106042 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106043 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106044 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106045 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106046 +disc_write_48070 disc_write 3 48070 NULL
106047 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106048 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106049 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106050 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106051 +set_discoverable_48141 set_discoverable 4 48141 NULL
106052 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106053 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106054 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106055 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106056 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106057 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106058 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106059 +init_ipath_48187 init_ipath 1 48187 NULL
106060 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106061 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106062 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106063 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106064 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106065 +read_file_recv_48232 read_file_recv 3 48232 NULL
106066 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106067 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106068 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106069 +send_set_info_48288 send_set_info 7 48288 NULL
106070 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106071 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106072 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106073 +hash_setkey_48310 hash_setkey 3 48310 NULL
106074 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106075 +skb_add_data_48363 skb_add_data 3 48363 NULL
106076 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106077 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106078 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106079 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106080 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106081 +print_filtered_48442 print_filtered 2-0 48442 NULL
106082 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106083 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106084 +send_control_msg_48498 send_control_msg 6 48498 NULL
106085 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106086 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106087 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106088 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106089 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106090 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106091 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106092 +named_distribute_48544 named_distribute 4 48544 NULL
106093 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106094 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106095 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106096 +mtd_read_48655 mtd_read 0 48655 NULL
106097 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106098 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106099 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106100 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
106101 +altera_drscan_48698 altera_drscan 2 48698 NULL
106102 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
106103 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
106104 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
106105 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
106106 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
106107 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
106108 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
106109 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
106110 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
106111 +azx_get_position_48841 azx_get_position 0 48841 NULL
106112 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
106113 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
106114 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
106115 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
106116 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
106117 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
106118 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
106119 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
106120 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
106121 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
106122 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
106123 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
106124 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
106125 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
106126 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
106127 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
106128 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
106129 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
106130 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
106131 +transient_status_49027 transient_status 4 49027 NULL
106132 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
106133 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
106134 +ubi_read_49061 ubi_read 0 49061 NULL
106135 +scsi_register_49094 scsi_register 2 49094 NULL
106136 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
106137 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
106138 +check_exists_49119 check_exists 2 49119 NULL nohasharray
106139 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
106140 +pt_read_49136 pt_read 3 49136 NULL
106141 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
106142 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
106143 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
106144 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
106145 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
106146 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
106147 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
106148 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
106149 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
106150 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
106151 +resp_write_same_49217 resp_write_same 2 49217 NULL
106152 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
106153 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
106154 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
106155 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
106156 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
106157 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
106158 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
106159 +uio_read_49300 uio_read 3 49300 NULL
106160 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
106161 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
106162 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
106163 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
106164 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
106165 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
106166 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
106167 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
106168 +px_raw_event_49371 px_raw_event 4 49371 NULL
106169 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
106170 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
106171 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
106172 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
106173 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
106174 +md_domain_init_49432 md_domain_init 2 49432 NULL
106175 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
106176 +get_lru_size_49441 get_lru_size 0 49441 NULL
106177 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
106178 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
106179 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
106180 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
106181 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
106182 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
106183 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
106184 +smk_write_access_49561 smk_write_access 3 49561 NULL
106185 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
106186 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
106187 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
106188 +tap_write_49595 tap_write 3 49595 NULL
106189 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
106190 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
106191 +heap_init_49617 heap_init 2 49617 NULL
106192 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
106193 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
106194 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
106195 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
106196 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
106197 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
106198 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
106199 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
106200 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
106201 +check_frame_49741 check_frame 0 49741 NULL
106202 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
106203 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
106204 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
106205 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
106206 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
106207 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
106208 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
106209 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
106210 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
106211 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
106212 +add_uuid_49831 add_uuid 4 49831 NULL
106213 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
106214 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
106215 +twl4030_write_49846 twl4030_write 2 49846 NULL
106216 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
106217 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
106218 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
106219 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
106220 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
106221 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
106222 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
106223 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
106224 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
106225 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
106226 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
106227 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
106228 +__module_alloc_50004 __module_alloc 1 50004 NULL
106229 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
106230 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
106231 +isdn_read_50021 isdn_read 3 50021 NULL
106232 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
106233 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
106234 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
106235 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
106236 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
106237 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
106238 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
106239 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
106240 +read_file_slot_50111 read_file_slot 3 50111 NULL
106241 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
106242 +copy_items_50140 copy_items 6 50140 NULL
106243 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
106244 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
106245 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
106246 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
106247 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
106248 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
106249 +odev_update_50169 odev_update 2 50169 NULL
106250 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
106251 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
106252 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
106253 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
106254 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
106255 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
106256 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
106257 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
106258 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
106259 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
106260 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
106261 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
106262 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
106263 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
106264 +do_launder_page_50329 do_launder_page 0 50329 NULL
106265 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
106266 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
106267 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
106268 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
106269 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
106270 +tpm_read_50344 tpm_read 3 50344 NULL
106271 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
106272 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
106273 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
106274 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
106275 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
106276 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
106277 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
106278 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
106279 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
106280 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
106281 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
106282 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
106283 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
106284 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
106285 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
106286 +force_mapping_50464 force_mapping 2 50464 NULL
106287 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
106288 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
106289 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
106290 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
106291 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
106292 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
106293 +fat_readpages_50582 fat_readpages 4 50582 NULL
106294 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
106295 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
106296 +sge_rx_50594 sge_rx 3 50594 NULL
106297 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
106298 +__ffs_50625 __ffs 0 50625 NULL
106299 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
106300 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
106301 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
106302 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
106303 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
106304 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
106305 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
106306 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
106307 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
106308 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
106309 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
106310 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
106311 +skb_padto_50759 skb_padto 2 50759 NULL
106312 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
106313 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
106314 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
106315 +tpm_write_50798 tpm_write 3 50798 NULL
106316 +write_flush_50803 write_flush 3 50803 NULL
106317 +dvb_play_50814 dvb_play 3 50814 NULL
106318 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
106319 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
106320 +SetArea_50835 SetArea 4 50835 NULL nohasharray
106321 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
106322 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
106323 +self_check_write_50856 self_check_write 5 50856 NULL
106324 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
106325 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
106326 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
106327 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
106328 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
106329 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
106330 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
106331 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
106332 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
106333 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
106334 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
106335 +timeout_write_50991 timeout_write 3 50991 NULL
106336 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
106337 +proc_write_51003 proc_write 3 51003 NULL
106338 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
106339 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
106340 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
106341 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
106342 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
106343 +dump_midi_51040 dump_midi 3 51040 NULL
106344 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
106345 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
106346 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
106347 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
106348 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
106349 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
106350 +ti_recv_51110 ti_recv 3 51110 NULL
106351 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
106352 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
106353 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
106354 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
106355 +set_dirty_51144 set_dirty 3 51144 NULL
106356 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
106357 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
106358 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
106359 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
106360 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
106361 +tipc_send_51238 tipc_send 4 51238 NULL
106362 +drm_property_create_51239 drm_property_create 4 51239 NULL
106363 +st_read_51251 st_read 3 51251 NULL
106364 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
106365 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
106366 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
106367 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
106368 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
106369 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
106370 +get_cell_51316 get_cell 2 51316 NULL
106371 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
106372 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
106373 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
106374 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
106375 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
106376 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
106377 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
106378 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
106379 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
106380 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
106381 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
106382 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
106383 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
106384 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
106385 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
106386 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
106387 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
106388 +vaddr_51480 vaddr 0 51480 NULL
106389 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
106390 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
106391 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
106392 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
106393 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
106394 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
106395 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
106396 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
106397 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
106398 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
106399 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
106400 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
106401 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
106402 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
106403 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
106404 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
106405 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
106406 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
106407 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
106408 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
106409 +sel_write_access_51704 sel_write_access 3 51704 NULL
106410 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
106411 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
106412 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
106413 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
106414 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
106415 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
106416 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
106417 +if_write_51756 if_write 3 51756 NULL
106418 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
106419 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
106420 +to_ratio_51809 to_ratio 2-1 51809 NULL
106421 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
106422 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
106423 +ioread32_51847 ioread32 0 51847 NULL nohasharray
106424 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
106425 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
106426 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
106427 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
106428 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
106429 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
106430 +user_read_51881 user_read 3 51881 NULL
106431 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
106432 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
106433 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
106434 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
106435 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
106436 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
106437 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
106438 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
106439 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
106440 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
106441 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
106442 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
106443 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
106444 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
106445 +rdmalt_52022 rdmalt 0 52022 NULL
106446 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
106447 +override_release_52032 override_release 2 52032 NULL
106448 +end_port_52042 end_port 0 52042 NULL
106449 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
106450 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
106451 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
106452 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
106453 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
106454 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
106455 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
106456 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
106457 +retry_count_read_52129 retry_count_read 3 52129 NULL
106458 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
106459 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
106460 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
106461 +htable_size_52148 htable_size 0-1 52148 NULL
106462 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
106463 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
106464 +alix_present_52165 alix_present 1 52165 NULL
106465 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
106466 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
106467 +print_prefix_52176 print_prefix 0 52176 NULL
106468 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
106469 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
106470 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
106471 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
106472 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
106473 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
106474 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
106475 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
106476 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
106477 +atomic64_read_52300 atomic64_read 0 52300 NULL
106478 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
106479 +read_file_reset_52310 read_file_reset 3 52310 NULL
106480 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
106481 +hwflags_read_52318 hwflags_read 3 52318 NULL
106482 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
106483 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
106484 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
106485 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
106486 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
106487 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
106488 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
106489 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
106490 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
106491 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
106492 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
106493 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
106494 +delay_status_52431 delay_status 5 52431 NULL
106495 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
106496 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
106497 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
106498 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
106499 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
106500 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
106501 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
106502 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
106503 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
106504 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
106505 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
106506 +from_oblock_52546 from_oblock 0-1 52546 NULL
106507 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
106508 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
106509 +emit_code_52583 emit_code 0-3 52583 NULL
106510 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
106511 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
106512 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
106513 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
106514 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
106515 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
106516 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
106517 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
106518 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
106519 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
106520 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
106521 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
106522 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
106523 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
106524 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
106525 +twlreg_write_52880 twlreg_write 3 52880 NULL
106526 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
106527 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
106528 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
106529 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
106530 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
106531 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
106532 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
106533 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
106534 +send_packet_52960 send_packet 4 52960 NULL
106535 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
106536 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
106537 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
106538 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
106539 +num_node_state_52989 num_node_state 0 52989 NULL
106540 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
106541 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
106542 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
106543 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
106544 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
106545 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
106546 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
106547 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
106548 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
106549 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
106550 +verity_status_53120 verity_status 5 53120 NULL
106551 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
106552 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
106553 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
106554 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
106555 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
106556 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
106557 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
106558 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
106559 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
106560 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
106561 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
106562 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
106563 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
106564 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
106565 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
106566 +vm_mmap_53339 vm_mmap 0 53339 NULL
106567 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
106568 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
106569 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
106570 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
106571 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
106572 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
106573 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
106574 +n2_run_53459 n2_run 3 53459 NULL
106575 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
106576 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
106577 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
106578 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
106579 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
106580 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
106581 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
106582 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
106583 +check_acl_53512 check_acl 0 53512 NULL
106584 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
106585 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
106586 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
106587 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
106588 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
106589 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
106590 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
106591 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
106592 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
106593 +_preload_range_53676 _preload_range 2-3 53676 NULL
106594 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
106595 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
106596 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
106597 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
106598 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
106599 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
106600 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
106601 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
106602 +wdm_write_53735 wdm_write 3 53735 NULL
106603 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
106604 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
106605 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
106606 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
106607 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
106608 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
106609 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
106610 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
106611 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
106612 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
106613 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
106614 +pms_read_53873 pms_read 3 53873 NULL
106615 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
106616 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
106617 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
106618 +proc_file_read_53905 proc_file_read 3 53905 NULL
106619 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
106620 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
106621 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
106622 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
106623 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
106624 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
106625 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
106626 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
106627 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
106628 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
106629 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
106630 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
106631 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
106632 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
106633 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
106634 +_malloc_54077 _malloc 1 54077 NULL
106635 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
106636 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
106637 +create_xattr_54106 create_xattr 5 54106 NULL
106638 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
106639 +strn_len_54122 strn_len 0 54122 NULL
106640 +isku_receive_54130 isku_receive 4 54130 NULL
106641 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
106642 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
106643 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
106644 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
106645 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
106646 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
106647 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
106648 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
106649 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
106650 +reada_add_block_54247 reada_add_block 2 54247 NULL
106651 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
106652 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
106653 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
106654 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
106655 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
106656 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
106657 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
106658 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
106659 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
106660 +sprintf_54306 sprintf 0 54306 NULL
106661 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
106662 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
106663 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
106664 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
106665 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
106666 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
106667 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
106668 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
106669 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
106670 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
106671 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
106672 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
106673 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
106674 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
106675 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
106676 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
106677 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
106678 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
106679 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
106680 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
106681 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
106682 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
106683 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
106684 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
106685 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
106686 +viacam_read_54526 viacam_read 3 54526 NULL
106687 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
106688 +setsockopt_54539 setsockopt 5 54539 NULL
106689 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
106690 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
106691 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
106692 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
106693 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
106694 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
106695 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
106696 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
106697 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
106698 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
106699 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
106700 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
106701 +evm_read_key_54674 evm_read_key 3 54674 NULL
106702 +resource_string_54699 resource_string 0 54699 NULL
106703 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
106704 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
106705 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
106706 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
106707 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
106708 +kzalloc_54740 kzalloc 1 54740 NULL
106709 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
106710 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
106711 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
106712 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
106713 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
106714 +domain_init_54797 domain_init 2 54797 NULL
106715 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
106716 +get_dev_size_54807 get_dev_size 0 54807 NULL
106717 +nfsd_write_54809 nfsd_write 6 54809 NULL
106718 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
106719 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
106720 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
106721 +write_rio_54837 write_rio 3 54837 NULL
106722 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
106723 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
106724 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
106725 +printer_read_54851 printer_read 3 54851 NULL
106726 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
106727 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
106728 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
106729 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
106730 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
106731 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
106732 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
106733 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
106734 +add_port_54941 add_port 2 54941 NULL
106735 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
106736 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
106737 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
106738 +c4_add_card_54968 c4_add_card 3 54968 NULL
106739 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
106740 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
106741 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
106742 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
106743 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
106744 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
106745 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
106746 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
106747 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
106748 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
106749 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
106750 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
106751 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
106752 +corrupt_data_55120 corrupt_data 0 55120 NULL
106753 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
106754 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
106755 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
106756 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
106757 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
106758 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
106759 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
106760 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
106761 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
106762 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
106763 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
106764 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
106765 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
106766 +dump_command_55220 dump_command 1 55220 NULL
106767 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
106768 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
106769 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
106770 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
106771 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
106772 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
106773 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
106774 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
106775 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
106776 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
106777 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
106778 +do_shmat_55336 do_shmat 5 55336 NULL
106779 +vme_user_read_55338 vme_user_read 3 55338 NULL
106780 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
106781 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
106782 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
106783 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
106784 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
106785 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
106786 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
106787 +alloc_skb_55439 alloc_skb 1 55439 NULL
106788 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
106789 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
106790 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
106791 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
106792 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
106793 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
106794 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
106795 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
106796 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
106797 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
106798 +ea_get_55522 ea_get 0 55522 NULL
106799 +buffer_size_55534 buffer_size 0 55534 NULL
106800 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
106801 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
106802 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
106803 +add_partition_55588 add_partition 2 55588 NULL
106804 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
106805 +free_pages_55603 free_pages 1 55603 NULL
106806 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
106807 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
106808 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
106809 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
106810 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
106811 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
106812 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
106813 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
106814 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
106815 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
106816 +read_oldmem_55658 read_oldmem 3 55658 NULL
106817 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
106818 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
106819 +get_info_55681 get_info 3 55681 NULL
106820 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
106821 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
106822 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
106823 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
106824 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
106825 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
106826 +set_local_name_55757 set_local_name 4 55757 NULL
106827 +strlen_55778 strlen 0 55778 NULL
106828 +set_spte_55783 set_spte 5-4 55783 NULL
106829 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
106830 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
106831 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
106832 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
106833 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
106834 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
106835 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
106836 +hsc_write_55875 hsc_write 3 55875 NULL
106837 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
106838 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
106839 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
106840 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
106841 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
106842 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
106843 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
106844 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
106845 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
106846 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
106847 +__set_discard_56081 __set_discard 2 56081 NULL
106848 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
106849 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
106850 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
106851 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
106852 +map_addr_56144 map_addr 7 56144 NULL
106853 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
106854 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
106855 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
106856 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
106857 +skb_headroom_56200 skb_headroom 0 56200 NULL
106858 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
106859 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
106860 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
106861 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
106862 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
106863 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
106864 +fd_copyin_56247 fd_copyin 3 56247 NULL
106865 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
106866 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
106867 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
106868 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
106869 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
106870 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
106871 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
106872 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
106873 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
106874 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
106875 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
106876 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
106877 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
106878 +dev_read_56369 dev_read 3 56369 NULL
106879 +write_gssp_56404 write_gssp 3 56404 NULL
106880 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
106881 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
106882 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
106883 +store_msg_56417 store_msg 3 56417 NULL
106884 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
106885 +fl_create_56435 fl_create 5 56435 NULL
106886 +gnttab_map_56439 gnttab_map 2 56439 NULL
106887 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
106888 +set_connectable_56458 set_connectable 4 56458 NULL
106889 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
106890 +putused_user_56467 putused_user 3 56467 NULL
106891 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
106892 +global_rt_period_56476 global_rt_period 0 56476 NULL
106893 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
106894 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
106895 +init_map_ip_56508 init_map_ip 5 56508 NULL
106896 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
106897 +ip_options_get_56538 ip_options_get 4 56538 NULL
106898 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
106899 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
106900 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
106901 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
106902 +event_filter_write_56609 event_filter_write 3 56609 NULL
106903 +gather_array_56641 gather_array 3 56641 NULL
106904 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
106905 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
106906 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
106907 +build_map_info_56696 build_map_info 2 56696 NULL
106908 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
106909 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
106910 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
106911 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
106912 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
106913 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
106914 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
106915 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
106916 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
106917 +hash_lookup_56792 hash_lookup 2 56792 NULL
106918 +do_syslog_56807 do_syslog 3 56807 NULL
106919 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
106920 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
106921 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
106922 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
106923 +wb_lookup_56858 wb_lookup 2 56858 NULL
106924 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
106925 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
106926 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
106927 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
106928 +strcspn_56913 strcspn 0 56913 NULL
106929 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
106930 +check_header_56930 check_header 2 56930 NULL
106931 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
106932 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
106933 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
106934 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
106935 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
106936 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
106937 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
106938 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
106939 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
106940 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
106941 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
106942 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
106943 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
106944 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
106945 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
106946 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
106947 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
106948 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
106949 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
106950 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
106951 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
106952 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
106953 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
106954 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
106955 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
106956 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
106957 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
106958 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
106959 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
106960 +flush_space_57241 flush_space 3 57241 NULL
106961 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
106962 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
106963 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
106964 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
106965 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
106966 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
106967 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
106968 +fw_file_size_57307 fw_file_size 0 57307 NULL
106969 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
106970 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
106971 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
106972 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
106973 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
106974 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
106975 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
106976 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
106977 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
106978 +read_file_blob_57406 read_file_blob 3 57406 NULL
106979 +enclosure_register_57412 enclosure_register 3 57412 NULL
106980 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
106981 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
106982 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
106983 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
106984 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
106985 +ReadReg_57453 ReadReg 0 57453 NULL
106986 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
106987 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
106988 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
106989 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
106990 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
106991 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
106992 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
106993 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
106994 +skb_headlen_57501 skb_headlen 0 57501 NULL
106995 +copy_in_user_57502 copy_in_user 3 57502 NULL
106996 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
106997 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
106998 +init_tag_map_57515 init_tag_map 3 57515 NULL
106999 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107000 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107001 +inode_permission_57531 inode_permission 0 57531 NULL
107002 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107003 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107004 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107005 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107006 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107007 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107008 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107009 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107010 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107011 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107012 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107013 +mem_read_57631 mem_read 3 57631 NULL
107014 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107015 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107016 +r3964_write_57662 r3964_write 4 57662 NULL
107017 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107018 +__lgwrite_57669 __lgwrite 4 57669 NULL
107019 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107020 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107021 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107022 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107023 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107024 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107025 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107026 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107027 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107028 +ld2_57794 ld2 0 57794 NULL
107029 +ivtv_read_57796 ivtv_read 3 57796 NULL
107030 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107031 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107032 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107033 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107034 +copy_to_user_57835 copy_to_user 3 57835 NULL
107035 +flash_read_57843 flash_read 3 57843 NULL
107036 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107037 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107038 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107039 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107040 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107041 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107042 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107043 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107044 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107045 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107046 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107047 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107048 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107049 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107050 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107051 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107052 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107053 +mce_async_out_58056 mce_async_out 3 58056 NULL
107054 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107055 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107056 +cm4040_write_58079 cm4040_write 3 58079 NULL
107057 +udi_log_event_58105 udi_log_event 3 58105 NULL
107058 +savemem_58129 savemem 3 58129 NULL
107059 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107060 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107061 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107062 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107063 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107064 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107065 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107066 +read_file_debug_58256 read_file_debug 3 58256 NULL
107067 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107068 +profile_load_58267 profile_load 3 58267 NULL
107069 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107070 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107071 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107072 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107073 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107074 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107075 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107076 +next_pidmap_58347 next_pidmap 2 58347 NULL
107077 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107078 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107079 +save_hint_58359 save_hint 2 58359 NULL
107080 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107081 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107082 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107083 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107084 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107085 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107086 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107087 +capabilities_read_58457 capabilities_read 3 58457 NULL
107088 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107089 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107090 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107091 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107092 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107093 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107094 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107095 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107096 +__clear_discard_58546 __clear_discard 2 58546 NULL
107097 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107098 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107099 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107100 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
107101 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
107102 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
107103 +xip_file_read_58592 xip_file_read 3 58592 NULL
107104 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
107105 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
107106 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
107107 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
107108 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
107109 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
107110 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
107111 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
107112 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
107113 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
107114 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
107115 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
107116 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
107117 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
107118 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
107119 +acpi_map_58725 acpi_map 1-2 58725 NULL
107120 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
107121 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
107122 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
107123 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
107124 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
107125 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
107126 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
107127 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
107128 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
107129 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
107130 +ep_read_58813 ep_read 3 58813 NULL
107131 +command_write_58841 command_write 3 58841 NULL
107132 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
107133 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
107134 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
107135 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
107136 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
107137 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
107138 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
107139 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
107140 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
107141 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
107142 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
107143 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
107144 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
107145 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
107146 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
107147 +ep_write_59008 ep_write 3 59008 NULL
107148 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
107149 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
107150 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
107151 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
107152 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
107153 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
107154 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
107155 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
107156 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
107157 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
107158 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
107159 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
107160 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
107161 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
107162 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
107163 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
107164 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
107165 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
107166 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
107167 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
107168 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
107169 +dt3155_read_59226 dt3155_read 3 59226 NULL
107170 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
107171 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
107172 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
107173 +nla_len_59258 nla_len 0 59258 NULL
107174 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
107175 +fd_copyout_59323 fd_copyout 3 59323 NULL
107176 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
107177 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
107178 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
107179 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
107180 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
107181 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
107182 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
107183 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
107184 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
107185 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
107186 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
107187 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
107188 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
107189 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
107190 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
107191 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
107192 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
107193 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
107194 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
107195 +tunables_write_59563 tunables_write 3 59563 NULL
107196 +memdup_user_59590 memdup_user 2 59590 NULL
107197 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
107198 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
107199 +mtrr_write_59622 mtrr_write 3 59622 NULL
107200 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
107201 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
107202 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
107203 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
107204 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
107205 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
107206 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
107207 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
107208 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
107209 +sriov_enable_59689 sriov_enable 2 59689 NULL
107210 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
107211 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
107212 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
107213 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
107214 +strnlen_59746 strnlen 0 59746 NULL
107215 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
107216 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
107217 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
107218 +venus_remove_59781 venus_remove 4 59781 NULL
107219 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
107220 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
107221 +ipw_write_59807 ipw_write 3 59807 NULL
107222 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
107223 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
107224 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
107225 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
107226 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
107227 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
107228 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
107229 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
107230 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
107231 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
107232 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
107233 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
107234 +lookup_node_59953 lookup_node 2 59953 NULL
107235 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
107236 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
107237 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
107238 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
107239 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
107240 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
107241 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
107242 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
107243 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
107244 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
107245 +register_device_60015 register_device 2-3 60015 NULL
107246 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
107247 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
107248 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
107249 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
107250 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
107251 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
107252 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
107253 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
107254 +compat_writev_60063 compat_writev 3 60063 NULL
107255 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
107256 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
107257 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
107258 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
107259 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
107260 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
107261 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
107262 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
107263 +init_state_60165 init_state 2 60165 NULL
107264 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
107265 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
107266 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
107267 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
107268 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
107269 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
107270 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
107271 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
107272 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
107273 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
107274 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
107275 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
107276 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
107277 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
107278 +printer_write_60276 printer_write 3 60276 NULL
107279 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
107280 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
107281 +getDataLength_60301 getDataLength 0 60301 NULL
107282 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
107283 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
107284 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
107285 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
107286 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
107287 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
107288 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
107289 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
107290 +driver_names_read_60399 driver_names_read 3 60399 NULL
107291 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
107292 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
107293 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
107294 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
107295 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
107296 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
107297 +rx_data_60442 rx_data 4 60442 NULL nohasharray
107298 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
107299 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
107300 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
107301 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
107302 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
107303 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
107304 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
107305 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
107306 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
107307 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
107308 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
107309 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
107310 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
107311 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
107312 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
107313 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
107314 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
107315 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
107316 +init_data_container_60709 init_data_container 1 60709 NULL
107317 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
107318 +raid_status_60755 raid_status 5 60755 NULL
107319 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
107320 +opticon_write_60775 opticon_write 4 60775 NULL
107321 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
107322 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
107323 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
107324 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
107325 +generic_writepages_60871 generic_writepages 0 60871 NULL
107326 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
107327 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
107328 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
107329 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
107330 +sys_mlock_60932 sys_mlock 1 60932 NULL
107331 +pti_char_write_60960 pti_char_write 3 60960 NULL
107332 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
107333 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
107334 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
107335 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
107336 +symtab_init_61050 symtab_init 2 61050 NULL
107337 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
107338 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
107339 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
107340 +get_derived_key_61100 get_derived_key 4 61100 NULL
107341 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
107342 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
107343 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
107344 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
107345 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
107346 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
107347 +__vmalloc_61168 __vmalloc 1 61168 NULL
107348 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
107349 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
107350 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
107351 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
107352 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
107353 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
107354 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
107355 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
107356 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
107357 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
107358 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
107359 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
107360 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
107361 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
107362 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
107363 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
107364 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
107365 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
107366 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
107367 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
107368 +change_xattr_61390 change_xattr 5 61390 NULL
107369 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
107370 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
107371 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
107372 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
107373 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
107374 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
107375 +erst_errno_61526 erst_errno 0 61526 NULL
107376 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
107377 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
107378 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
107379 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
107380 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
107381 +seq_open_private_61589 seq_open_private 3 61589 NULL
107382 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
107383 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
107384 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
107385 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
107386 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
107387 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
107388 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
107389 +resize_stripes_61650 resize_stripes 2 61650 NULL
107390 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
107391 +insert_one_name_61668 insert_one_name 7 61668 NULL
107392 +lock_loop_61681 lock_loop 1 61681 NULL
107393 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
107394 +filter_read_61692 filter_read 3 61692 NULL
107395 +iov_length_61716 iov_length 0 61716 NULL
107396 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
107397 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
107398 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
107399 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
107400 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
107401 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
107402 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
107403 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
107404 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
107405 +get_fw_name_61874 get_fw_name 3 61874 NULL
107406 +free_init_pages_61875 free_init_pages 2 61875 NULL
107407 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
107408 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
107409 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
107410 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
107411 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
107412 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
107413 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
107414 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
107415 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
107416 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
107417 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
107418 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
107419 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
107420 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
107421 +cow_file_range_61979 cow_file_range 3 61979 NULL
107422 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
107423 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
107424 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
107425 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
107426 +SYSC_select_62024 SYSC_select 1 62024 NULL
107427 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
107428 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
107429 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
107430 +do_pselect_62061 do_pselect 1 62061 NULL
107431 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
107432 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
107433 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
107434 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
107435 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
107436 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
107437 +ql_status_62135 ql_status 5 62135 NULL
107438 +video_usercopy_62151 video_usercopy 2 62151 NULL
107439 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
107440 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
107441 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
107442 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
107443 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
107444 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
107445 +allocate_partition_62245 allocate_partition 4 62245 NULL
107446 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
107447 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
107448 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
107449 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
107450 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
107451 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
107452 +subseq_list_62332 subseq_list 3-0 62332 NULL
107453 +flash_write_62354 flash_write 3 62354 NULL
107454 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
107455 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
107456 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
107457 +altera_irscan_62396 altera_irscan 2 62396 NULL
107458 +set_ssp_62411 set_ssp 4 62411 NULL
107459 +unmap_single_62423 unmap_single 2 62423 NULL
107460 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
107461 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
107462 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
107463 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
107464 +remove_mapping_62491 remove_mapping 2 62491 NULL
107465 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
107466 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
107467 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
107468 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
107469 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
107470 +debugfs_read_62535 debugfs_read 3 62535 NULL
107471 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
107472 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
107473 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
107474 +get_subdir_62581 get_subdir 3 62581 NULL
107475 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
107476 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
107477 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
107478 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
107479 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
107480 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
107481 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
107482 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
107483 +write_62671 write 3 62671 NULL
107484 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
107485 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
107486 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
107487 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
107488 +rdm_62719 rdm 0 62719 NULL
107489 +key_replays_read_62746 key_replays_read 3 62746 NULL
107490 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
107491 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
107492 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
107493 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
107494 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
107495 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
107496 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
107497 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
107498 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
107499 +set_swbp_62853 set_swbp 3 62853 NULL
107500 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
107501 +aoechr_write_62883 aoechr_write 3 62883 NULL
107502 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
107503 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
107504 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
107505 +getdqbuf_62908 getdqbuf 1 62908 NULL
107506 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
107507 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
107508 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
107509 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
107510 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
107511 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
107512 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
107513 +unlink1_63059 unlink1 3 63059 NULL
107514 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
107515 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
107516 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
107517 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
107518 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
107519 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
107520 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
107521 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
107522 +vme_master_read_63221 vme_master_read 0 63221 NULL
107523 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
107524 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
107525 +ptp_read_63251 ptp_read 4 63251 NULL
107526 +raid5_resize_63306 raid5_resize 2 63306 NULL
107527 +proc_info_read_63344 proc_info_read 3 63344 NULL
107528 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
107529 +idmouse_read_63374 idmouse_read 3 63374 NULL
107530 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
107531 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
107532 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
107533 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
107534 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
107535 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
107536 +kone_send_63435 kone_send 4 63435 NULL
107537 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
107538 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
107539 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
107540 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
107541 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
107542 +read_kcore_63488 read_kcore 3 63488 NULL
107543 +save_hint_63497 save_hint 2 63497 NULL
107544 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
107545 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
107546 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
107547 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
107548 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
107549 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
107550 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
107551 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
107552 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
107553 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
107554 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
107555 +module_alloc_63630 module_alloc 1 63630 NULL
107556 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
107557 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
107558 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
107559 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
107560 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
107561 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
107562 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
107563 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
107564 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
107565 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
107566 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
107567 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
107568 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
107569 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
107570 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
107571 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
107572 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
107573 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
107574 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
107575 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
107576 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
107577 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
107578 +prepare_copy_63826 prepare_copy 2 63826 NULL
107579 +sel_write_load_63830 sel_write_load 3 63830 NULL
107580 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
107581 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
107582 +divas_write_63901 divas_write 3 63901 NULL
107583 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
107584 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
107585 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
107586 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
107587 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
107588 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
107589 +__team_options_register_63941 __team_options_register 3 63941 NULL
107590 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
107591 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
107592 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
107593 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
107594 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
107595 +kmemdup_64015 kmemdup 2 64015 NULL
107596 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
107597 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
107598 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
107599 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
107600 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
107601 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
107602 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
107603 +get_u8_64076 get_u8 0 64076 NULL
107604 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
107605 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
107606 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
107607 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
107608 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
107609 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
107610 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
107611 +init_bch_64130 init_bch 1-2 64130 NULL
107612 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
107613 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
107614 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
107615 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
107616 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
107617 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
107618 +read_pulse_64227 read_pulse 0-3 64227 NULL
107619 +header_len_64232 header_len 0 64232 NULL
107620 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
107621 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
107622 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
107623 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
107624 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
107625 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
107626 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
107627 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
107628 +ffz_64324 ffz 0 64324 NULL
107629 +map_region_64328 map_region 1 64328 NULL
107630 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
107631 +ts_write_64336 ts_write 3 64336 NULL
107632 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
107633 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
107634 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
107635 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
107636 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
107637 +ilo_write_64378 ilo_write 3 64378 NULL
107638 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
107639 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
107640 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
107641 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
107642 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
107643 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
107644 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
107645 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
107646 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
107647 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
107648 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
107649 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
107650 +cap_capable_64462 cap_capable 0 64462 NULL
107651 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
107652 +single_open_size_64483 single_open_size 4 64483 NULL
107653 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
107654 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
107655 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
107656 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
107657 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
107658 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
107659 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
107660 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
107661 +SyS_bind_64544 SyS_bind 3 64544 NULL
107662 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
107663 +__spi_sync_64561 __spi_sync 0 64561 NULL
107664 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
107665 +fanotify_write_64623 fanotify_write 3 64623 NULL
107666 +to_dblock_64655 to_dblock 0-1 64655 NULL
107667 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
107668 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
107669 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
107670 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
107671 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
107672 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
107673 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
107674 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
107675 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
107676 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
107677 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
107678 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
107679 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
107680 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
107681 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
107682 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
107683 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
107684 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
107685 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
107686 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
107687 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
107688 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
107689 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
107690 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
107691 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
107692 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
107693 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
107694 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
107695 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
107696 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
107697 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
107698 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
107699 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
107700 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
107701 +pskb_pull_65005 pskb_pull 2 65005 NULL
107702 +unifi_write_65012 unifi_write 3 65012 NULL
107703 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
107704 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
107705 +insert_dent_65034 insert_dent 7 65034 NULL
107706 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
107707 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
107708 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
107709 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
107710 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
107711 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
107712 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
107713 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
107714 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
107715 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
107716 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
107717 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
107718 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
107719 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
107720 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
107721 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
107722 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
107723 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
107724 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
107725 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
107726 +get_var_len_65304 get_var_len 0 65304 NULL
107727 +unpack_array_65318 unpack_array 0 65318 NULL
107728 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
107729 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
107730 +init_list_set_65351 init_list_set 2-3 65351 NULL
107731 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
107732 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
107733 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
107734 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
107735 +strchr_65372 strchr 0 65372 NULL nohasharray
107736 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
107737 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
107738 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
107739 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
107740 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
107741 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
107742 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
107743 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
107744 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
107745 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
107746 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
107747 +alloc_dr_65495 alloc_dr 2 65495 NULL
107748 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
107749 new file mode 100644
107750 index 0000000..03d0c84
107751 --- /dev/null
107752 +++ b/tools/gcc/size_overflow_plugin.c
107753 @@ -0,0 +1,2113 @@
107754 +/*
107755 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
107756 + * Licensed under the GPL v2, or (at your option) v3
107757 + *
107758 + * Homepage:
107759 + * http://www.grsecurity.net/~ephox/overflow_plugin/
107760 + *
107761 + * Documentation:
107762 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
107763 + *
107764 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
107765 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
107766 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
107767 + *
107768 + * Usage:
107769 + * $ 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
107770 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
107771 + */
107772 +
107773 +#include "gcc-plugin.h"
107774 +#include "config.h"
107775 +#include "system.h"
107776 +#include "coretypes.h"
107777 +#include "tree.h"
107778 +#include "tree-pass.h"
107779 +#include "intl.h"
107780 +#include "plugin-version.h"
107781 +#include "tm.h"
107782 +#include "toplev.h"
107783 +#include "function.h"
107784 +#include "tree-flow.h"
107785 +#include "plugin.h"
107786 +#include "gimple.h"
107787 +#include "diagnostic.h"
107788 +#include "cfgloop.h"
107789 +
107790 +#if BUILDING_GCC_VERSION >= 4008
107791 +#define TODO_dump_func 0
107792 +#endif
107793 +
107794 +struct size_overflow_hash {
107795 + const struct size_overflow_hash * const next;
107796 + const char * const name;
107797 + const unsigned int param;
107798 +};
107799 +
107800 +#include "size_overflow_hash.h"
107801 +
107802 +enum mark {
107803 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
107804 +};
107805 +
107806 +enum err_code_conditions {
107807 + CAST_ONLY, FROM_CONST
107808 +};
107809 +
107810 +static unsigned int call_count = 0;
107811 +
107812 +#define __unused __attribute__((__unused__))
107813 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
107814 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
107815 +#define BEFORE_STMT true
107816 +#define AFTER_STMT false
107817 +#define CREATE_NEW_VAR NULL_TREE
107818 +#define CODES_LIMIT 32
107819 +#define MAX_PARAM 31
107820 +#define MY_STMT GF_PLF_1
107821 +#define NO_CAST_CHECK GF_PLF_2
107822 +#define FROM_ARG true
107823 +#define FROM_RET false
107824 +
107825 +#if BUILDING_GCC_VERSION == 4005
107826 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
107827 +#endif
107828 +
107829 +int plugin_is_GPL_compatible;
107830 +void debug_gimple_stmt(gimple gs);
107831 +
107832 +static tree expand(struct pointer_set_t *visited, tree lhs);
107833 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
107834 +static tree report_size_overflow_decl;
107835 +static const_tree const_char_ptr_type_node;
107836 +static unsigned int handle_function(void);
107837 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
107838 +static tree get_size_overflow_type(gimple stmt, const_tree node);
107839 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
107840 +static void print_missing_msg(tree func, unsigned int argnum);
107841 +
107842 +static struct plugin_info size_overflow_plugin_info = {
107843 + .version = "20130822beta",
107844 + .help = "no-size-overflow\tturn off size overflow checking\n",
107845 +};
107846 +
107847 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
107848 +{
107849 + unsigned int arg_count;
107850 + enum tree_code code = TREE_CODE(*node);
107851 +
107852 + switch (code) {
107853 + case FUNCTION_DECL:
107854 + arg_count = type_num_arguments(TREE_TYPE(*node));
107855 + break;
107856 + case FUNCTION_TYPE:
107857 + case METHOD_TYPE:
107858 + arg_count = type_num_arguments(*node);
107859 + break;
107860 + default:
107861 + *no_add_attrs = true;
107862 + error("%s: %qE attribute only applies to functions", __func__, name);
107863 + return NULL_TREE;
107864 + }
107865 +
107866 + for (; args; args = TREE_CHAIN(args)) {
107867 + tree position = TREE_VALUE(args);
107868 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
107869 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
107870 + *no_add_attrs = true;
107871 + }
107872 + }
107873 + return NULL_TREE;
107874 +}
107875 +
107876 +static const char* get_asm_name(tree node)
107877 +{
107878 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
107879 +}
107880 +
107881 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
107882 +{
107883 + unsigned int arg_count, arg_num;
107884 + enum tree_code code = TREE_CODE(*node);
107885 +
107886 + switch (code) {
107887 + case FUNCTION_DECL:
107888 + arg_count = type_num_arguments(TREE_TYPE(*node));
107889 + break;
107890 + case FUNCTION_TYPE:
107891 + case METHOD_TYPE:
107892 + arg_count = type_num_arguments(*node);
107893 + break;
107894 + case FIELD_DECL:
107895 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
107896 + if (arg_num != 0) {
107897 + *no_add_attrs = true;
107898 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
107899 + }
107900 + return NULL_TREE;
107901 + default:
107902 + *no_add_attrs = true;
107903 + error("%qE attribute only applies to functions", name);
107904 + return NULL_TREE;
107905 + }
107906 +
107907 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
107908 + return NULL_TREE;
107909 +
107910 + for (; args; args = TREE_CHAIN(args)) {
107911 + tree position = TREE_VALUE(args);
107912 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
107913 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
107914 + *no_add_attrs = true;
107915 + }
107916 + }
107917 + return NULL_TREE;
107918 +}
107919 +
107920 +static struct attribute_spec size_overflow_attr = {
107921 + .name = "size_overflow",
107922 + .min_length = 1,
107923 + .max_length = -1,
107924 + .decl_required = true,
107925 + .type_required = false,
107926 + .function_type_required = false,
107927 + .handler = handle_size_overflow_attribute,
107928 +#if BUILDING_GCC_VERSION >= 4007
107929 + .affects_type_identity = false
107930 +#endif
107931 +};
107932 +
107933 +static struct attribute_spec intentional_overflow_attr = {
107934 + .name = "intentional_overflow",
107935 + .min_length = 1,
107936 + .max_length = -1,
107937 + .decl_required = true,
107938 + .type_required = false,
107939 + .function_type_required = false,
107940 + .handler = handle_intentional_overflow_attribute,
107941 +#if BUILDING_GCC_VERSION >= 4007
107942 + .affects_type_identity = false
107943 +#endif
107944 +};
107945 +
107946 +static void register_attributes(void __unused *event_data, void __unused *data)
107947 +{
107948 + register_attribute(&size_overflow_attr);
107949 + register_attribute(&intentional_overflow_attr);
107950 +}
107951 +
107952 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
107953 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
107954 +{
107955 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
107956 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
107957 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
107958 +
107959 + unsigned int m = 0x57559429;
107960 + unsigned int n = 0x5052acdb;
107961 + const unsigned int *key4 = (const unsigned int *)key;
107962 + unsigned int h = len;
107963 + unsigned int k = len + seed + n;
107964 + unsigned long long p;
107965 +
107966 + while (len >= 8) {
107967 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
107968 + len -= 8;
107969 + }
107970 + if (len >= 4) {
107971 + cwmixb(key4[0]) key4 += 1;
107972 + len -= 4;
107973 + }
107974 + if (len)
107975 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
107976 + cwmixb(h ^ (k + n));
107977 + return k ^ h;
107978 +
107979 +#undef cwfold
107980 +#undef cwmixa
107981 +#undef cwmixb
107982 +}
107983 +
107984 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
107985 +{
107986 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
107987 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
107988 + return fn ^ codes;
107989 +}
107990 +
107991 +static inline tree get_original_function_decl(tree fndecl)
107992 +{
107993 + if (DECL_ABSTRACT_ORIGIN(fndecl))
107994 + return DECL_ABSTRACT_ORIGIN(fndecl);
107995 + return fndecl;
107996 +}
107997 +
107998 +static inline gimple get_def_stmt(const_tree node)
107999 +{
108000 + gcc_assert(node != NULL_TREE);
108001 + if (TREE_CODE(node) != SSA_NAME)
108002 + return NULL;
108003 + return SSA_NAME_DEF_STMT(node);
108004 +}
108005 +
108006 +static unsigned char get_tree_code(const_tree type)
108007 +{
108008 + switch (TREE_CODE(type)) {
108009 + case ARRAY_TYPE:
108010 + return 0;
108011 + case BOOLEAN_TYPE:
108012 + return 1;
108013 + case ENUMERAL_TYPE:
108014 + return 2;
108015 + case FUNCTION_TYPE:
108016 + return 3;
108017 + case INTEGER_TYPE:
108018 + return 4;
108019 + case POINTER_TYPE:
108020 + return 5;
108021 + case RECORD_TYPE:
108022 + return 6;
108023 + case UNION_TYPE:
108024 + return 7;
108025 + case VOID_TYPE:
108026 + return 8;
108027 + case REAL_TYPE:
108028 + return 9;
108029 + case VECTOR_TYPE:
108030 + return 10;
108031 + case REFERENCE_TYPE:
108032 + return 11;
108033 + case OFFSET_TYPE:
108034 + return 12;
108035 + case COMPLEX_TYPE:
108036 + return 13;
108037 + default:
108038 + debug_tree((tree)type);
108039 + gcc_unreachable();
108040 + }
108041 +}
108042 +
108043 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108044 +{
108045 + gcc_assert(type != NULL_TREE);
108046 +
108047 + while (type && len < CODES_LIMIT) {
108048 + tree_codes[len] = get_tree_code(type);
108049 + len++;
108050 + type = TREE_TYPE(type);
108051 + }
108052 + return len;
108053 +}
108054 +
108055 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108056 +{
108057 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108058 + enum tree_code code = TREE_CODE(type);
108059 + size_t len = 0;
108060 +
108061 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108062 +
108063 + arg = TYPE_ARG_TYPES(type);
108064 + // skip builtins __builtin_constant_p
108065 + if (!arg && DECL_BUILT_IN(fndecl))
108066 + return 0;
108067 +
108068 + if (TREE_CODE_CLASS(code) == tcc_type)
108069 + result = type;
108070 + else
108071 + result = DECL_RESULT(fndecl);
108072 +
108073 + gcc_assert(result != NULL_TREE);
108074 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108075 +
108076 + if (arg == NULL_TREE) {
108077 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108078 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108079 + if (arg_field == NULL_TREE)
108080 + return 0;
108081 + arg = TREE_TYPE(arg_field);
108082 + len = add_type_codes(arg, tree_codes, len);
108083 + gcc_assert(len != 0);
108084 + return len;
108085 + }
108086 +
108087 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108088 + while (arg && len < CODES_LIMIT) {
108089 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108090 + arg = TREE_CHAIN(arg);
108091 + }
108092 +
108093 + gcc_assert(len != 0);
108094 + return len;
108095 +}
108096 +
108097 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108098 +{
108099 + unsigned int hash;
108100 + const struct size_overflow_hash *entry;
108101 + unsigned char tree_codes[CODES_LIMIT];
108102 + size_t len;
108103 + const char *func_name;
108104 +
108105 + fndecl = get_original_function_decl(fndecl);
108106 + len = get_function_decl(fndecl, tree_codes);
108107 + if (len == 0)
108108 + return NULL;
108109 +
108110 + func_name = get_asm_name(fndecl);
108111 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
108112 +
108113 + entry = size_overflow_hash[hash];
108114 + while (entry) {
108115 + if (!strcmp(entry->name, func_name))
108116 + return entry;
108117 + entry = entry->next;
108118 + }
108119 +
108120 + return NULL;
108121 +}
108122 +
108123 +static bool is_bool(const_tree node)
108124 +{
108125 + const_tree type;
108126 +
108127 + if (node == NULL_TREE)
108128 + return false;
108129 +
108130 + type = TREE_TYPE(node);
108131 + if (!INTEGRAL_TYPE_P(type))
108132 + return false;
108133 + if (TREE_CODE(type) == BOOLEAN_TYPE)
108134 + return true;
108135 + if (TYPE_PRECISION(type) == 1)
108136 + return true;
108137 + return false;
108138 +}
108139 +
108140 +static bool skip_types(const_tree var)
108141 +{
108142 + tree type;
108143 +
108144 + if (is_gimple_constant(var))
108145 + return true;
108146 +
108147 + switch (TREE_CODE(var)) {
108148 + case ADDR_EXPR:
108149 +#if BUILDING_GCC_VERSION >= 4006
108150 + case MEM_REF:
108151 +#endif
108152 + case ARRAY_REF:
108153 + case BIT_FIELD_REF:
108154 + case INDIRECT_REF:
108155 + case TARGET_MEM_REF:
108156 + return true;
108157 + case PARM_DECL:
108158 + case VAR_DECL:
108159 + case COMPONENT_REF:
108160 + return false;
108161 + default:
108162 + break;
108163 + }
108164 +
108165 + gcc_assert(TREE_CODE(var) == SSA_NAME);
108166 +
108167 + type = TREE_TYPE(var);
108168 + switch (TREE_CODE(type)) {
108169 + case INTEGER_TYPE:
108170 + case ENUMERAL_TYPE:
108171 + return false;
108172 + case BOOLEAN_TYPE:
108173 + return is_bool(var);
108174 + default:
108175 + break;
108176 + }
108177 +
108178 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
108179 +
108180 + type = TREE_TYPE(type);
108181 + gcc_assert(type != NULL_TREE);
108182 + switch (TREE_CODE(type)) {
108183 + case RECORD_TYPE:
108184 + case POINTER_TYPE:
108185 + case ARRAY_TYPE:
108186 + return true;
108187 + case VOID_TYPE:
108188 + case INTEGER_TYPE:
108189 + case UNION_TYPE:
108190 + return false;
108191 + default:
108192 + break;
108193 + }
108194 +
108195 + debug_tree((tree)var);
108196 + gcc_unreachable();
108197 +}
108198 +
108199 +static unsigned int find_arg_number(const_tree arg, tree func)
108200 +{
108201 + tree var;
108202 + unsigned int argnum = 1;
108203 +
108204 + if (TREE_CODE(arg) == SSA_NAME)
108205 + arg = SSA_NAME_VAR(arg);
108206 +
108207 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
108208 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
108209 + continue;
108210 + if (!skip_types(var))
108211 + return argnum;
108212 + }
108213 +
108214 + return 0;
108215 +}
108216 +
108217 +static tree create_new_var(tree type)
108218 +{
108219 + tree new_var = create_tmp_var(type, "cicus");
108220 +
108221 +#if BUILDING_GCC_VERSION <= 4007
108222 + add_referenced_var(new_var);
108223 +#endif
108224 + return new_var;
108225 +}
108226 +
108227 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
108228 +{
108229 + gimple assign;
108230 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108231 + tree type = TREE_TYPE(rhs1);
108232 + tree lhs = create_new_var(type);
108233 +
108234 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
108235 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
108236 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108237 +
108238 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108239 + update_stmt(assign);
108240 + gimple_set_plf(assign, MY_STMT, true);
108241 + return assign;
108242 +}
108243 +
108244 +static tree cast_a_tree(tree type, tree var)
108245 +{
108246 + gcc_assert(type != NULL_TREE);
108247 + gcc_assert(var != NULL_TREE);
108248 + gcc_assert(fold_convertible_p(type, var));
108249 +
108250 + return fold_convert(type, var);
108251 +}
108252 +
108253 +static tree get_lhs(const_gimple stmt)
108254 +{
108255 + switch (gimple_code(stmt)) {
108256 + case GIMPLE_ASSIGN:
108257 + return gimple_get_lhs(stmt);
108258 + case GIMPLE_PHI:
108259 + return gimple_phi_result(stmt);
108260 + case GIMPLE_CALL:
108261 + return gimple_call_lhs(stmt);
108262 + default:
108263 + return NULL_TREE;
108264 + }
108265 +}
108266 +
108267 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
108268 +{
108269 + const_gimple def_stmt = get_def_stmt(rhs);
108270 +
108271 + if (force)
108272 + return false;
108273 +
108274 + if (is_gimple_constant(rhs))
108275 + return false;
108276 +
108277 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108278 + return false;
108279 +
108280 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
108281 + return false;
108282 +
108283 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
108284 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108285 + return false;
108286 +
108287 + return true;
108288 +}
108289 +
108290 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
108291 +{
108292 + gimple assign, def_stmt;
108293 +
108294 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
108295 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
108296 + gcc_unreachable();
108297 +
108298 + def_stmt = get_def_stmt(rhs);
108299 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
108300 + return def_stmt;
108301 +
108302 + if (lhs == CREATE_NEW_VAR)
108303 + lhs = create_new_var(dst_type);
108304 +
108305 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
108306 +
108307 + if (!gsi_end_p(*gsi)) {
108308 + location_t loc = gimple_location(gsi_stmt(*gsi));
108309 + gimple_set_location(assign, loc);
108310 + }
108311 +
108312 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108313 +
108314 + if (before)
108315 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
108316 + else
108317 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
108318 + update_stmt(assign);
108319 + gimple_set_plf(assign, MY_STMT, true);
108320 +
108321 + return assign;
108322 +}
108323 +
108324 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
108325 +{
108326 + gimple_stmt_iterator gsi;
108327 + tree lhs;
108328 + const_gimple new_stmt;
108329 +
108330 + if (rhs == NULL_TREE)
108331 + return NULL_TREE;
108332 +
108333 + gsi = gsi_for_stmt(stmt);
108334 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
108335 +
108336 + lhs = get_lhs(new_stmt);
108337 + gcc_assert(lhs != NULL_TREE);
108338 + return lhs;
108339 +}
108340 +
108341 +static tree cast_to_TI_type(gimple stmt, tree node)
108342 +{
108343 + gimple_stmt_iterator gsi;
108344 + gimple cast_stmt;
108345 + tree type = TREE_TYPE(node);
108346 +
108347 + if (types_compatible_p(type, intTI_type_node))
108348 + return node;
108349 +
108350 + gsi = gsi_for_stmt(stmt);
108351 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108352 + return gimple_get_lhs(cast_stmt);
108353 +}
108354 +
108355 +static void check_function_hash(const_gimple stmt)
108356 +{
108357 + tree func;
108358 + const struct size_overflow_hash *hash;
108359 +
108360 + if (gimple_code(stmt) != GIMPLE_CALL)
108361 + return;
108362 +
108363 + func = gimple_call_fndecl(stmt);
108364 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
108365 + if (func == NULL_TREE)
108366 + return;
108367 +
108368 + hash = get_function_hash(func);
108369 + if (!hash)
108370 + print_missing_msg(func, 0);
108371 +}
108372 +
108373 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
108374 +{
108375 + tree lhs, new_lhs;
108376 + gimple_stmt_iterator gsi;
108377 +
108378 + if (rhs1 == NULL_TREE) {
108379 + debug_gimple_stmt(oldstmt);
108380 + error("%s: rhs1 is NULL_TREE", __func__);
108381 + gcc_unreachable();
108382 + }
108383 +
108384 + switch (gimple_code(oldstmt)) {
108385 + case GIMPLE_ASM:
108386 + lhs = rhs1;
108387 + break;
108388 + case GIMPLE_CALL:
108389 + lhs = gimple_call_lhs(oldstmt);
108390 + break;
108391 + case GIMPLE_ASSIGN:
108392 + lhs = gimple_get_lhs(oldstmt);
108393 + break;
108394 + default:
108395 + debug_gimple_stmt(oldstmt);
108396 + gcc_unreachable();
108397 + }
108398 +
108399 + gsi = gsi_for_stmt(oldstmt);
108400 + pointer_set_insert(visited, oldstmt);
108401 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
108402 + basic_block next_bb, cur_bb;
108403 + const_edge e;
108404 +
108405 + gcc_assert(before == false);
108406 + gcc_assert(stmt_can_throw_internal(oldstmt));
108407 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
108408 + gcc_assert(!gsi_end_p(gsi));
108409 +
108410 + cur_bb = gimple_bb(oldstmt);
108411 + next_bb = cur_bb->next_bb;
108412 + e = find_edge(cur_bb, next_bb);
108413 + gcc_assert(e != NULL);
108414 + gcc_assert(e->flags & EDGE_FALLTHRU);
108415 +
108416 + gsi = gsi_after_labels(next_bb);
108417 + gcc_assert(!gsi_end_p(gsi));
108418 +
108419 + before = true;
108420 + oldstmt = gsi_stmt(gsi);
108421 + }
108422 +
108423 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
108424 + return new_lhs;
108425 +}
108426 +
108427 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
108428 +{
108429 + gimple stmt;
108430 + gimple_stmt_iterator gsi;
108431 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
108432 +
108433 + if (gimple_plf(oldstmt, MY_STMT))
108434 + return lhs;
108435 +
108436 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
108437 + rhs1 = gimple_assign_rhs1(oldstmt);
108438 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
108439 + }
108440 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
108441 + rhs2 = gimple_assign_rhs2(oldstmt);
108442 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
108443 + }
108444 +
108445 + stmt = gimple_copy(oldstmt);
108446 + gimple_set_location(stmt, gimple_location(oldstmt));
108447 + gimple_set_plf(stmt, MY_STMT, true);
108448 +
108449 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
108450 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
108451 +
108452 + size_overflow_type = get_size_overflow_type(oldstmt, node);
108453 +
108454 + new_var = create_new_var(size_overflow_type);
108455 + new_var = make_ssa_name(new_var, stmt);
108456 + gimple_set_lhs(stmt, new_var);
108457 +
108458 + if (rhs1 != NULL_TREE)
108459 + gimple_assign_set_rhs1(stmt, rhs1);
108460 +
108461 + if (rhs2 != NULL_TREE)
108462 + gimple_assign_set_rhs2(stmt, rhs2);
108463 +#if BUILDING_GCC_VERSION >= 4007
108464 + if (rhs3 != NULL_TREE)
108465 + gimple_assign_set_rhs3(stmt, rhs3);
108466 +#endif
108467 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
108468 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
108469 +
108470 + gsi = gsi_for_stmt(oldstmt);
108471 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
108472 + update_stmt(stmt);
108473 + pointer_set_insert(visited, oldstmt);
108474 + return gimple_get_lhs(stmt);
108475 +}
108476 +
108477 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
108478 +{
108479 + basic_block first_bb;
108480 + gimple assign;
108481 + gimple_stmt_iterator gsi;
108482 +
108483 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108484 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108485 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
108486 +
108487 + gsi = gsi_start_bb(first_bb);
108488 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108489 + return gimple_get_lhs(assign);
108490 +}
108491 +
108492 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
108493 +{
108494 + gimple_stmt_iterator gsi;
108495 + const_gimple assign;
108496 + gimple def_stmt = get_def_stmt(new_arg);
108497 +
108498 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
108499 + gsi = gsi_after_labels(gimple_bb(def_stmt));
108500 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
108501 + } else {
108502 + gsi = gsi_for_stmt(def_stmt);
108503 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
108504 + }
108505 +
108506 + return gimple_get_lhs(assign);
108507 +}
108508 +
108509 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
108510 +{
108511 + basic_block bb;
108512 + gimple_stmt_iterator gsi;
108513 + const_gimple assign, def_stmt;
108514 +
108515 + def_stmt = get_def_stmt(arg);
108516 + bb = gimple_bb(def_stmt);
108517 + gcc_assert(bb->index != 0);
108518 + gsi = gsi_after_labels(bb);
108519 +
108520 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108521 + return gimple_get_lhs(assign);
108522 +}
108523 +
108524 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
108525 +{
108526 + tree size_overflow_type;
108527 + const_gimple def_stmt = get_def_stmt(arg);
108528 +
108529 + if (phi_ssa_name != NULL_TREE)
108530 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
108531 +
108532 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
108533 +
108534 + if (new_arg != NULL_TREE) {
108535 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
108536 + return use_phi_ssa_name(phi_ssa_name, new_arg);
108537 + }
108538 +
108539 + switch(gimple_code(def_stmt)) {
108540 + case GIMPLE_PHI:
108541 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
108542 + case GIMPLE_NOP:
108543 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
108544 + default:
108545 + debug_gimple_stmt((gimple)def_stmt);
108546 + gcc_unreachable();
108547 + }
108548 +}
108549 +
108550 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
108551 +{
108552 + basic_block bb;
108553 + gimple phi;
108554 + gimple_seq seq;
108555 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
108556 +
108557 + bb = gsi_bb(gsi);
108558 +
108559 + phi = create_phi_node(result, bb);
108560 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
108561 + seq = phi_nodes(bb);
108562 + gsi = gsi_last(seq);
108563 + gsi_remove(&gsi, false);
108564 +
108565 + gsi = gsi_for_stmt(oldstmt);
108566 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
108567 + gimple_set_bb(phi, bb);
108568 + gimple_set_plf(phi, MY_STMT, true);
108569 + return phi;
108570 +}
108571 +
108572 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
108573 +{
108574 + gimple new_phi = NULL;
108575 + gimple oldstmt = get_def_stmt(orig_result);
108576 + tree phi_ssa_name = NULL_TREE;
108577 + unsigned int i;
108578 +
108579 + pointer_set_insert(visited, oldstmt);
108580 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
108581 + tree arg, new_arg;
108582 +
108583 + arg = gimple_phi_arg_def(oldstmt, i);
108584 +
108585 + new_arg = expand(visited, arg);
108586 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
108587 + if (i == 0) {
108588 + phi_ssa_name = new_arg;
108589 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
108590 + }
108591 +
108592 + gcc_assert(new_phi != NULL);
108593 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
108594 + }
108595 +
108596 + gcc_assert(new_phi != NULL);
108597 + update_stmt(new_phi);
108598 + return gimple_phi_result(new_phi);
108599 +}
108600 +
108601 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
108602 +{
108603 + const_gimple assign;
108604 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108605 + tree origtype = TREE_TYPE(orig_rhs);
108606 +
108607 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
108608 +
108609 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108610 + return gimple_get_lhs(assign);
108611 +}
108612 +
108613 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
108614 +{
108615 + const_tree rhs1, lhs, rhs1_type, lhs_type;
108616 + enum machine_mode lhs_mode, rhs_mode;
108617 + gimple def_stmt = get_def_stmt(no_const_rhs);
108618 +
108619 + if (!gimple_assign_cast_p(def_stmt))
108620 + return false;
108621 +
108622 + rhs1 = gimple_assign_rhs1(def_stmt);
108623 + lhs = gimple_get_lhs(def_stmt);
108624 + rhs1_type = TREE_TYPE(rhs1);
108625 + lhs_type = TREE_TYPE(lhs);
108626 + rhs_mode = TYPE_MODE(rhs1_type);
108627 + lhs_mode = TYPE_MODE(lhs_type);
108628 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
108629 + return false;
108630 +
108631 + return true;
108632 +}
108633 +
108634 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
108635 +{
108636 + tree rhs1 = gimple_assign_rhs1(stmt);
108637 + tree lhs = gimple_get_lhs(stmt);
108638 + const_tree rhs1_type = TREE_TYPE(rhs1);
108639 + const_tree lhs_type = TREE_TYPE(lhs);
108640 +
108641 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
108642 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108643 +
108644 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
108645 +}
108646 +
108647 +static bool no_uses(tree node)
108648 +{
108649 + imm_use_iterator imm_iter;
108650 + use_operand_p use_p;
108651 +
108652 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
108653 + const_gimple use_stmt = USE_STMT(use_p);
108654 + if (use_stmt == NULL)
108655 + return true;
108656 + if (is_gimple_debug(use_stmt))
108657 + continue;
108658 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
108659 + continue;
108660 + return false;
108661 + }
108662 + return true;
108663 +}
108664 +
108665 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
108666 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
108667 +{
108668 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
108669 + gimple def_stmt = get_def_stmt(lhs);
108670 +
108671 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
108672 + return false;
108673 +
108674 + rhs1 = gimple_assign_rhs1(def_stmt);
108675 + rhs_type = TREE_TYPE(rhs1);
108676 + lhs_type = TREE_TYPE(lhs);
108677 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
108678 + return false;
108679 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
108680 + return false;
108681 +
108682 + def_stmt = get_def_stmt(rhs1);
108683 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
108684 + return false;
108685 +
108686 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
108687 + return false;
108688 +
108689 + rhs1 = gimple_assign_rhs1(def_stmt);
108690 + rhs2 = gimple_assign_rhs2(def_stmt);
108691 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
108692 + return false;
108693 +
108694 + if (is_gimple_constant(rhs2))
108695 + not_const_rhs = rhs1;
108696 + else
108697 + not_const_rhs = rhs2;
108698 +
108699 + return no_uses(not_const_rhs);
108700 +}
108701 +
108702 +static bool skip_lhs_cast_check(const_gimple stmt)
108703 +{
108704 + const_tree rhs = gimple_assign_rhs1(stmt);
108705 + const_gimple def_stmt = get_def_stmt(rhs);
108706 +
108707 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
108708 + if (gimple_code(def_stmt) == GIMPLE_ASM)
108709 + return true;
108710 +
108711 + if (is_const_plus_unsigned_signed_truncation(rhs))
108712 + return true;
108713 +
108714 + return false;
108715 +}
108716 +
108717 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
108718 +{
108719 + bool cast_lhs, cast_rhs;
108720 + tree lhs = gimple_get_lhs(stmt);
108721 + tree rhs = gimple_assign_rhs1(stmt);
108722 + const_tree lhs_type = TREE_TYPE(lhs);
108723 + const_tree rhs_type = TREE_TYPE(rhs);
108724 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
108725 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
108726 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
108727 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
108728 +
108729 + static bool check_lhs[3][4] = {
108730 + // ss su us uu
108731 + { false, true, true, false }, // lhs > rhs
108732 + { false, false, false, false }, // lhs = rhs
108733 + { true, true, true, true }, // lhs < rhs
108734 + };
108735 +
108736 + static bool check_rhs[3][4] = {
108737 + // ss su us uu
108738 + { true, false, true, true }, // lhs > rhs
108739 + { true, false, true, true }, // lhs = rhs
108740 + { true, false, true, true }, // lhs < rhs
108741 + };
108742 +
108743 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
108744 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
108745 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108746 +
108747 + if (lhs_size > rhs_size) {
108748 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108749 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108750 + } else if (lhs_size == rhs_size) {
108751 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108752 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108753 + } else {
108754 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108755 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108756 + }
108757 +
108758 + if (!cast_lhs && !cast_rhs)
108759 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108760 +
108761 + if (cast_lhs && !skip_lhs_cast_check(stmt))
108762 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
108763 +
108764 + if (cast_rhs)
108765 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
108766 +
108767 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108768 +}
108769 +
108770 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
108771 +{
108772 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
108773 +
108774 + if (gimple_plf(stmt, MY_STMT))
108775 + return lhs;
108776 +
108777 + rhs1 = gimple_assign_rhs1(stmt);
108778 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
108779 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108780 +
108781 + new_rhs1 = expand(visited, rhs1);
108782 +
108783 + if (new_rhs1 == NULL_TREE)
108784 + return create_cast_assign(visited, stmt);
108785 +
108786 + if (gimple_plf(stmt, NO_CAST_CHECK))
108787 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108788 +
108789 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
108790 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
108791 +
108792 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
108793 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
108794 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108795 + }
108796 +
108797 + if (!gimple_assign_cast_p(stmt))
108798 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108799 +
108800 + return create_cast_overflow_check(visited, new_rhs1, stmt);
108801 +}
108802 +
108803 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
108804 +{
108805 + tree rhs1, lhs = gimple_get_lhs(stmt);
108806 + gimple def_stmt = get_def_stmt(lhs);
108807 +
108808 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
108809 + rhs1 = gimple_assign_rhs1(def_stmt);
108810 +
108811 + if (is_gimple_constant(rhs1))
108812 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108813 +
108814 + switch (TREE_CODE(rhs1)) {
108815 + case SSA_NAME:
108816 + return handle_unary_rhs(visited, def_stmt);
108817 + case ARRAY_REF:
108818 + case BIT_FIELD_REF:
108819 + case ADDR_EXPR:
108820 + case COMPONENT_REF:
108821 + case INDIRECT_REF:
108822 +#if BUILDING_GCC_VERSION >= 4006
108823 + case MEM_REF:
108824 +#endif
108825 + case TARGET_MEM_REF:
108826 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108827 + case PARM_DECL:
108828 + case VAR_DECL:
108829 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108830 +
108831 + default:
108832 + debug_gimple_stmt(def_stmt);
108833 + debug_tree(rhs1);
108834 + gcc_unreachable();
108835 + }
108836 +}
108837 +
108838 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
108839 +{
108840 + gimple cond_stmt;
108841 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
108842 +
108843 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
108844 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
108845 + update_stmt(cond_stmt);
108846 +}
108847 +
108848 +static tree create_string_param(tree string)
108849 +{
108850 + tree i_type, a_type;
108851 + const int length = TREE_STRING_LENGTH(string);
108852 +
108853 + gcc_assert(length > 0);
108854 +
108855 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
108856 + a_type = build_array_type(char_type_node, i_type);
108857 +
108858 + TREE_TYPE(string) = a_type;
108859 + TREE_CONSTANT(string) = 1;
108860 + TREE_READONLY(string) = 1;
108861 +
108862 + return build1(ADDR_EXPR, ptr_type_node, string);
108863 +}
108864 +
108865 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
108866 +{
108867 + gimple func_stmt;
108868 + const_gimple def_stmt;
108869 + const_tree loc_line;
108870 + tree loc_file, ssa_name, current_func;
108871 + expanded_location xloc;
108872 + char *ssa_name_buf;
108873 + int len;
108874 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
108875 +
108876 + def_stmt = get_def_stmt(arg);
108877 + xloc = expand_location(gimple_location(def_stmt));
108878 +
108879 + if (!gimple_has_location(def_stmt)) {
108880 + xloc = expand_location(gimple_location(stmt));
108881 + if (!gimple_has_location(stmt))
108882 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
108883 + }
108884 +
108885 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
108886 +
108887 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
108888 + loc_file = create_string_param(loc_file);
108889 +
108890 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
108891 + current_func = create_string_param(current_func);
108892 +
108893 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
108894 + call_count++;
108895 + 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);
108896 + gcc_assert(len > 0);
108897 + ssa_name = build_string(len + 1, ssa_name_buf);
108898 + free(ssa_name_buf);
108899 + ssa_name = create_string_param(ssa_name);
108900 +
108901 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
108902 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
108903 +
108904 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
108905 +}
108906 +
108907 +static void __unused print_the_code_insertions(const_gimple stmt)
108908 +{
108909 + location_t loc = gimple_location(stmt);
108910 +
108911 + inform(loc, "Integer size_overflow check applied here.");
108912 +}
108913 +
108914 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
108915 +{
108916 + basic_block cond_bb, join_bb, bb_true;
108917 + edge e;
108918 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108919 +
108920 + cond_bb = gimple_bb(stmt);
108921 + if (before)
108922 + gsi_prev(&gsi);
108923 + if (gsi_end_p(gsi))
108924 + e = split_block_after_labels(cond_bb);
108925 + else
108926 + e = split_block(cond_bb, gsi_stmt(gsi));
108927 + cond_bb = e->src;
108928 + join_bb = e->dest;
108929 + e->flags = EDGE_FALSE_VALUE;
108930 + e->probability = REG_BR_PROB_BASE;
108931 +
108932 + bb_true = create_empty_bb(cond_bb);
108933 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
108934 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
108935 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
108936 +
108937 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108938 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
108939 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
108940 +
108941 + if (current_loops != NULL) {
108942 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
108943 + add_bb_to_loop(bb_true, cond_bb->loop_father);
108944 + }
108945 +
108946 + insert_cond(cond_bb, arg, cond_code, type_value);
108947 + insert_cond_result(bb_true, stmt, arg, min);
108948 +
108949 +// print_the_code_insertions(stmt);
108950 +}
108951 +
108952 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
108953 +{
108954 + const_tree rhs_type = TREE_TYPE(rhs);
108955 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
108956 +
108957 + gcc_assert(rhs_type != NULL_TREE);
108958 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
108959 + return;
108960 +
108961 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
108962 +
108963 + if (is_const_plus_unsigned_signed_truncation(rhs))
108964 + return;
108965 +
108966 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
108967 + // typemax (-1) < typemin (0)
108968 + if (TREE_OVERFLOW(type_max))
108969 + return;
108970 +
108971 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
108972 +
108973 + cast_rhs_type = TREE_TYPE(cast_rhs);
108974 + type_max_type = TREE_TYPE(type_max);
108975 + type_min_type = TREE_TYPE(type_min);
108976 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
108977 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
108978 +
108979 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
108980 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
108981 +}
108982 +
108983 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
108984 +{
108985 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
108986 + return false;
108987 + if (!is_gimple_constant(rhs))
108988 + return false;
108989 + return true;
108990 +}
108991 +
108992 +static tree get_def_stmt_rhs(const_tree var)
108993 +{
108994 + tree rhs1, def_stmt_rhs1;
108995 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
108996 +
108997 + def_stmt = get_def_stmt(var);
108998 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
108999 +
109000 + rhs1 = gimple_assign_rhs1(def_stmt);
109001 + rhs1_def_stmt = get_def_stmt(rhs1);
109002 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109003 + return rhs1;
109004 +
109005 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109006 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109007 +
109008 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109009 + case GIMPLE_CALL:
109010 + case GIMPLE_NOP:
109011 + case GIMPLE_ASM:
109012 + case GIMPLE_PHI:
109013 + return def_stmt_rhs1;
109014 + case GIMPLE_ASSIGN:
109015 + return rhs1;
109016 + default:
109017 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109018 + gcc_unreachable();
109019 + }
109020 +}
109021 +
109022 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109023 +{
109024 + tree new_rhs, orig_rhs;
109025 + void (*gimple_assign_set_rhs)(gimple, tree);
109026 + tree rhs1 = gimple_assign_rhs1(stmt);
109027 + tree rhs2 = gimple_assign_rhs2(stmt);
109028 + tree lhs = gimple_get_lhs(stmt);
109029 +
109030 + if (!check_overflow)
109031 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109032 +
109033 + if (change_rhs == NULL_TREE)
109034 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109035 +
109036 + if (new_rhs2 == NULL_TREE) {
109037 + orig_rhs = rhs1;
109038 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109039 + } else {
109040 + orig_rhs = rhs2;
109041 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109042 + }
109043 +
109044 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109045 +
109046 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109047 + gimple_assign_set_rhs(stmt, new_rhs);
109048 + update_stmt(stmt);
109049 +
109050 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109051 +}
109052 +
109053 +static bool is_subtraction_special(const_gimple stmt)
109054 +{
109055 + gimple rhs1_def_stmt, rhs2_def_stmt;
109056 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109057 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109058 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109059 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109060 +
109061 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109062 + return false;
109063 +
109064 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109065 +
109066 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109067 + return false;
109068 +
109069 + rhs1_def_stmt = get_def_stmt(rhs1);
109070 + rhs2_def_stmt = get_def_stmt(rhs2);
109071 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109072 + return false;
109073 +
109074 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109075 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109076 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109077 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109078 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109079 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109080 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109081 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109082 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109083 + return false;
109084 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109085 + return false;
109086 +
109087 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109088 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109089 + return true;
109090 +}
109091 +
109092 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109093 +{
109094 + tree new_rhs1, new_rhs2;
109095 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109096 + gimple assign, stmt = get_def_stmt(lhs);
109097 + tree rhs1 = gimple_assign_rhs1(stmt);
109098 + tree rhs2 = gimple_assign_rhs2(stmt);
109099 +
109100 + if (!is_subtraction_special(stmt))
109101 + return NULL_TREE;
109102 +
109103 + new_rhs1 = expand(visited, rhs1);
109104 + new_rhs2 = expand(visited, rhs2);
109105 +
109106 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
109107 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
109108 +
109109 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
109110 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
109111 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
109112 + }
109113 +
109114 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
109115 + new_lhs = gimple_get_lhs(assign);
109116 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
109117 +
109118 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109119 +}
109120 +
109121 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
109122 +{
109123 + const_gimple def_stmt;
109124 +
109125 + if (TREE_CODE(rhs) != SSA_NAME)
109126 + return false;
109127 +
109128 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
109129 + return false;
109130 +
109131 + def_stmt = get_def_stmt(rhs);
109132 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
109133 + return false;
109134 +
109135 + return true;
109136 +}
109137 +
109138 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
109139 +{
109140 + tree rhs1, rhs2, new_lhs;
109141 + gimple def_stmt = get_def_stmt(lhs);
109142 + tree new_rhs1 = NULL_TREE;
109143 + tree new_rhs2 = NULL_TREE;
109144 +
109145 + rhs1 = gimple_assign_rhs1(def_stmt);
109146 + rhs2 = gimple_assign_rhs2(def_stmt);
109147 +
109148 + /* no DImode/TImode division in the 32/64 bit kernel */
109149 + switch (gimple_assign_rhs_code(def_stmt)) {
109150 + case RDIV_EXPR:
109151 + case TRUNC_DIV_EXPR:
109152 + case CEIL_DIV_EXPR:
109153 + case FLOOR_DIV_EXPR:
109154 + case ROUND_DIV_EXPR:
109155 + case TRUNC_MOD_EXPR:
109156 + case CEIL_MOD_EXPR:
109157 + case FLOOR_MOD_EXPR:
109158 + case ROUND_MOD_EXPR:
109159 + case EXACT_DIV_EXPR:
109160 + case POINTER_PLUS_EXPR:
109161 + case BIT_AND_EXPR:
109162 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109163 + default:
109164 + break;
109165 + }
109166 +
109167 + new_lhs = handle_integer_truncation(visited, lhs);
109168 + if (new_lhs != NULL_TREE)
109169 + return new_lhs;
109170 +
109171 + if (TREE_CODE(rhs1) == SSA_NAME)
109172 + new_rhs1 = expand(visited, rhs1);
109173 + if (TREE_CODE(rhs2) == SSA_NAME)
109174 + new_rhs2 = expand(visited, rhs2);
109175 +
109176 + if (is_a_neg_overflow(def_stmt, rhs2))
109177 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
109178 + if (is_a_neg_overflow(def_stmt, rhs1))
109179 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
109180 +
109181 +
109182 + if (is_a_constant_overflow(def_stmt, rhs2))
109183 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
109184 + if (is_a_constant_overflow(def_stmt, rhs1))
109185 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
109186 +
109187 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109188 +}
109189 +
109190 +#if BUILDING_GCC_VERSION >= 4007
109191 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
109192 +{
109193 + if (is_gimple_constant(rhs))
109194 + return cast_a_tree(size_overflow_type, rhs);
109195 + if (TREE_CODE(rhs) != SSA_NAME)
109196 + return NULL_TREE;
109197 + return expand(visited, rhs);
109198 +}
109199 +
109200 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
109201 +{
109202 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
109203 + gimple def_stmt = get_def_stmt(lhs);
109204 +
109205 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
109206 +
109207 + rhs1 = gimple_assign_rhs1(def_stmt);
109208 + rhs2 = gimple_assign_rhs2(def_stmt);
109209 + rhs3 = gimple_assign_rhs3(def_stmt);
109210 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
109211 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
109212 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
109213 +
109214 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
109215 +}
109216 +#endif
109217 +
109218 +static tree get_size_overflow_type(gimple stmt, const_tree node)
109219 +{
109220 + const_tree type;
109221 + tree new_type;
109222 +
109223 + gcc_assert(node != NULL_TREE);
109224 +
109225 + type = TREE_TYPE(node);
109226 +
109227 + if (gimple_plf(stmt, MY_STMT))
109228 + return TREE_TYPE(node);
109229 +
109230 + switch (TYPE_MODE(type)) {
109231 + case QImode:
109232 + new_type = intHI_type_node;
109233 + break;
109234 + case HImode:
109235 + new_type = intSI_type_node;
109236 + break;
109237 + case SImode:
109238 + new_type = intDI_type_node;
109239 + break;
109240 + case DImode:
109241 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109242 + new_type = intDI_type_node;
109243 + else
109244 + new_type = intTI_type_node;
109245 + break;
109246 + default:
109247 + debug_tree((tree)node);
109248 + error("%s: unsupported gcc configuration.", __func__);
109249 + gcc_unreachable();
109250 + }
109251 +
109252 + if (TYPE_QUALS(type) != 0)
109253 + return build_qualified_type(new_type, TYPE_QUALS(type));
109254 + return new_type;
109255 +}
109256 +
109257 +static tree expand_visited(gimple def_stmt)
109258 +{
109259 + const_gimple next_stmt;
109260 + gimple_stmt_iterator gsi;
109261 + enum gimple_code code = gimple_code(def_stmt);
109262 +
109263 + if (code == GIMPLE_ASM)
109264 + return NULL_TREE;
109265 +
109266 + gsi = gsi_for_stmt(def_stmt);
109267 + gsi_next(&gsi);
109268 +
109269 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
109270 + return NULL_TREE;
109271 + gcc_assert(!gsi_end_p(gsi));
109272 + next_stmt = gsi_stmt(gsi);
109273 +
109274 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
109275 + return NULL_TREE;
109276 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
109277 +
109278 + return get_lhs(next_stmt);
109279 +}
109280 +
109281 +static tree expand(struct pointer_set_t *visited, tree lhs)
109282 +{
109283 + gimple def_stmt;
109284 +
109285 + if (skip_types(lhs))
109286 + return NULL_TREE;
109287 +
109288 + def_stmt = get_def_stmt(lhs);
109289 +
109290 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
109291 + return NULL_TREE;
109292 +
109293 + if (gimple_plf(def_stmt, MY_STMT))
109294 + return lhs;
109295 +
109296 + if (pointer_set_contains(visited, def_stmt))
109297 + return expand_visited(def_stmt);
109298 +
109299 + switch (gimple_code(def_stmt)) {
109300 + case GIMPLE_PHI:
109301 + return handle_phi(visited, lhs);
109302 + case GIMPLE_CALL:
109303 + case GIMPLE_ASM:
109304 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109305 + case GIMPLE_ASSIGN:
109306 + switch (gimple_num_ops(def_stmt)) {
109307 + case 2:
109308 + return handle_unary_ops(visited, def_stmt);
109309 + case 3:
109310 + return handle_binary_ops(visited, lhs);
109311 +#if BUILDING_GCC_VERSION >= 4007
109312 + case 4:
109313 + return handle_ternary_ops(visited, lhs);
109314 +#endif
109315 + }
109316 + default:
109317 + debug_gimple_stmt(def_stmt);
109318 + error("%s: unknown gimple code", __func__);
109319 + gcc_unreachable();
109320 + }
109321 +}
109322 +
109323 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
109324 +{
109325 + const_gimple assign;
109326 + tree orig_type = TREE_TYPE(orig_node);
109327 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109328 +
109329 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109330 + return gimple_get_lhs(assign);
109331 +}
109332 +
109333 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
109334 +{
109335 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
109336 + update_stmt(stmt);
109337 +}
109338 +
109339 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
109340 +{
109341 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
109342 + update_stmt(stmt);
109343 +}
109344 +
109345 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
109346 +{
109347 + tree arg;
109348 + const_tree origarg;
109349 +
109350 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
109351 + return true;
109352 +
109353 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
109354 + while (origarg && *argnum) {
109355 + (*argnum)--;
109356 + origarg = TREE_CHAIN(origarg);
109357 + }
109358 +
109359 + gcc_assert(*argnum == 0);
109360 +
109361 + gcc_assert(origarg != NULL_TREE);
109362 + *argnum = 0;
109363 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
109364 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
109365 + return true;
109366 + return false;
109367 +}
109368 +
109369 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
109370 +{
109371 + gimple phi = get_def_stmt(result);
109372 + unsigned int i, n = gimple_phi_num_args(phi);
109373 +
109374 + if (!phi)
109375 + return MARK_NO;
109376 +
109377 + pointer_set_insert(visited, phi);
109378 + for (i = 0; i < n; i++) {
109379 + enum mark marked;
109380 + const_tree arg = gimple_phi_arg_def(phi, i);
109381 + marked = pre_expand(visited, search_err_code, arg);
109382 + if (marked != MARK_NO)
109383 + return marked;
109384 + }
109385 + return MARK_NO;
109386 +}
109387 +
109388 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109389 +{
109390 + gimple def_stmt = get_def_stmt(lhs);
109391 + const_tree rhs;
109392 +
109393 + if (!def_stmt)
109394 + return MARK_NO;
109395 +
109396 + rhs = gimple_assign_rhs1(def_stmt);
109397 +
109398 + def_stmt = get_def_stmt(rhs);
109399 + if (is_gimple_constant(rhs))
109400 + search_err_code[FROM_CONST] = true;
109401 +
109402 + return pre_expand(visited, search_err_code, rhs);
109403 +}
109404 +
109405 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109406 +{
109407 + gimple def_stmt = get_def_stmt(lhs);
109408 + const_tree rhs1, rhs2;
109409 + enum mark marked;
109410 +
109411 + if (!def_stmt)
109412 + return MARK_NO;
109413 +
109414 + search_err_code[CAST_ONLY] = false;
109415 +
109416 + rhs1 = gimple_assign_rhs1(def_stmt);
109417 + rhs2 = gimple_assign_rhs2(def_stmt);
109418 + marked = pre_expand(visited, search_err_code, rhs1);
109419 + if (marked != MARK_NO)
109420 + return marked;
109421 + return pre_expand(visited, search_err_code, rhs2);
109422 +}
109423 +
109424 +static const_tree search_field_decl(const_tree comp_ref)
109425 +{
109426 + const_tree field = NULL_TREE;
109427 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
109428 +
109429 + for (i = 0; i < len; i++) {
109430 + field = TREE_OPERAND(comp_ref, i);
109431 + if (TREE_CODE(field) == FIELD_DECL)
109432 + break;
109433 + }
109434 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
109435 + return field;
109436 +}
109437 +
109438 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
109439 +{
109440 + const_tree attr, p;
109441 +
109442 + // 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);
109443 + if (fndecl == NULL_TREE)
109444 + return MARK_NO;
109445 +
109446 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
109447 + if (!attr || !TREE_VALUE(attr))
109448 + return MARK_NO;
109449 +
109450 + p = TREE_VALUE(attr);
109451 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
109452 + return MARK_TURN_OFF;
109453 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
109454 + return MARK_NOT_INTENTIONAL;
109455 + if (argnum == 0) {
109456 + gcc_assert(current_function_decl == fndecl);
109457 + return MARK_NO;
109458 + }
109459 +
109460 + do {
109461 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
109462 + return MARK_YES;
109463 + p = TREE_CHAIN(p);
109464 + } while (p);
109465 +
109466 + return MARK_NO;
109467 +}
109468 +
109469 +static void print_missing_msg(tree func, unsigned int argnum)
109470 +{
109471 + unsigned int new_hash;
109472 + size_t len;
109473 + unsigned char tree_codes[CODES_LIMIT];
109474 + location_t loc;
109475 + const char *curfunc;
109476 +
109477 + func = get_original_function_decl(func);
109478 + loc = DECL_SOURCE_LOCATION(func);
109479 + curfunc = get_asm_name(func);
109480 +
109481 + len = get_function_decl(func, tree_codes);
109482 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
109483 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
109484 +}
109485 +
109486 +static unsigned int search_missing_attribute(const_tree arg)
109487 +{
109488 + unsigned int argnum;
109489 + const struct size_overflow_hash *hash;
109490 + const_tree type = TREE_TYPE(arg);
109491 + tree func = get_original_function_decl(current_function_decl);
109492 +
109493 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
109494 +
109495 + if (TREE_CODE(type) == POINTER_TYPE)
109496 + return 0;
109497 +
109498 + argnum = find_arg_number(arg, func);
109499 + if (argnum == 0)
109500 + return 0;
109501 +
109502 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
109503 + return argnum;
109504 +
109505 + hash = get_function_hash(func);
109506 + if (!hash || !(hash->param & (1U << argnum))) {
109507 + print_missing_msg(func, argnum);
109508 + return 0;
109509 + }
109510 + return argnum;
109511 +}
109512 +
109513 +static enum mark is_already_marked(const_tree lhs)
109514 +{
109515 + unsigned int argnum;
109516 + const_tree fndecl;
109517 +
109518 + argnum = search_missing_attribute(lhs);
109519 + fndecl = get_original_function_decl(current_function_decl);
109520 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
109521 + return MARK_YES;
109522 + return MARK_NO;
109523 +}
109524 +
109525 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109526 +{
109527 + const_gimple def_stmt;
109528 +
109529 + if (skip_types(lhs))
109530 + return MARK_NO;
109531 +
109532 + if (TREE_CODE(lhs) == PARM_DECL)
109533 + return is_already_marked(lhs);
109534 +
109535 + if (TREE_CODE(lhs) == COMPONENT_REF) {
109536 + const_tree field, attr;
109537 +
109538 + field = search_field_decl(lhs);
109539 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
109540 + if (!attr || !TREE_VALUE(attr))
109541 + return MARK_NO;
109542 + return MARK_YES;
109543 + }
109544 +
109545 + def_stmt = get_def_stmt(lhs);
109546 +
109547 + if (!def_stmt)
109548 + return MARK_NO;
109549 +
109550 + if (pointer_set_contains(visited, def_stmt))
109551 + return MARK_NO;
109552 +
109553 + switch (gimple_code(def_stmt)) {
109554 + case GIMPLE_NOP:
109555 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
109556 + return is_already_marked(lhs);
109557 + return MARK_NO;
109558 + case GIMPLE_PHI:
109559 + return walk_phi(visited, search_err_code, lhs);
109560 + case GIMPLE_CALL:
109561 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
109562 + return MARK_TURN_OFF;
109563 + check_function_hash(def_stmt);
109564 + return MARK_NO;
109565 + case GIMPLE_ASM:
109566 + search_err_code[CAST_ONLY] = false;
109567 + return MARK_NO;
109568 + case GIMPLE_ASSIGN:
109569 + switch (gimple_num_ops(def_stmt)) {
109570 + case 2:
109571 + return walk_unary_ops(visited, search_err_code, lhs);
109572 + case 3:
109573 + return walk_binary_ops(visited, search_err_code, lhs);
109574 + }
109575 + default:
109576 + debug_gimple_stmt((gimple)def_stmt);
109577 + error("%s: unknown gimple code", __func__);
109578 + gcc_unreachable();
109579 + }
109580 +}
109581 +
109582 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
109583 +static bool skip_asm(const_tree arg)
109584 +{
109585 + gimple def_stmt = get_def_stmt(arg);
109586 +
109587 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109588 + return false;
109589 +
109590 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
109591 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
109592 +}
109593 +
109594 +/*
109595 +0</MARK_YES: no dup, search attributes (so, int)
109596 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
109597 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
109598 +*/
109599 +
109600 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
109601 +{
109602 + struct pointer_set_t *visited;
109603 + enum mark is_marked, is_found;
109604 + location_t loc;
109605 + bool search_err_code[2] = {true, false};
109606 +
109607 + is_marked = mark_status(current_function_decl, 0);
109608 + if (is_marked == MARK_TURN_OFF)
109609 + return true;
109610 +
109611 + is_marked = mark_status(fndecl, argnum + 1);
109612 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
109613 + return true;
109614 +
109615 + visited = pointer_set_create();
109616 + is_found = pre_expand(visited, search_err_code, arg);
109617 + pointer_set_destroy(visited);
109618 +
109619 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
109620 + return true;
109621 +
109622 + if (where == FROM_ARG && skip_asm(arg))
109623 + return true;
109624 +
109625 + if (is_found == MARK_TURN_OFF)
109626 + return true;
109627 +
109628 + if ((is_found == MARK_YES && is_marked == MARK_YES))
109629 + return true;
109630 +
109631 + if (is_found == MARK_YES) {
109632 + loc = DECL_SOURCE_LOCATION(fndecl);
109633 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
109634 + return true;
109635 + }
109636 + return false;
109637 +}
109638 +
109639 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
109640 +{
109641 + struct pointer_set_t *visited;
109642 + tree arg, new_arg;
109643 + bool match;
109644 +
109645 + if (argnum == 0)
109646 + return;
109647 +
109648 + argnum--;
109649 +
109650 + match = get_function_arg(&argnum, fndecl);
109651 + if (!match)
109652 + return;
109653 + gcc_assert(gimple_call_num_args(stmt) > argnum);
109654 + arg = gimple_call_arg(stmt, argnum);
109655 + if (arg == NULL_TREE)
109656 + return;
109657 +
109658 + if (skip_types(arg))
109659 + return;
109660 +
109661 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
109662 + return;
109663 +
109664 + visited = pointer_set_create();
109665 + new_arg = expand(visited, arg);
109666 + pointer_set_destroy(visited);
109667 +
109668 + if (new_arg == NULL_TREE)
109669 + return;
109670 +
109671 + change_function_arg(stmt, arg, argnum, new_arg);
109672 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
109673 +}
109674 +
109675 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
109676 +{
109677 + tree p = TREE_VALUE(attr);
109678 + do {
109679 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
109680 + p = TREE_CHAIN(p);
109681 + } while (p);
109682 +}
109683 +
109684 +static void handle_function_by_hash(gimple stmt, tree fndecl)
109685 +{
109686 + unsigned int num;
109687 + const struct size_overflow_hash *hash;
109688 +
109689 + hash = get_function_hash(fndecl);
109690 + if (!hash)
109691 + return;
109692 +
109693 + for (num = 0; num <= MAX_PARAM; num++)
109694 + if (hash->param & (1U << num))
109695 + handle_function_arg(stmt, fndecl, num);
109696 +}
109697 +
109698 +static bool check_return_value(void)
109699 +{
109700 + const struct size_overflow_hash *hash;
109701 +
109702 + hash = get_function_hash(current_function_decl);
109703 + if (!hash || !(hash->param & 1U << 0))
109704 + return false;
109705 +
109706 + return true;
109707 +}
109708 +
109709 +static void handle_return_value(gimple ret_stmt)
109710 +{
109711 + struct pointer_set_t *visited;
109712 + tree ret, new_ret;
109713 +
109714 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
109715 + return;
109716 +
109717 + ret = gimple_return_retval(ret_stmt);
109718 +
109719 + if (skip_types(ret))
109720 + return;
109721 +
109722 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
109723 + return;
109724 +
109725 + visited = pointer_set_create();
109726 + new_ret = expand(visited, ret);
109727 + pointer_set_destroy(visited);
109728 +
109729 + change_function_return(ret_stmt, ret, new_ret);
109730 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
109731 +}
109732 +
109733 +static void set_plf_false(void)
109734 +{
109735 + basic_block bb;
109736 +
109737 + FOR_ALL_BB(bb) {
109738 + gimple_stmt_iterator si;
109739 +
109740 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
109741 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
109742 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
109743 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
109744 + }
109745 +}
109746 +
109747 +static unsigned int handle_function(void)
109748 +{
109749 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
109750 + bool check_ret;
109751 +
109752 + set_plf_false();
109753 +
109754 + check_ret = check_return_value();
109755 +
109756 + do {
109757 + gimple_stmt_iterator gsi;
109758 + next = bb->next_bb;
109759 +
109760 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
109761 + tree fndecl, attr;
109762 + gimple stmt = gsi_stmt(gsi);
109763 +
109764 + if (check_ret)
109765 + handle_return_value(stmt);
109766 +
109767 + if (!(is_gimple_call(stmt)))
109768 + continue;
109769 + fndecl = gimple_call_fndecl(stmt);
109770 + if (fndecl == NULL_TREE)
109771 + continue;
109772 + if (gimple_call_num_args(stmt) == 0)
109773 + continue;
109774 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
109775 + if (!attr || !TREE_VALUE(attr))
109776 + handle_function_by_hash(stmt, fndecl);
109777 + else
109778 + handle_function_by_attribute(stmt, attr, fndecl);
109779 + gsi = gsi_for_stmt(stmt);
109780 + next = gimple_bb(stmt)->next_bb;
109781 + }
109782 + bb = next;
109783 + } while (bb);
109784 + return 0;
109785 +}
109786 +
109787 +static struct gimple_opt_pass size_overflow_pass = {
109788 + .pass = {
109789 + .type = GIMPLE_PASS,
109790 + .name = "size_overflow",
109791 +#if BUILDING_GCC_VERSION >= 4008
109792 + .optinfo_flags = OPTGROUP_NONE,
109793 +#endif
109794 + .gate = NULL,
109795 + .execute = handle_function,
109796 + .sub = NULL,
109797 + .next = NULL,
109798 + .static_pass_number = 0,
109799 + .tv_id = TV_NONE,
109800 + .properties_required = PROP_cfg,
109801 + .properties_provided = 0,
109802 + .properties_destroyed = 0,
109803 + .todo_flags_start = 0,
109804 + .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
109805 + }
109806 +};
109807 +
109808 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
109809 +{
109810 + tree fntype;
109811 +
109812 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
109813 +
109814 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
109815 + fntype = build_function_type_list(void_type_node,
109816 + const_char_ptr_type_node,
109817 + unsigned_type_node,
109818 + const_char_ptr_type_node,
109819 + const_char_ptr_type_node,
109820 + NULL_TREE);
109821 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
109822 +
109823 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
109824 + TREE_PUBLIC(report_size_overflow_decl) = 1;
109825 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
109826 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
109827 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
109828 +}
109829 +
109830 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
109831 +{
109832 + int i;
109833 + const char * const plugin_name = plugin_info->base_name;
109834 + const int argc = plugin_info->argc;
109835 + const struct plugin_argument * const argv = plugin_info->argv;
109836 + bool enable = true;
109837 +
109838 + struct register_pass_info size_overflow_pass_info = {
109839 + .pass = &size_overflow_pass.pass,
109840 + .reference_pass_name = "ssa",
109841 + .ref_pass_instance_number = 1,
109842 + .pos_op = PASS_POS_INSERT_AFTER
109843 + };
109844 +
109845 + if (!plugin_default_version_check(version, &gcc_version)) {
109846 + error(G_("incompatible gcc/plugin versions"));
109847 + return 1;
109848 + }
109849 +
109850 + for (i = 0; i < argc; ++i) {
109851 + if (!strcmp(argv[i].key, "no-size-overflow")) {
109852 + enable = false;
109853 + continue;
109854 + }
109855 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
109856 + }
109857 +
109858 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
109859 + if (enable) {
109860 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
109861 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
109862 + }
109863 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
109864 +
109865 + return 0;
109866 +}
109867 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
109868 new file mode 100644
109869 index 0000000..ac2901e
109870 --- /dev/null
109871 +++ b/tools/gcc/stackleak_plugin.c
109872 @@ -0,0 +1,327 @@
109873 +/*
109874 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
109875 + * Licensed under the GPL v2
109876 + *
109877 + * Note: the choice of the license means that the compilation process is
109878 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
109879 + * but for the kernel it doesn't matter since it doesn't link against
109880 + * any of the gcc libraries
109881 + *
109882 + * gcc plugin to help implement various PaX features
109883 + *
109884 + * - track lowest stack pointer
109885 + *
109886 + * TODO:
109887 + * - initialize all local variables
109888 + *
109889 + * BUGS:
109890 + * - none known
109891 + */
109892 +#include "gcc-plugin.h"
109893 +#include "config.h"
109894 +#include "system.h"
109895 +#include "coretypes.h"
109896 +#include "tree.h"
109897 +#include "tree-pass.h"
109898 +#include "flags.h"
109899 +#include "intl.h"
109900 +#include "toplev.h"
109901 +#include "plugin.h"
109902 +//#include "expr.h" where are you...
109903 +#include "diagnostic.h"
109904 +#include "plugin-version.h"
109905 +#include "tm.h"
109906 +#include "function.h"
109907 +#include "basic-block.h"
109908 +#include "gimple.h"
109909 +#include "rtl.h"
109910 +#include "emit-rtl.h"
109911 +
109912 +#if BUILDING_GCC_VERSION >= 4008
109913 +#define TODO_dump_func 0
109914 +#endif
109915 +
109916 +extern void print_gimple_stmt(FILE *, gimple, int, int);
109917 +
109918 +int plugin_is_GPL_compatible;
109919 +
109920 +static int track_frame_size = -1;
109921 +static const char track_function[] = "pax_track_stack";
109922 +static const char check_function[] = "pax_check_alloca";
109923 +static bool init_locals;
109924 +
109925 +static struct plugin_info stackleak_plugin_info = {
109926 + .version = "201302112000",
109927 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
109928 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
109929 +};
109930 +
109931 +static bool gate_stackleak_track_stack(void);
109932 +static unsigned int execute_stackleak_tree_instrument(void);
109933 +static unsigned int execute_stackleak_final(void);
109934 +
109935 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
109936 + .pass = {
109937 + .type = GIMPLE_PASS,
109938 + .name = "stackleak_tree_instrument",
109939 +#if BUILDING_GCC_VERSION >= 4008
109940 + .optinfo_flags = OPTGROUP_NONE,
109941 +#endif
109942 + .gate = gate_stackleak_track_stack,
109943 + .execute = execute_stackleak_tree_instrument,
109944 + .sub = NULL,
109945 + .next = NULL,
109946 + .static_pass_number = 0,
109947 + .tv_id = TV_NONE,
109948 + .properties_required = PROP_gimple_leh | PROP_cfg,
109949 + .properties_provided = 0,
109950 + .properties_destroyed = 0,
109951 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
109952 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
109953 + }
109954 +};
109955 +
109956 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
109957 + .pass = {
109958 + .type = RTL_PASS,
109959 + .name = "stackleak_final",
109960 +#if BUILDING_GCC_VERSION >= 4008
109961 + .optinfo_flags = OPTGROUP_NONE,
109962 +#endif
109963 + .gate = gate_stackleak_track_stack,
109964 + .execute = execute_stackleak_final,
109965 + .sub = NULL,
109966 + .next = NULL,
109967 + .static_pass_number = 0,
109968 + .tv_id = TV_NONE,
109969 + .properties_required = 0,
109970 + .properties_provided = 0,
109971 + .properties_destroyed = 0,
109972 + .todo_flags_start = 0,
109973 + .todo_flags_finish = TODO_dump_func
109974 + }
109975 +};
109976 +
109977 +static bool gate_stackleak_track_stack(void)
109978 +{
109979 + return track_frame_size >= 0;
109980 +}
109981 +
109982 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
109983 +{
109984 + gimple check_alloca;
109985 + tree fntype, fndecl, alloca_size;
109986 +
109987 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
109988 + fndecl = build_fn_decl(check_function, fntype);
109989 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
109990 +
109991 + // insert call to void pax_check_alloca(unsigned long size)
109992 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
109993 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
109994 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
109995 +}
109996 +
109997 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
109998 +{
109999 + gimple track_stack;
110000 + tree fntype, fndecl;
110001 +
110002 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110003 + fndecl = build_fn_decl(track_function, fntype);
110004 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110005 +
110006 + // insert call to void pax_track_stack(void)
110007 + track_stack = gimple_build_call(fndecl, 0);
110008 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110009 +}
110010 +
110011 +#if BUILDING_GCC_VERSION == 4005
110012 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110013 +{
110014 + tree fndecl;
110015 +
110016 + if (!is_gimple_call(stmt))
110017 + return false;
110018 + fndecl = gimple_call_fndecl(stmt);
110019 + if (!fndecl)
110020 + return false;
110021 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110022 + return false;
110023 +// print_node(stderr, "pax", fndecl, 4);
110024 + return DECL_FUNCTION_CODE(fndecl) == code;
110025 +}
110026 +#endif
110027 +
110028 +static bool is_alloca(gimple stmt)
110029 +{
110030 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110031 + return true;
110032 +
110033 +#if BUILDING_GCC_VERSION >= 4007
110034 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110035 + return true;
110036 +#endif
110037 +
110038 + return false;
110039 +}
110040 +
110041 +static unsigned int execute_stackleak_tree_instrument(void)
110042 +{
110043 + basic_block bb, entry_bb;
110044 + bool prologue_instrumented = false, is_leaf = true;
110045 +
110046 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110047 +
110048 + // 1. loop through BBs and GIMPLE statements
110049 + FOR_EACH_BB(bb) {
110050 + gimple_stmt_iterator gsi;
110051 +
110052 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110053 + gimple stmt;
110054 +
110055 + stmt = gsi_stmt(gsi);
110056 +
110057 + if (is_gimple_call(stmt))
110058 + is_leaf = false;
110059 +
110060 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110061 + if (!is_alloca(stmt))
110062 + continue;
110063 +
110064 + // 2. insert stack overflow check before each __builtin_alloca call
110065 + stackleak_check_alloca(&gsi);
110066 +
110067 + // 3. insert track call after each __builtin_alloca call
110068 + stackleak_add_instrumentation(&gsi);
110069 + if (bb == entry_bb)
110070 + prologue_instrumented = true;
110071 + }
110072 + }
110073 +
110074 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110075 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110076 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110077 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110078 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110079 + return 0;
110080 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110081 + return 0;
110082 +
110083 + // 4. insert track call at the beginning
110084 + if (!prologue_instrumented) {
110085 + gimple_stmt_iterator gsi;
110086 +
110087 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110088 + if (dom_info_available_p(CDI_DOMINATORS))
110089 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110090 + gsi = gsi_start_bb(bb);
110091 + stackleak_add_instrumentation(&gsi);
110092 + }
110093 +
110094 + return 0;
110095 +}
110096 +
110097 +static unsigned int execute_stackleak_final(void)
110098 +{
110099 + rtx insn, next;
110100 +
110101 + if (cfun->calls_alloca)
110102 + return 0;
110103 +
110104 + // keep calls only if function frame is big enough
110105 + if (get_frame_size() >= track_frame_size)
110106 + return 0;
110107 +
110108 + // 1. find pax_track_stack calls
110109 + for (insn = get_insns(); insn; insn = next) {
110110 + // 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))
110111 + rtx body;
110112 +
110113 + next = NEXT_INSN(insn);
110114 + if (!CALL_P(insn))
110115 + continue;
110116 + body = PATTERN(insn);
110117 + if (GET_CODE(body) != CALL)
110118 + continue;
110119 + body = XEXP(body, 0);
110120 + if (GET_CODE(body) != MEM)
110121 + continue;
110122 + body = XEXP(body, 0);
110123 + if (GET_CODE(body) != SYMBOL_REF)
110124 + continue;
110125 + if (strcmp(XSTR(body, 0), track_function))
110126 + continue;
110127 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110128 + // 2. delete call
110129 + delete_insn_and_edges(insn);
110130 +#if BUILDING_GCC_VERSION >= 4007
110131 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
110132 + insn = next;
110133 + next = NEXT_INSN(insn);
110134 + delete_insn_and_edges(insn);
110135 + }
110136 +#endif
110137 + }
110138 +
110139 +// print_simple_rtl(stderr, get_insns());
110140 +// print_rtl(stderr, get_insns());
110141 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110142 +
110143 + return 0;
110144 +}
110145 +
110146 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110147 +{
110148 + const char * const plugin_name = plugin_info->base_name;
110149 + const int argc = plugin_info->argc;
110150 + const struct plugin_argument * const argv = plugin_info->argv;
110151 + int i;
110152 + struct register_pass_info stackleak_tree_instrument_pass_info = {
110153 + .pass = &stackleak_tree_instrument_pass.pass,
110154 +// .reference_pass_name = "tree_profile",
110155 + .reference_pass_name = "optimized",
110156 + .ref_pass_instance_number = 1,
110157 + .pos_op = PASS_POS_INSERT_BEFORE
110158 + };
110159 + struct register_pass_info stackleak_final_pass_info = {
110160 + .pass = &stackleak_final_rtl_opt_pass.pass,
110161 + .reference_pass_name = "final",
110162 + .ref_pass_instance_number = 1,
110163 + .pos_op = PASS_POS_INSERT_BEFORE
110164 + };
110165 +
110166 + if (!plugin_default_version_check(version, &gcc_version)) {
110167 + error(G_("incompatible gcc/plugin versions"));
110168 + return 1;
110169 + }
110170 +
110171 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
110172 +
110173 + for (i = 0; i < argc; ++i) {
110174 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
110175 + if (!argv[i].value) {
110176 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110177 + continue;
110178 + }
110179 + track_frame_size = atoi(argv[i].value);
110180 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
110181 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110182 + continue;
110183 + }
110184 + if (!strcmp(argv[i].key, "initialize-locals")) {
110185 + if (argv[i].value) {
110186 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110187 + continue;
110188 + }
110189 + init_locals = true;
110190 + continue;
110191 + }
110192 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110193 + }
110194 +
110195 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
110196 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
110197 +
110198 + return 0;
110199 +}
110200 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
110201 new file mode 100644
110202 index 0000000..4fae911
110203 --- /dev/null
110204 +++ b/tools/gcc/structleak_plugin.c
110205 @@ -0,0 +1,277 @@
110206 +/*
110207 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
110208 + * Licensed under the GPL v2
110209 + *
110210 + * Note: the choice of the license means that the compilation process is
110211 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110212 + * but for the kernel it doesn't matter since it doesn't link against
110213 + * any of the gcc libraries
110214 + *
110215 + * gcc plugin to forcibly initialize certain local variables that could
110216 + * otherwise leak kernel stack to userland if they aren't properly initialized
110217 + * by later code
110218 + *
110219 + * Homepage: http://pax.grsecurity.net/
110220 + *
110221 + * Usage:
110222 + * $ # for 4.5/4.6/C based 4.7
110223 + * $ 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
110224 + * $ # for C++ based 4.7/4.8+
110225 + * $ 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
110226 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
110227 + *
110228 + * TODO: eliminate redundant initializers
110229 + * increase type coverage
110230 + */
110231 +
110232 +#include "gcc-plugin.h"
110233 +#include "config.h"
110234 +#include "system.h"
110235 +#include "coretypes.h"
110236 +#include "tree.h"
110237 +#include "tree-pass.h"
110238 +#include "intl.h"
110239 +#include "plugin-version.h"
110240 +#include "tm.h"
110241 +#include "toplev.h"
110242 +#include "function.h"
110243 +#include "tree-flow.h"
110244 +#include "plugin.h"
110245 +#include "gimple.h"
110246 +#include "diagnostic.h"
110247 +#include "cfgloop.h"
110248 +#include "langhooks.h"
110249 +
110250 +#if BUILDING_GCC_VERSION >= 4008
110251 +#define TODO_dump_func 0
110252 +#endif
110253 +
110254 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110255 +
110256 +// unused type flag in all versions 4.5-4.8
110257 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
110258 +
110259 +int plugin_is_GPL_compatible;
110260 +void debug_gimple_stmt(gimple gs);
110261 +
110262 +static struct plugin_info structleak_plugin_info = {
110263 + .version = "201304082245",
110264 + .help = "disable\tdo not activate plugin\n",
110265 +};
110266 +
110267 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
110268 +{
110269 + *no_add_attrs = true;
110270 +
110271 + // check for types? for now accept everything linux has to offer
110272 + if (TREE_CODE(*node) != FIELD_DECL)
110273 + return NULL_TREE;
110274 +
110275 + *no_add_attrs = false;
110276 + return NULL_TREE;
110277 +}
110278 +
110279 +static struct attribute_spec user_attr = {
110280 + .name = "user",
110281 + .min_length = 0,
110282 + .max_length = 0,
110283 + .decl_required = false,
110284 + .type_required = false,
110285 + .function_type_required = false,
110286 + .handler = handle_user_attribute,
110287 +#if BUILDING_GCC_VERSION >= 4007
110288 + .affects_type_identity = true
110289 +#endif
110290 +};
110291 +
110292 +static void register_attributes(void *event_data, void *data)
110293 +{
110294 + register_attribute(&user_attr);
110295 +// register_attribute(&force_attr);
110296 +}
110297 +
110298 +static tree get_field_type(tree field)
110299 +{
110300 + return strip_array_types(TREE_TYPE(field));
110301 +}
110302 +
110303 +static bool is_userspace_type(tree type)
110304 +{
110305 + tree field;
110306 +
110307 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
110308 + tree fieldtype = get_field_type(field);
110309 + enum tree_code code = TREE_CODE(fieldtype);
110310 +
110311 + if (code == RECORD_TYPE || code == UNION_TYPE)
110312 + if (is_userspace_type(fieldtype))
110313 + return true;
110314 +
110315 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
110316 + return true;
110317 + }
110318 + return false;
110319 +}
110320 +
110321 +static void finish_type(void *event_data, void *data)
110322 +{
110323 + tree type = (tree)event_data;
110324 +
110325 + if (TYPE_USERSPACE(type))
110326 + return;
110327 +
110328 + if (is_userspace_type(type))
110329 + TYPE_USERSPACE(type) = 1;
110330 +}
110331 +
110332 +static void initialize(tree var)
110333 +{
110334 + basic_block bb;
110335 + gimple_stmt_iterator gsi;
110336 + tree initializer;
110337 + gimple init_stmt;
110338 +
110339 + // this is the original entry bb before the forced split
110340 + // TODO: check further BBs in case more splits occured before us
110341 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
110342 +
110343 + // first check if the variable is already initialized, warn otherwise
110344 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110345 + gimple stmt = gsi_stmt(gsi);
110346 + tree rhs1;
110347 +
110348 + // we're looking for an assignment of a single rhs...
110349 + if (!gimple_assign_single_p(stmt))
110350 + continue;
110351 + rhs1 = gimple_assign_rhs1(stmt);
110352 +#if BUILDING_GCC_VERSION >= 4007
110353 + // ... of a non-clobbering expression...
110354 + if (TREE_CLOBBER_P(rhs1))
110355 + continue;
110356 +#endif
110357 + // ... to our variable...
110358 + if (gimple_get_lhs(stmt) != var)
110359 + continue;
110360 + // if it's an initializer then we're good
110361 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
110362 + return;
110363 + }
110364 +
110365 + // these aren't the 0days you're looking for
110366 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
110367 +
110368 + // build the initializer expression
110369 + initializer = build_constructor(TREE_TYPE(var), NULL);
110370 +
110371 + // build the initializer stmt
110372 + init_stmt = gimple_build_assign(var, initializer);
110373 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
110374 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
110375 + update_stmt(init_stmt);
110376 +}
110377 +
110378 +static unsigned int handle_function(void)
110379 +{
110380 + basic_block bb;
110381 + unsigned int ret = 0;
110382 + tree var;
110383 +
110384 +#if BUILDING_GCC_VERSION == 4005
110385 + tree vars;
110386 +#else
110387 + unsigned int i;
110388 +#endif
110389 +
110390 + // split the first bb where we can put the forced initializers
110391 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110392 + if (dom_info_available_p(CDI_DOMINATORS))
110393 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110394 +
110395 + // enumarate all local variables and forcibly initialize our targets
110396 +#if BUILDING_GCC_VERSION == 4005
110397 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
110398 + var = TREE_VALUE(vars);
110399 +#else
110400 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
110401 +#endif
110402 + tree type = TREE_TYPE(var);
110403 +
110404 + gcc_assert(DECL_P(var));
110405 + if (!auto_var_in_fn_p(var, current_function_decl))
110406 + continue;
110407 +
110408 + // only care about structure types
110409 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
110410 + continue;
110411 +
110412 + // if the type is of interest, examine the variable
110413 + if (TYPE_USERSPACE(type))
110414 + initialize(var);
110415 + }
110416 +
110417 + return ret;
110418 +}
110419 +
110420 +static struct gimple_opt_pass structleak_pass = {
110421 + .pass = {
110422 + .type = GIMPLE_PASS,
110423 + .name = "structleak",
110424 +#if BUILDING_GCC_VERSION >= 4008
110425 + .optinfo_flags = OPTGROUP_NONE,
110426 +#endif
110427 + .gate = NULL,
110428 + .execute = handle_function,
110429 + .sub = NULL,
110430 + .next = NULL,
110431 + .static_pass_number = 0,
110432 + .tv_id = TV_NONE,
110433 + .properties_required = PROP_cfg,
110434 + .properties_provided = 0,
110435 + .properties_destroyed = 0,
110436 + .todo_flags_start = 0,
110437 + .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
110438 + }
110439 +};
110440 +
110441 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110442 +{
110443 + int i;
110444 + const char * const plugin_name = plugin_info->base_name;
110445 + const int argc = plugin_info->argc;
110446 + const struct plugin_argument * const argv = plugin_info->argv;
110447 + bool enable = true;
110448 +
110449 + struct register_pass_info structleak_pass_info = {
110450 + .pass = &structleak_pass.pass,
110451 + .reference_pass_name = "ssa",
110452 + .ref_pass_instance_number = 1,
110453 + .pos_op = PASS_POS_INSERT_AFTER
110454 + };
110455 +
110456 + if (!plugin_default_version_check(version, &gcc_version)) {
110457 + error(G_("incompatible gcc/plugin versions"));
110458 + return 1;
110459 + }
110460 +
110461 + if (strcmp(lang_hooks.name, "GNU C")) {
110462 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
110463 + enable = false;
110464 + }
110465 +
110466 + for (i = 0; i < argc; ++i) {
110467 + if (!strcmp(argv[i].key, "disable")) {
110468 + enable = false;
110469 + continue;
110470 + }
110471 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110472 + }
110473 +
110474 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
110475 + if (enable) {
110476 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
110477 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
110478 + }
110479 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110480 +
110481 + return 0;
110482 +}
110483 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
110484 index 280dd82..077b427 100644
110485 --- a/tools/lib/lk/Makefile
110486 +++ b/tools/lib/lk/Makefile
110487 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
110488
110489 LIBFILE = liblk.a
110490
110491 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110492 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110493 EXTLIBS = -lelf -lpthread -lrt -lm
110494 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
110495 ALL_LDFLAGS = $(LDFLAGS)
110496 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
110497 index 6789d78..4afd019e 100644
110498 --- a/tools/perf/util/include/asm/alternative-asm.h
110499 +++ b/tools/perf/util/include/asm/alternative-asm.h
110500 @@ -5,4 +5,7 @@
110501
110502 #define altinstruction_entry #
110503
110504 + .macro pax_force_retaddr rip=0, reload=0
110505 + .endm
110506 +
110507 #endif
110508 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
110509 index 96b919d..c49bb74 100644
110510 --- a/tools/perf/util/include/linux/compiler.h
110511 +++ b/tools/perf/util/include/linux/compiler.h
110512 @@ -18,4 +18,12 @@
110513 #define __force
110514 #endif
110515
110516 +#ifndef __size_overflow
110517 +# define __size_overflow(...)
110518 +#endif
110519 +
110520 +#ifndef __intentional_overflow
110521 +# define __intentional_overflow(...)
110522 +#endif
110523 +
110524 #endif
110525 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
110526 index 1580dd4..5627b5b 100644
110527 --- a/virt/kvm/kvm_main.c
110528 +++ b/virt/kvm/kvm_main.c
110529 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
110530
110531 static cpumask_var_t cpus_hardware_enabled;
110532 static int kvm_usage_count = 0;
110533 -static atomic_t hardware_enable_failed;
110534 +static atomic_unchecked_t hardware_enable_failed;
110535
110536 struct kmem_cache *kvm_vcpu_cache;
110537 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
110538
110539 -static __read_mostly struct preempt_ops kvm_preempt_ops;
110540 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
110541 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
110542 +static struct preempt_ops kvm_preempt_ops = {
110543 + .sched_in = kvm_sched_in,
110544 + .sched_out = kvm_sched_out,
110545 +};
110546
110547 struct dentry *kvm_debugfs_dir;
110548
110549 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
110550 /* We can read the guest memory with __xxx_user() later on. */
110551 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
110552 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
110553 - !access_ok(VERIFY_WRITE,
110554 + !__access_ok(VERIFY_WRITE,
110555 (void __user *)(unsigned long)mem->userspace_addr,
110556 mem->memory_size)))
110557 goto out;
110558 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
110559 return 0;
110560 }
110561
110562 -static struct file_operations kvm_vcpu_fops = {
110563 +static file_operations_no_const kvm_vcpu_fops __read_only = {
110564 .release = kvm_vcpu_release,
110565 .unlocked_ioctl = kvm_vcpu_ioctl,
110566 #ifdef CONFIG_COMPAT
110567 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
110568 return 0;
110569 }
110570
110571 -static struct file_operations kvm_vm_fops = {
110572 +static file_operations_no_const kvm_vm_fops __read_only = {
110573 .release = kvm_vm_release,
110574 .unlocked_ioctl = kvm_vm_ioctl,
110575 #ifdef CONFIG_COMPAT
110576 @@ -2662,7 +2667,7 @@ out:
110577 return r;
110578 }
110579
110580 -static struct file_operations kvm_chardev_ops = {
110581 +static file_operations_no_const kvm_chardev_ops __read_only = {
110582 .unlocked_ioctl = kvm_dev_ioctl,
110583 .compat_ioctl = kvm_dev_ioctl,
110584 .llseek = noop_llseek,
110585 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
110586
110587 if (r) {
110588 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
110589 - atomic_inc(&hardware_enable_failed);
110590 + atomic_inc_unchecked(&hardware_enable_failed);
110591 printk(KERN_INFO "kvm: enabling virtualization on "
110592 "CPU%d failed\n", cpu);
110593 }
110594 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
110595
110596 kvm_usage_count++;
110597 if (kvm_usage_count == 1) {
110598 - atomic_set(&hardware_enable_failed, 0);
110599 + atomic_set_unchecked(&hardware_enable_failed, 0);
110600 on_each_cpu(hardware_enable_nolock, NULL, 1);
110601
110602 - if (atomic_read(&hardware_enable_failed)) {
110603 + if (atomic_read_unchecked(&hardware_enable_failed)) {
110604 hardware_disable_all_nolock();
110605 r = -EBUSY;
110606 }
110607 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
110608 kvm_arch_vcpu_put(vcpu);
110609 }
110610
110611 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110612 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110613 struct module *module)
110614 {
110615 int r;
110616 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110617 if (!vcpu_align)
110618 vcpu_align = __alignof__(struct kvm_vcpu);
110619 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
110620 - 0, NULL);
110621 + SLAB_USERCOPY, NULL);
110622 if (!kvm_vcpu_cache) {
110623 r = -ENOMEM;
110624 goto out_free_3;
110625 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110626 if (r)
110627 goto out_free;
110628
110629 + pax_open_kernel();
110630 kvm_chardev_ops.owner = module;
110631 kvm_vm_fops.owner = module;
110632 kvm_vcpu_fops.owner = module;
110633 + pax_close_kernel();
110634
110635 r = misc_register(&kvm_dev);
110636 if (r) {
110637 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110638
110639 register_syscore_ops(&kvm_syscore_ops);
110640
110641 - kvm_preempt_ops.sched_in = kvm_sched_in;
110642 - kvm_preempt_ops.sched_out = kvm_sched_out;
110643 -
110644 r = kvm_init_debug();
110645 if (r) {
110646 printk(KERN_ERR "kvm: create debugfs files failed\n");